-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create module.nix with most of the contents of configuration.nix behind an `enable` option. Import that module and enable the option in configuration.nix to retain backwards compatibility. This allows the flake to be consumed by other system configurations without doing conditional imports.
- Loading branch information
Showing
4 changed files
with
103 additions
and
57 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 |
---|---|---|
@@ -1,46 +1,8 @@ | ||
{ lib, pkgs, config, modulesPath, ... }: | ||
|
||
with lib; | ||
let | ||
defaultUser = "nixos"; | ||
syschdemd = import ./syschdemd.nix { inherit lib pkgs config defaultUser; }; | ||
in | ||
{ | ||
{ lib, pkgs, config, modulesPath, ... }: { | ||
imports = [ | ||
"${modulesPath}/profiles/minimal.nix" | ||
./module.nix | ||
]; | ||
|
||
# WSL is closer to a container than anything else | ||
boot.isContainer = true; | ||
|
||
environment.etc.hosts.enable = false; | ||
environment.etc."resolv.conf".enable = false; | ||
|
||
networking.dhcpcd.enable = false; | ||
|
||
users.users.${defaultUser} = { | ||
isNormalUser = true; | ||
extraGroups = [ "wheel" ]; | ||
}; | ||
|
||
users.users.root = { | ||
shell = "${syschdemd}/bin/syschdemd"; | ||
# Otherwise WSL fails to login as root with "initgroups failed 5" | ||
extraGroups = [ "root" ]; | ||
}; | ||
|
||
security.sudo.wheelNeedsPassword = false; | ||
|
||
# Disable systemd units that don't make sense on WSL | ||
systemd.services."serial-getty@ttyS0".enable = false; | ||
systemd.services."serial-getty@hvc0".enable = false; | ||
systemd.services."getty@tty1".enable = false; | ||
systemd.services."autovt@".enable = false; | ||
|
||
systemd.services.firewall.enable = false; | ||
systemd.services.systemd-resolved.enable = false; | ||
systemd.services.systemd-udevd.enable = false; | ||
|
||
# Don't allow emergency mode, because we don't have a console. | ||
systemd.enableEmergencyMode = false; | ||
wsl.enable = true; | ||
} |
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,53 @@ | ||
{ lib, pkgs, config, modulesPath, ... }: | ||
let | ||
cfg = config.wsl; | ||
syschdemd = import ./syschdemd.nix { | ||
inherit lib pkgs config; | ||
inherit (cfg) defaultUser; | ||
}; | ||
in | ||
{ | ||
options.wsl = { | ||
enable = lib.mkEnableOption "wsl"; | ||
defaultUser = lib.mkOption { | ||
type = lib.types.str; | ||
default = "nixos"; | ||
}; | ||
enableTarball = lib.mkEnableOption "wsl tarball builder"; | ||
}; | ||
config = lib.mkIf cfg.enable { | ||
# WSL is closer to a container than anything else | ||
boot.isContainer = true; | ||
|
||
environment.etc.hosts.enable = false; | ||
environment.etc."resolv.conf".enable = false; | ||
|
||
networking.dhcpcd.enable = false; | ||
|
||
users.users.${cfg.defaultUser} = { | ||
isNormalUser = true; | ||
extraGroups = [ "wheel" ]; | ||
}; | ||
|
||
users.users.root = { | ||
shell = "${syschdemd}/bin/syschdemd"; | ||
# Otherwise WSL fails to login as root with "initgroups failed 5" | ||
extraGroups = [ "root" ]; | ||
}; | ||
|
||
security.sudo.wheelNeedsPassword = false; | ||
|
||
# Disable systemd units that don't make sense on WSL | ||
systemd.services."serial-getty@ttyS0".enable = false; | ||
systemd.services."serial-getty@hvc0".enable = false; | ||
systemd.services."getty@tty1".enable = false; | ||
systemd.services."autovt@".enable = false; | ||
|
||
systemd.services.firewall.enable = false; | ||
systemd.services.systemd-resolved.enable = false; | ||
systemd.services.systemd-udevd.enable = false; | ||
|
||
# Don't allow emergency mode, because we don't have a console. | ||
systemd.enableEmergencyMode = false; | ||
}; | ||
} |