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