From deef7819e9863464365bc251c1070708e0925fc0 Mon Sep 17 00:00:00 2001 From: K900 Date: Wed, 1 Feb 2023 12:15:04 +0300 Subject: feat: use a Rust tool to do the PATH manipulations Overkill? Yes. Fuck bash? Also yes. --- modules/wsl-distro.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/wsl-distro.nix b/modules/wsl-distro.nix index 615da2f..72cdf63 100644 --- a/modules/wsl-distro.nix +++ b/modules/wsl-distro.nix @@ -26,7 +26,7 @@ with lib; { defaultUser = config.users.users.${cfg.defaultUser}; }; - shim = pkgs.callPackage ../scripts/native-systemd-shim/shim.nix { }; + nativeUtils = pkgs.callPackage ../scripts/native-utils { }; bashWrapper = pkgs.runCommand "nixos-wsl-bash-wrapper" { nativeBuildInputs = [ pkgs.makeWrapper ]; } '' makeWrapper ${pkgs.bashInteractive}/bin/sh $out/bin/sh --prefix PATH ':' ${lib.makeBinPath [pkgs.systemd pkgs.gnugrep]} @@ -166,7 +166,7 @@ with lib; { shimSystemd = stringAfter [ ] '' echo "setting up /sbin/init shim..." mkdir -p /sbin - ln -sf ${shim}/bin/nixos-wsl-native-systemd-shim /sbin/init + ln -sf ${nativeUtils}/bin/systemd-shim /sbin/init ''; setupLogin = stringAfter [ ] '' echo "setting up /bin/login..." @@ -179,10 +179,7 @@ with lib; { # preserve $PATH from parent variables.PATH = [ "$PATH" ]; extraInit = '' - export WSLPATH=$(echo "$PATH" | tr ':' '\0' | command grep -az "^${cfg.wslConf.automount.root}" | tr '\0' ':') - ${if cfg.interop.includePath then "" else '' - export PATH=$(echo "$PATH" | tr ':' '\0' | command grep -avz "^${cfg.wslConf.automount.root}" | tr '\0' ':') - ''} + eval $(${nativeUtils}/bin/split-path --automount-root="${cfg.wslConf.automount.root}" ${lib.optionalString cfg.interop.includePath "--include-interop"}) ''; }; }) -- cgit v1.2.3