add a type definiton for s6-rc modules

This commit is contained in:
Daniel Barlow 2022-09-26 11:46:09 +01:00
parent cbee488d22
commit 9902d4052b
3 changed files with 13 additions and 6 deletions

View file

@ -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;

View file

@ -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

View file

@ -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;