2022-09-26 19:27:43 +02:00
|
|
|
{ lib, pkgs, ...}:
|
2022-09-26 12:46:09 +02:00
|
|
|
let
|
|
|
|
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ;
|
2022-09-26 19:27:43 +02:00
|
|
|
inherit (pkgs.pseudofile) dir symlink;
|
2022-09-27 15:06:07 +02:00
|
|
|
inherit (pkgs) busybox;
|
2022-09-26 19:27:43 +02:00
|
|
|
|
2022-09-26 12:46:09 +02:00
|
|
|
type_service = types.package // {
|
|
|
|
name = "service";
|
|
|
|
description = "s6-rc service";
|
|
|
|
check = x: isDerivation x && hasAttr "serviceType" x;
|
|
|
|
};
|
|
|
|
|
2022-09-25 12:22:15 +02:00
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
systemPackages = mkOption {
|
|
|
|
type = types.listOf types.package;
|
|
|
|
};
|
|
|
|
services = mkOption {
|
2022-09-26 12:46:09 +02:00
|
|
|
type = types.attrsOf type_service;
|
2022-09-25 12:22:15 +02:00
|
|
|
};
|
2022-09-26 21:45:00 +02:00
|
|
|
environment = mkOption { type = types.anything; };
|
2022-09-26 13:11:26 +02:00
|
|
|
kernel = {
|
|
|
|
config = mkOption {
|
|
|
|
# mostly the values are y n or m, but sometimes
|
|
|
|
# other strings are also used
|
|
|
|
type = types.attrsOf types.nonEmptyStr;
|
|
|
|
};
|
|
|
|
checkedConfig = mkOption {
|
|
|
|
type = types.attrsOf types.nonEmptyStr;
|
|
|
|
};
|
2022-09-25 12:22:15 +02:00
|
|
|
};
|
|
|
|
};
|
2022-09-26 21:45:00 +02:00
|
|
|
config = {
|
|
|
|
environment = dir {
|
2022-09-27 15:06:07 +02:00
|
|
|
bin = dir {
|
|
|
|
sh = symlink "${busybox}/bin/sh";
|
|
|
|
busybox = symlink "${busybox}/bin/busybox";
|
|
|
|
};
|
|
|
|
dev =
|
|
|
|
let node = type: major: minor: mode : { inherit type major minor mode; };
|
|
|
|
in dir {
|
|
|
|
null = node "c" "1" "3" "0666";
|
|
|
|
zero = node "c" "1" "5" "0666";
|
|
|
|
tty = node "c" "5" "0" "0666";
|
|
|
|
console = node "c" "5" "1" "0600";
|
|
|
|
pts = dir {};
|
|
|
|
};
|
2022-09-26 21:45:00 +02:00
|
|
|
etc = dir {
|
|
|
|
profile = symlink
|
|
|
|
(pkgs.writeScript ".profile" ''
|
|
|
|
PATH=${lib.makeBinPath (with pkgs; [ s6-init-bin busybox execline s6-linux-init s6-rc])}
|
|
|
|
export PATH
|
|
|
|
'');
|
2022-09-26 22:02:10 +02:00
|
|
|
passwd = { file = "root::0:0:root:/:/bin/sh\n"; };
|
|
|
|
group = { file = "root::0:\n"; };
|
2022-09-26 21:45:00 +02:00
|
|
|
};
|
2022-09-27 15:06:07 +02:00
|
|
|
proc = dir {};
|
|
|
|
run = dir {};
|
|
|
|
sys = dir {};
|
2022-09-26 21:45:00 +02:00
|
|
|
};
|
|
|
|
};
|
2022-09-25 12:22:15 +02:00
|
|
|
}
|