-
-
Notifications
You must be signed in to change notification settings - Fork 161
Expand file tree
/
Copy pathdefault.nix
More file actions
69 lines (61 loc) · 1.93 KB
/
Copy pathdefault.nix
File metadata and controls
69 lines (61 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{ config, pkgs, lib, ... }:
with lib; {
imports = [
./wrap-shell.nix
];
config =
let
cfg = config.wsl;
bashWrapper = pkgs.writeShellScriptBin "sh" ''
export PATH="$PATH:${lib.makeBinPath [ pkgs.systemd pkgs.gnugrep ]}"
exec ${pkgs.bashInteractive}/bin/sh "$@"
'';
in
mkIf (cfg.enable) {
system.build.nativeUtils = pkgs.callPackage ../../../utils { };
wsl = {
binShPkg = bashWrapper;
wslConf = {
user.default = config.users.users.${cfg.defaultUser}.name;
boot.systemd = true;
};
extraBin = [
{ src = "${pkgs.shadow}/bin/login"; }
];
};
system.activationScripts = {
createBootedSystemSymlink = stringAfter [ "specialfs" "users" "groups" ] ''
echo "setting up /run/booted-system..."
[[ -e /run/booted-system ]] || ln -sfn "$(readlink -f "$systemConfig")" /run/booted-system
'';
createSbin = stringAfter (optional cfg.populateBin "populateBin") (
if cfg.populateBin
then ''
echo "setting up /sbin..."
if [ ! -L /sbin ]; then
rm -rf /sbin
ln -s /bin /sbin
fi
''
else ''
echo "setting up /sbin..."
if [ ! -d /sbin ]; then
rm -rf /sbin
mkdir -p /sbin
fi
''
);
shimSystemd = stringAfter [ "createSbin" ] ''
echo "setting up /sbin/init shim..."
ln -sf ${config.system.build.nativeUtils}/bin/systemd-shim /sbin/init
'';
};
environment = {
# preserve $PATH from parent
variables.PATH = [ "$PATH" ];
extraInit = ''
eval $(${config.system.build.nativeUtils}/bin/split-path --automount-root="${cfg.wslConf.automount.root}" ${lib.optionalString cfg.interop.includePath "--include-interop"})
'';
};
};
}