aboutsummaryrefslogtreecommitdiff
path: root/modules/services/default.nix
blob: 7409c590fe18d79a26f1ed69e1ef1889a17b46d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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);
  };
}