switch to s6-linux-init and s6-rc

This is at the point where it runs a getty and a pile of s6-supervise
processes, though it doesn't seem to run the things being supervised
This commit is contained in:
Daniel Barlow
2022-09-21 23:01:21 +01:00
parent 6be5b90c96
commit 45025f128a
12 changed files with 404 additions and 22 deletions

View File

@@ -3,6 +3,7 @@ let
inherit (pkgs)
callPackage
closureInfo
lib
runCommand
s6-rc
stdenv
@@ -46,36 +47,42 @@ let
mount -t proc none /proc
mkdir -p /run/services
'';
storefs = callPackage <nixpkgs/nixos/lib/make-squashfs.nix> {
storeContents = [ rcS pkgs.pkgsStatic.busybox s6db pkgs.s6-linux-init ] ++ config.packages ;
# comp = "xz -Xdict-size 100%"
};
s6-pseudofiles = pkgs.s6-init-files;
pseudofiles = writeText "pseudofiles" ''
/ d 0755 0 0
/bin d 0755 0 0
/etc d 0755 0 0
/run d 0755 0 0
/dev d 0755 0 0
/dev/console c 0600 root root 5 1
/dev/null c 0666 root root 1 3
/dev/tty c 0777 root root 5 0
/dev/zero c 0666 root root 1 5
/dev/tty1 c 0777 root root 4 1
/dev/tty2 c 0777 root root 4 2
/dev/tty3 c 0777 root root 4 3
/dev/tty4 c 0777 root root 4 4
/dev/zero c 0666 root root 1 5
/dev/tty c 0777 root root 5 0
/dev/console c 0600 root root 5 1
/proc d 0555 root root
/dev/pts d 0755 0 0
/etc/init.d d 0755 0 0
/bin/init s 0755 0 0 ${pkgs.pkgsStatic.busybox}/bin/init
/bin/init s 0755 0 0 /etc/s6-linux-init/current/bin/init
/bin/sh s 0755 0 0 ${pkgs.pkgsStatic.busybox}/bin/sh
/bin/busybox s 0755 0 0 ${pkgs.pkgsStatic.busybox}/bin/busybox
/bin/busybox s 0755 0 0 ${pkgs.busybox}/bin/busybox
/etc/init.d/rcS s 0755 0 0 ${rcS}
/etc/s6-rc d 0755 0 0
/etc/s6-rc/compiled s 0755 0 0 ${s6db}/compiled
/etc/passwd f 0644 0 0 echo "root::0:0:root:/:/bin/sh"
'';
in runCommand "frob-squashfs" {} ''
cp ${storefs} ./store.img
chmod +w store.img
${pkgs.buildPackages.squashfsTools}/bin/mksquashfs - store.img -no-recovery -quiet -no-progress -root-becomes store -p "/ d 0755 0 0"
${pkgs.buildPackages.squashfsTools}/bin/mksquashfs - store.img -no-recovery -quiet -no-progress -root-becomes nix -pf ${pseudofiles}
cp store.img $out
''
storefs = callPackage <nixpkgs/nixos/lib/make-squashfs.nix> {
storeContents = [ pseudofiles pkgs.strace s6-pseudofiles rcS pkgs.pkgsStatic.busybox s6db pkgs.s6-linux-init ] ++ config.packages ;
# comp = "xz -Xdict-size 100%"
};
in runCommand "frob-squashfs" {
nativeBuildInputs = with pkgs.buildPackages; [ squashfsTools qprint ];
} ''
cp ${storefs} ./store.img
chmod +w store.img
mksquashfs - store.img -no-recovery -quiet -no-progress -root-becomes store -p "/ d 0755 0 0"
mksquashfs - store.img -no-recovery -quiet -no-progress -root-becomes nix -pf ${pseudofiles} -pf ${s6-pseudofiles}
cp store.img $out
''