Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/wsl-distro.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ with builtins; with lib;
config =
let
cfg = config.wsl;
syschdemd = import ../syschdemd.nix { inherit lib pkgs config; defaultUser = cfg.defaultUser; defaultUserHome = config.users.users.${cfg.defaultUser}.home; };
syschdemd = import ../syschdemd.nix { inherit lib pkgs config; inherit (cfg) automountPath defaultUser; defaultUserHome = config.users.users.${cfg.defaultUser}.home; };
in
mkIf cfg.enable {

Expand Down
2 changes: 2 additions & 0 deletions syschdemd.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ lib
, pkgs
, config
, automountPath
, defaultUser
, defaultUserHome ? "/home/${defaultUser}"
, ...
Expand All @@ -21,6 +22,7 @@ pkgs.substituteAll {

systemdWrapper = pkgs.writeShellScript "systemd-wrapper.sh" ''
mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc || true
mount --make-rshared ${automountPath}
exec systemd
'';
}
4 changes: 1 addition & 3 deletions syschdemd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ systemPath=$(${sw}/readlink -f /nix/var/nix/profiles/system)
function start_systemd {
echo "Starting systemd..." >&2

@wrapperDir@/umount /proc/sys/fs/binfmt_misc || true

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

# Wait until systemd has been started to prevent a race condition from occuring
while ! /run/current-system/sw/bin/pgrep -xf systemd >/run/systemd.pid; do
while ! $sw/pgrep -xf systemd | $sw/tail -n1 >/run/systemd.pid; do
$sw/sleep 1s
done

Expand Down