From 9bbcddfb74cf80cf1fb016aeac9e8554cb4d5850 Mon Sep 17 00:00:00 2001 From: "Casper V. Kristensen" Date: Sun, 13 Oct 2024 18:40:55 +0200 Subject: [PATCH] nixos module --- flake.nix | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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; + }; }; }