From eeaa845dbd0490bbdea2235a714aaba3a63fbe51 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Thu, 17 Aug 2023 21:44:26 +0200 Subject: [PATCH] module untested --- flake.nix | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/flake.nix b/flake.nix index b3174f2..fc01e8b 100644 --- a/flake.nix +++ b/flake.nix @@ -66,5 +66,49 @@ default.program = "${self.packages.${system}.grzegorz-run}/bin/grzegorz-run"; }); + nixosModules.grzegorz-kiosk = { config, pkgs, ... }: let + inherit (pkgs) lib; + cfg = config.services.grzegorz; + in { + options.services.grzegorz = { + + enable = lib.mkEnableOption (lib.mdDoc "grzegorz"); + + package = lib.mkPackageOption self.packages.${config.nixpkgs.system} "grzegorz-run" { }; + + listenAddr = lib.mkOption { + type = lib.types.str; + default = "::"; + }; + listenPort = lib.mkOption { + type = lib.types.port; + default = 9090; + }; + }; + config = { + systemd.services.grzegorz = lib.mkIf cfg.enable { + description = "grzegorz"; + wantedBy = [ "default.target" ]; + serviceConfig = { + User = "grzegorz"; + Group = "grzegorz"; + DynamicUser = true; + #StateDirectory = "grzegorz"; + #CacheDirectory = "grzegorz"; + ExecStart = lib.escapeShellArgs [ + "${pkgs.cage}/bin/cage" + "--" + "${cfg.package}/bin/grzegorz-run" + "--host" cfg.listenAddr + "--port" cfg.listenPort + ]; + Restart = "on-failure"; + }; + }; + + }; + }; + + }; }