From fdbeca13108fac5e5f07fb08d8b28d80ed973c1d Mon Sep 17 00:00:00 2001 From: Stefan Weigl-Bosker Date: Tue, 4 Mar 2025 12:36:18 -0500 Subject: service management wip --- modules/services/default.nix | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 modules/services/default.nix (limited to 'modules/services') diff --git a/modules/services/default.nix b/modules/services/default.nix new file mode 100644 index 0000000..7409c59 --- /dev/null +++ b/modules/services/default.nix @@ -0,0 +1,44 @@ +{ self, config, lib, pkgs, nixgl, ... }: +let + cfg = config.modules.services; + + inherit (lib) mkOption types listOf; + runFile = name: value: { + ${"service/" + name + "/run"} = { + text = value.run; + executable = true; + }; + }; +in +{ + options.modules.services = { + name = mkOption { + type = types.string; + }; + enable = mkOption { + type = types.bool; + default = false; + description = "Whether to enable the user service manager module."; + }; + services = mkOption { + description = "List of user services to run on login"; + type = types.attrsOf (types.submodule { + options = { + run = mkOption { + type = types.str; + description = "The 'run' script for the service"; + example = '' + #!/bin/sh + + exec chpst -e "$TURNSTILE_ENV_DIR" foo + ''; + }; + }; + }); + }; + }; + + config = lib.mkIf cfg.enable { + xdg.configFile = (lib.concatMapAttrs runFile cfg.services); + }; +} -- cgit v1.2.3