Skip to content

Commit

Permalink
feat: use a Rust tool to do the PATH manipulations
Browse files Browse the repository at this point in the history
Overkill? Yes. Fuck bash? Also yes.
  • Loading branch information
K900 committed Feb 1, 2023
1 parent 0487b4d commit deef781
Show file tree
Hide file tree
Showing 10 changed files with 525 additions and 185 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"rust-analyzer.linkedProjects": [
"scripts/native-systemd-shim/Cargo.toml"
"scripts/native-utils/Cargo.toml"
],
"workbench.colorCustomizations": {
"commandCenter.border": "#e7e7e799",
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
username = pkgs.callPackage ./checks/username.nix args;
};

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

devShell = pkgs.mkShell {
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
Expand Down
9 changes: 3 additions & 6 deletions modules/wsl-distro.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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]}
Expand Down Expand Up @@ -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..."
Expand All @@ -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"})
'';
};
})
Expand Down
166 changes: 0 additions & 166 deletions scripts/native-systemd-shim/Cargo.lock

This file was deleted.

10 changes: 0 additions & 10 deletions scripts/native-systemd-shim/Cargo.toml

This file was deleted.

Loading

0 comments on commit deef781

Please sign in to comment.