{ description = "Pterodactyl Wings"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; }; outputs = { self, nixpkgs }: { packages."x86_64-linux".pterodactyl-wings = nixpkgs.legacyPackages."x86_64-linux".callPackage ./pkgs/wings.nix { }; packages."x86_64-linux".default = self.packages."x86_64-linux".pterodactyl-wings; packages."aarch64-linux".pterodactyl-wings = nixpkgs.legacyPackages."aarch64-linux".callPackage ./pkgs/wings.nix { }; packages."aarch64-linux".default = self.packages."aarch64-linux".pterodactyl-wings; nixosModules.pterodactyl-panel = ./modules/panel.nix; nixosModules.pterodactyl-wings = { lib, config, pkgs, ... }: with lib; let configuration = '' # managed by NixOS '' + "${config.services.wings.configuration}"; in { options.services.wings = { enable = mkOption { type = types.bool; default = false; }; configuration = mkOption { type = types.str; default = null; }; pkg = mkOption { type = types.package; default = self.packages.${pkgs.system}.pterodactyl-wings; }; }; config = mkIf config.services.wings.enable { assertions = [{ assertion = config.services.wings.configuration != null; message = "wings is enabled, configuration must be set."; }]; virtualisation.docker.enable = true; environment.etc."pterodactyl/config.yml".text = configuration; environment.systemPackages = [ config.services.wings.pkg ]; systemd.services.wings = { enable = config.services.wings.enable; description = "Pterodactyl Wings daemon"; after = [ "docker.service" ]; partOf = [ "docker.service" ]; requires = [ "docker.service" ]; startLimitIntervalSec = 180; startLimitBurst = 30; serviceConfig = { User = "root"; WorkingDirectory = "/run/wings"; LimitNOFILE = 4096; PIDFile = "/var/run/wings/daemon.pid"; ExecStart = "/bin/sh -c '/usr/bin/env mkdir /run/wings; /usr/bin/env cat /etc/pterodactyl/config.yml > /run/wings/config.yml; ${config.services.wings.pkg}/bin/wings --config /run/wings/config.yml'"; Restart = "on-failure"; RestartSec = "5s"; }; wantedBy = [ "multi-user.target" ]; }; }; }; nixosModules.default = self.nixosModules.pterodactyl-wings; }; }