Skip to content

Commit

Permalink
syschdemd: remount binfmt_misc inside the namespace
Browse files Browse the repository at this point in the history
We need to do this so systemd-binfmt works
  • Loading branch information
K900 committed Mar 26, 2022
1 parent d3f21ef commit 8d7840d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions syschdemd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ pkgs.substituteAll {
inherit defaultUser;
inherit (config.security) wrapperDir;
fsPackagesPath = lib.makeBinPath config.system.fsPackages;

systemdWrapper = pkgs.writeShellScript "systemd-wrapper.sh" ''
mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc
exec systemd
'';
}
4 changes: 3 additions & 1 deletion syschdemd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ if [ ! -e "/run/current-system" ]; then
fi

if [ ! -e "/run/systemd.pid" ]; then
@wrapperDir@/umount /proc/sys/fs/binfmt_misc

PATH=/run/current-system/systemd/lib/systemd:@fsPackagesPath@ \
LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive \
@daemonize@/bin/daemonize /run/current-system/sw/bin/unshare -fp --mount-proc systemd
@daemonize@/bin/daemonize /run/current-system/sw/bin/unshare -fp --mount-proc @systemdWrapper@
/run/current-system/sw/bin/pgrep -xf systemd >/run/systemd.pid

# Wait for systemd to start
Expand Down

0 comments on commit 8d7840d

Please sign in to comment.