From 9902d4052bf545bc2e263f665daad3245fff70c5 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Mon, 26 Sep 2022 11:46:09 +0100 Subject: [PATCH] add a type definiton for s6-rc modules --- modules/base.nix | 11 +++++++++-- pkgs/liminix-tools/builder.sh | 2 +- pkgs/liminix-tools/default.nix | 6 +++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/modules/base.nix b/modules/base.nix index 4830cee..79b4af0 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 f113c91..74172b4 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 d66f5f7..c5940ed 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;