Skip to content

Commit e110ed4

Browse files
authored
Merge pull request #214 from K900/until-morale-improves
feat: use a Rust tool to do the PATH manipulations
2 parents 65a6b5a + deef781 commit e110ed4

File tree

10 files changed

+525
-185
lines changed

10 files changed

+525
-185
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"rust-analyzer.linkedProjects": [
3-
"scripts/native-systemd-shim/Cargo.toml"
3+
"scripts/native-utils/Cargo.toml"
44
],
55
"workbench.colorCustomizations": {
66
"commandCenter.border": "#e7e7e799",

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
username = pkgs.callPackage ./checks/username.nix args;
5959
};
6060

61-
packages.staticShim = pkgs.pkgsStatic.callPackage ./scripts/native-systemd-shim/shim.nix { };
61+
packages.staticShim = pkgs.pkgsStatic.callPackage ./scripts/native-utils { };
6262

6363
devShell = pkgs.mkShell {
6464
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";

modules/wsl-distro.nix

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ with lib; {
2626
defaultUser = config.users.users.${cfg.defaultUser};
2727
};
2828

29-
shim = pkgs.callPackage ../scripts/native-systemd-shim/shim.nix { };
29+
nativeUtils = pkgs.callPackage ../scripts/native-utils { };
3030

3131
bashWrapper = pkgs.runCommand "nixos-wsl-bash-wrapper" { nativeBuildInputs = [ pkgs.makeWrapper ]; } ''
3232
makeWrapper ${pkgs.bashInteractive}/bin/sh $out/bin/sh --prefix PATH ':' ${lib.makeBinPath [pkgs.systemd pkgs.gnugrep]}
@@ -159,7 +159,7 @@ with lib; {
159159
shimSystemd = stringAfter [ ] ''
160160
echo "setting up /sbin/init shim..."
161161
mkdir -p /sbin
162-
ln -sf ${shim}/bin/nixos-wsl-native-systemd-shim /sbin/init
162+
ln -sf ${nativeUtils}/bin/systemd-shim /sbin/init
163163
'';
164164
setupLogin = stringAfter [ ] ''
165165
echo "setting up /bin/login..."
@@ -172,10 +172,7 @@ with lib; {
172172
# preserve $PATH from parent
173173
variables.PATH = [ "$PATH" ];
174174
extraInit = ''
175-
export WSLPATH=$(echo "$PATH" | tr ':' '\0' | command grep -az "^${cfg.wslConf.automount.root}" | tr '\0' ':')
176-
${if cfg.interop.includePath then "" else ''
177-
export PATH=$(echo "$PATH" | tr ':' '\0' | command grep -avz "^${cfg.wslConf.automount.root}" | tr '\0' ':')
178-
''}
175+
eval $(${nativeUtils}/bin/split-path --automount-root="${cfg.wslConf.automount.root}" ${lib.optionalString cfg.interop.includePath "--include-interop"})
179176
'';
180177
};
181178
})

scripts/native-systemd-shim/Cargo.lock

Lines changed: 0 additions & 166 deletions
This file was deleted.

scripts/native-systemd-shim/Cargo.toml

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)