1# Provide a basic configuration for installation devices like CDs.
2{
3 config,
4 pkgs,
5 lib,
6 ...
7}:
8
9with lib;
10
11{
12 imports = [
13 # Enable devices which are usually scanned, because we don't know the
14 # target system.
15 ../installer/scan/detected.nix
16 ../installer/scan/not-detected.nix
17
18 # Allow "nixos-rebuild" to work properly by providing
19 # /etc/nixos/configuration.nix.
20 ./clone-config.nix
21
22 # Include a copy of Nixpkgs so that nixos-install works out of
23 # the box.
24 ../installer/cd-dvd/channel.nix
25 ];
26
27 config = {
28 system.nixos.variant_id = lib.mkDefault "installer";
29
30 # Enable in installer, even if the minimal profile disables it.
31 documentation.enable = mkImageMediaOverride true;
32
33 # Show the manual.
34 documentation.nixos.enable = mkImageMediaOverride true;
35
36 # Use less privileged nixos user
37 users.users.nixos = {
38 isNormalUser = true;
39 extraGroups = [
40 "wheel"
41 "networkmanager"
42 "video"
43 ];
44 # Allow the graphical user to login without password
45 initialHashedPassword = "";
46 };
47
48 # Allow the user to log in as root without a password.
49 users.users.root.initialHashedPassword = "";
50
51 # Don't require sudo/root to `reboot` or `poweroff`.
52 security.polkit.enable = true;
53
54 # Allow passwordless sudo from nixos user
55 security.sudo = {
56 enable = mkDefault true;
57 wheelNeedsPassword = mkImageMediaOverride false;
58 };
59
60 # Automatically log in at the virtual consoles.
61 services.getty.autologinUser = "nixos";
62
63 # Some more help text.
64 services.getty.helpLine = ''
65 The "nixos" and "root" accounts have empty passwords.
66
67 To log in over ssh you must set a password for either "nixos" or "root"
68 with `passwd` (prefix with `sudo` for "root"), or add your public key to
69 /home/nixos/.ssh/authorized_keys or /root/.ssh/authorized_keys.
70
71 To set up a wireless connection, run `nmtui`.
72 ''
73 + optionalString config.services.xserver.enable ''
74
75 Type `sudo systemctl start display-manager' to
76 start the graphical user interface.
77 '';
78
79 # We run sshd by default. Login is only possible after adding a
80 # password via "passwd" or by adding a ssh key to ~/.ssh/authorized_keys.
81 # The latter one is particular useful if keys are manually added to
82 # installation device for head-less systems i.e. arm boards by manually
83 # mounting the storage in a different system.
84 services.openssh = {
85 enable = mkDefault true;
86 settings.PermitRootLogin = mkDefault "yes";
87 };
88
89 # Provide networkmanager for easy network configuration.
90 networking.networkmanager.enable = true;
91
92 # Tell the Nix evaluator to garbage collect more aggressively.
93 # This is desirable in memory-constrained environments that don't
94 # (yet) have swap set up.
95 environment.variables.GC_INITIAL_HEAP_SIZE = "1M";
96
97 # Make the installer more likely to succeed in low memory
98 # environments. The kernel's overcommit heustistics bite us
99 # fairly often, preventing processes such as nix-worker or
100 # download-using-manifests.pl from forking even if there is
101 # plenty of free memory.
102 boot.kernel.sysctl."vm.overcommit_memory" = "1";
103
104 # To speed up installation a little bit, include the complete
105 # stdenvNoCC in the Nix store on the CD.
106 system.extraDependencies =
107 with pkgs;
108 [
109 stdenvNoCC # for runCommand
110 busybox
111 # For boot.initrd.systemd
112 makeInitrdNGTool
113 ]
114 ++ jq.all; # for closureInfo
115
116 boot.swraid.enable = true;
117 # remove warning about unset mail
118 boot.swraid.mdadmConf = "PROGRAM ${pkgs.coreutils}/bin/true";
119
120 # Show all debug messages from the kernel but don't log refused packets
121 # because we have the firewall enabled. This makes installs from the
122 # console less cumbersome if the machine has a public IP.
123 networking.firewall.logRefusedConnections = mkDefault false;
124
125 # Prevent installation media from evacuating persistent storage, as their
126 # var directory is not persistent and it would thus result in deletion of
127 # those entries.
128 environment.etc."systemd/pstore.conf".text = ''
129 [PStore]
130 Unlink=no
131 '';
132
133 # allow nix-copy to live system
134 nix.settings.trusted-users = [ "nixos" ];
135
136 # Install less voices for speechd to save some space
137 nixpkgs.overlays = [
138 (_: prev: {
139 mbrola-voices = prev.mbrola-voices.override {
140 # only ship with one voice per language
141 languages = [ "*1" ];
142 };
143 })
144 ];
145 };
146}