-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move systemd related code to separate modules
- Loading branch information
Showing
10 changed files
with
225 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
./installer.nix | ||
./interop.nix | ||
./recovery.nix | ||
./systemd | ||
./version.nix | ||
./wsl-conf.nix | ||
./wsl-distro.nix | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ config, pkgs, lib, ... }: | ||
with lib; { | ||
|
||
imports = [ | ||
./native | ||
./syschdemd | ||
]; | ||
|
||
options.wsl = with types; { | ||
nativeSystemd = mkOption { | ||
type = bool; | ||
default = false; | ||
description = "Use native WSL systemd support"; | ||
}; | ||
}; | ||
|
||
config = | ||
let | ||
cfg = config.wsl; | ||
in | ||
mkIf (cfg.enable) { | ||
|
||
wsl.binShPkg = if cfg.nativeSystemd then bashWrapper else pkgs.bashInteractive; | ||
|
||
# systemd-oomd requires cgroup pressure info which WSL doesn't have | ||
systemd.oomd.enable = false; | ||
|
||
# useful for usbip but adds a dependency on various firmwares which are combined over 300 MB big | ||
services.udev.enable = lib.mkDefault false; | ||
|
||
systemd = { | ||
# Disable systemd units that don't make sense on WSL | ||
services = { | ||
firewall.enable = false; | ||
systemd-resolved.enable = lib.mkDefault false; | ||
# systemd-timesyncd actually works in WSL and without it the clock can drift | ||
systemd-timesyncd.unitConfig.ConditionVirtualization = ""; | ||
}; | ||
|
||
# Don't allow emergency mode, because we don't have a console. | ||
enableEmergencyMode = false; | ||
|
||
# Link the X11 socket into place. This is a no-op on a normal setup, | ||
# but helps if /tmp is a tmpfs or mounted from some other location. | ||
tmpfiles.rules = [ "L /tmp/.X11-unix - - - - ${cfg.wslConf.automount.root}/wslg/.X11-unix" ]; | ||
}; | ||
|
||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ config, pkgs, lib, ... }: | ||
with lib; { | ||
|
||
config = | ||
let | ||
cfg = config.wsl; | ||
nativeUtils = pkgs.callPackage ../scripts/native-utils { }; | ||
in | ||
mkIf (cfg.enable && cfg.nativeSystemd) { | ||
wsl.wslConf = { | ||
user.default = config.users.users.${cfg.defaultUser}.name; | ||
boot.systemd = true; | ||
}; | ||
|
||
system.activationScripts = { | ||
shimSystemd = stringAfter [ ] '' | ||
echo "setting up /sbin/init shim..." | ||
mkdir -p /sbin | ||
ln -sf ${nativeUtils}/bin/systemd-shim /sbin/init | ||
''; | ||
setupLogin = lib.mkIf cfg.populateBin (stringAfter [ ] '' | ||
echo "setting up /bin/login..." | ||
mkdir -p /bin | ||
ln -sf ${pkgs.shadow}/bin/login /bin/login | ||
''); | ||
}; | ||
|
||
environment = { | ||
# preserve $PATH from parent | ||
variables.PATH = [ "$PATH" ]; | ||
extraInit = '' | ||
eval $(${nativeUtils}/bin/split-path --automount-root="${cfg.wslConf.automount.root}" ${lib.optionalString cfg.interop.includePath "--include-interop"}) | ||
''; | ||
}; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ config, pkgs, lib, ... }: | ||
with lib; { | ||
|
||
options = { }; | ||
|
||
config = | ||
let | ||
cfg = config.wsl; | ||
|
||
syschdemd = pkgs.callPackage ./syschdemd.nix { | ||
automountPath = cfg.wslConf.automount.root; | ||
defaultUser = config.users.users.${cfg.defaultUser}; | ||
}; | ||
in | ||
mkIf (cfg.enable && !cfg.nativeSystemd) { | ||
|
||
users.users.root.shell = "${syschdemd}/bin/syschdemd"; | ||
security.sudo.extraConfig = '' | ||
Defaults env_keep+=INSIDE_NAMESPACE | ||
''; | ||
wsl.wslConf.user.default = "root"; | ||
|
||
# Start a systemd user session when starting a command through runuser | ||
security.pam.services.runuser.startSession = true; | ||
|
||
# Include Windows %PATH% in Linux $PATH. | ||
environment.extraInit = mkIf cfg.interop.includePath ''PATH="$PATH:$WSLPATH"''; | ||
environment.systemPackages = [ | ||
(pkgs.runCommand "wslpath" { } '' | ||
mkdir -p $out/bin | ||
ln -s /init $out/bin/wslpath | ||
'') | ||
]; | ||
|
||
}; | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.