summary refs log tree commit diff
path: root/nixos/modules/service-managers/trivial.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules/service-managers/trivial.nix')
-rw-r--r--nixos/modules/service-managers/trivial.nix35
1 files changed, 35 insertions, 0 deletions
diff --git a/nixos/modules/service-managers/trivial.nix b/nixos/modules/service-managers/trivial.nix
new file mode 100644
index 000000000000..77e615d1e2e2
--- /dev/null
+++ b/nixos/modules/service-managers/trivial.nix
@@ -0,0 +1,35 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.trivial-services;
+
+  serviceModule.options = {
+    script = mkOption {
+      type = types.lines;
+      description = "Shell commands executed as the service's main process.";
+    };
+
+    environment = mkOption {
+      default = {};
+      type = types.attrs; # FIXME
+      example = { PATH = "/foo/bar/bin"; LANG = "nl_NL.UTF-8"; };
+      description = "Environment variables passed to the service's processes.";
+    };
+  };
+
+  launcher = name: value: pkgs.writeScript name ''
+    #!${pkgs.stdenv.shell} -eu
+
+    ${pkgs.writeScript "${name}-entry" value.script}
+  '';
+in {
+  options.trivial-services = mkOption {
+    default = {};
+    type = with types; attrsOf (types.submodule serviceModule);
+    description = "Definition of trivial services";
+  };
+
+  config.system.build.toplevel-trivial = lib.mapAttrs launcher cfg;
+}