Skip to content

Commit 4bbe114

Browse files
refactor(interop): move PATH interop config to interop.nix
The environment setup for Windows PATH interop logically belongs in interop.nix alongside the includePath option, rather than being buried in the native systemd module.
1 parent 2c118f5 commit 4bbe114

2 files changed

Lines changed: 18 additions & 17 deletions

File tree

modules/interop.nix

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ lib, config, ... }:
1+
{ lib, pkgs, config, ... }:
22

33
with builtins; with lib;
44
{
@@ -32,6 +32,23 @@ with builtins; with lib;
3232
};
3333
};
3434

35+
environment = mkIf cfg.includePath {
36+
# Capture Windows interop paths from the PATH set by WSL. Skip paths
37+
# which don't start with /mnt/c; they are generic defaults (eg.
38+
# /usr/local/sbin) that don't exist on NixOS.
39+
variables.INTEROP_PATH = ''
40+
$(echo -n "$PATH" \
41+
| ${pkgs.coreutils}/bin/tr ':' '\n' \
42+
| ${pkgs.gnugrep}/bin/grep '^${config.wsl.wslConf.automount.root}/' \
43+
| ${pkgs.coreutils}/bin/paste -sd: -)
44+
'';
45+
46+
extraInit = ''
47+
export PATH="$PATH:$INTEROP_PATH"
48+
unset INTEROP_PATH
49+
'';
50+
};
51+
3552
warnings =
3653
let
3754
registrations = config.boot.binfmt.registrations;

modules/systemd/native/default.nix

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,6 @@ with lib; {
5757
'';
5858
};
5959

60-
environment = lib.mkIf cfg.interop.includePath {
61-
# Capture Windows interop paths from the PATH set by WSL. Skip paths
62-
# which don't start with /mnt/c; they are generic defaults (eg.
63-
# /usr/local/sbin) that don't exist on NixOS.
64-
variables.INTEROP_PATH = ''
65-
$(echo -n "$PATH" \
66-
| ${pkgs.coreutils}/bin/tr ':' '\n' \
67-
| ${pkgs.gnugrep}/bin/grep '^${cfg.wslConf.automount.root}/' \
68-
| ${pkgs.coreutils}/bin/paste -sd: -)
69-
'';
70-
71-
extraInit = ''
72-
export PATH="$PATH:$INTEROP_PATH"
73-
unset INTEROP_PATH
74-
'';
75-
};
7660
};
7761

7862
}

0 commit comments

Comments
 (0)