diff --git a/flake.nix b/flake.nix index d31398e..2fdfa51 100644 --- a/flake.nix +++ b/flake.nix @@ -28,7 +28,40 @@ vendorHash = "sha256-PbGOT36n1gyHr0OK0GqZL7B04WHJv+781nGJZIj9LgY="; }; + default = self.packages.${system}.sortseer; }); + + # https://wiki.nixos.org/wiki/NixOS_modules + nixosModules = { + sortseer = { + config, + lib, + pkgs, + ... + }: let + cfg = config.services.sortseer; + in { + options.services.sortseer = { + enable = lib.mkEnableOption "sortseer service"; + }; + + config = lib.mkIf cfg.enable { + systemd.services.sortseer = { + after = ["network.target"]; + wantedBy = ["multi-user.target"]; + serviceConfig = { + ExecStart = "${self.packages.${pkgs.system}.sortseer}/bin/sortseer"; + Restart = "always"; + DynamicUser = true; + # Allow binding to privileged ports + AmbientCapabilities = "CAP_NET_BIND_SERVICE"; + }; + }; + }; + }; + + default = self.nixosModules.sortseer; + }; }; }