diff --git a/modules/base.nix b/modules/base.nix index 4830cee1..79b4af0f 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -1,12 +1,19 @@ { lib, ...}: -let inherit (lib) mkEnableOption mkOption types; +let + inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ; + type_service = types.package // { + name = "service"; + description = "s6-rc service"; + check = x: isDerivation x && hasAttr "serviceType" x; + }; + in { options = { systemPackages = mkOption { type = types.listOf types.package; }; services = mkOption { - type = types.anything; + type = types.attrsOf type_service; }; kernel = mkOption { type = types.anything; diff --git a/pkgs/liminix-tools/builder.sh b/pkgs/liminix-tools/builder.sh index f113c91e..74172b48 100644 --- a/pkgs/liminix-tools/builder.sh +++ b/pkgs/liminix-tools/builder.sh @@ -1,6 +1,6 @@ source $stdenv/setup mkdir -p $out/${name} -echo $type > $out/${name}/type +echo $serviceType > $out/${name}/type mkdir -p $out/${name}/dependencies.d echo $buildInputs > $out/buildInputs test -n "$dependencies" && for d in $dependencies; do diff --git a/pkgs/liminix-tools/default.nix b/pkgs/liminix-tools/default.nix index d66f5f7e..c5940ed0 100644 --- a/pkgs/liminix-tools/default.nix +++ b/pkgs/liminix-tools/default.nix @@ -15,7 +15,7 @@ , dependencies ? [] } @ args: stdenvNoCC.mkDerivation { name = "${name}.service"; - type = "longrun"; + serviceType = "longrun"; buildInputs = dependencies; dependencies = builtins.map (d: d.name) dependencies; shell = "${busybox}/bin/sh"; @@ -34,7 +34,7 @@ # stdenvNoCC is to avoid generating derivations with names # like foo.service-mips-linux-musl name = "${name}.service"; - type = "oneshot"; + serviceType = "oneshot"; # does this suffice to make sure dependencies are included # even though the built output has no references to their # store directories? @@ -53,7 +53,7 @@ , ... }: stdenvNoCC.mkDerivation { inherit name; - type = "bundle"; + serviceType = "bundle"; contents = builtins.map (d: d.name) contents; buildInputs = dependencies ++ contents; dependencies = builtins.map (d: d.name) dependencies;