Skip to content

Commit

Permalink
docker-desktop: fix bind mounts (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
nzbr committed Aug 18, 2022
1 parent b199d85 commit 0b29fc7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/wsl-distro.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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

0 comments on commit 0b29fc7

Please sign in to comment.