diff options
author | Dan Peebles <pumpkin@me.com> | 2017-05-24 18:56:22 -0400 |
---|---|---|
committer | Dan Peebles <pumpkin@me.com> | 2017-05-26 18:14:31 -0400 |
commit | 7c3253e519a572f90a907fc56bb6407da004b24c (patch) | |
tree | bdb31f059a3988521842d5b8ac2d92c7937d26ed /nixos/modules/service-managers | |
parent | 8a11612d502d8578d7828e21778dcf3391084095 (diff) | |
download | nixpkgs-7c3253e519a572f90a907fc56bb6407da004b24c.tar nixpkgs-7c3253e519a572f90a907fc56bb6407da004b24c.tar.gz nixpkgs-7c3253e519a572f90a907fc56bb6407da004b24c.tar.bz2 nixpkgs-7c3253e519a572f90a907fc56bb6407da004b24c.tar.lz nixpkgs-7c3253e519a572f90a907fc56bb6407da004b24c.tar.xz nixpkgs-7c3253e519a572f90a907fc56bb6407da004b24c.tar.zst nixpkgs-7c3253e519a572f90a907fc56bb6407da004b24c.zip |
Simple proof of concept for how to do other types of services
Diffstat (limited to 'nixos/modules/service-managers')
-rw-r--r-- | nixos/modules/service-managers/docker.nix | 29 | ||||
-rw-r--r-- | nixos/modules/service-managers/trivial.nix | 35 |
2 files changed, 64 insertions, 0 deletions
diff --git a/nixos/modules/service-managers/docker.nix b/nixos/modules/service-managers/docker.nix new file mode 100644 index 00000000000..8e9c763b18a --- /dev/null +++ b/nixos/modules/service-managers/docker.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.docker-containers; + + containerModule = { + script = mkOption { + type = types.lines; + description = "Shell commands executed as the service's main process."; + }; + }; + + toContainer = name: value: pkgs.dockerTools.buildImage { + inherit name; + config = { + Cmd = [ value.script ]; + }; + }; +in { + options.docker-containers = mkOption { + default = {}; + type = with types; attrsOf (types.submodule containerModule); + description = "Definition of docker containers"; + }; + + config.system.build.toplevel-docker = lib.mapAttrs toContainer cfg; +} diff --git a/nixos/modules/service-managers/trivial.nix b/nixos/modules/service-managers/trivial.nix new file mode 100644 index 00000000000..77e615d1e2e --- /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; +} |