From edb701b87dda29a3717f5726190a114638cc3905 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Thu, 22 Sep 2022 00:10:00 +0100 Subject: [PATCH] set PATH for root user, mount /proc and /sys --- make-image.nix | 19 +++++++------------ pkgs/s6-init-files/scripts/rc.init | 3 +++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/make-image.nix b/make-image.nix index afd1571..4b6249b 100644 --- a/make-image.nix +++ b/make-image.nix @@ -37,17 +37,11 @@ let s6-rc-compile $out/compiled $srcs ''; }; - rcS = writeScript "rcS" '' - #!${pkgs.pkgsStatic.busybox}/bin/sh - echo WHEEEE - PATH=${pkgs.pkgsStatic.busybox}/bin:$PATH - export PATH - mount -t devtmpfs none /dev/ - mount -t devpts none /dev/pts - mount -t proc none /proc - mkdir -p /run/services - ''; s6-pseudofiles = pkgs.s6-init-files; + profile = writeScript ".profile" '' + PATH=${lib.makeBinPath (with pkgs; [busybox execline s6-linux-init s6-rc])} + export PATH + ''; pseudofiles = writeText "pseudofiles" '' / d 0755 0 0 /bin d 0755 0 0 @@ -63,18 +57,19 @@ let /dev/tty c 0777 root root 5 0 /dev/console c 0600 root root 5 1 /proc d 0555 root root + /sys d 0555 root root /dev/pts d 0755 0 0 /etc/init.d d 0755 0 0 /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.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" + /.profile s 0644 0 0 ${profile} ''; storefs = callPackage { - storeContents = [ pseudofiles pkgs.strace s6-pseudofiles rcS pkgs.pkgsStatic.busybox s6db pkgs.s6-linux-init ] ++ config.packages ; + storeContents = [ pseudofiles pkgs.strace s6-pseudofiles pkgs.pkgsStatic.busybox s6db pkgs.s6-linux-init ] ++ config.packages ; # comp = "xz -Xdict-size 100%" }; in runCommand "frob-squashfs" { diff --git a/pkgs/s6-init-files/scripts/rc.init b/pkgs/s6-init-files/scripts/rc.init index e4b8ff5..8d43699 100755 --- a/pkgs/s6-init-files/scripts/rc.init +++ b/pkgs/s6-init-files/scripts/rc.init @@ -15,6 +15,9 @@ shift ### This is done only once at boot time. ### Ideally, this phase should just initialize the service manager. +mount -t proc none /proc +mount -t sysfs none /sys + ### If your services are managed by s6-rc: ### (replace /run/service with your scandir) s6-rc-init /run/service -d -c /etc/s6-rc/compiled