2020-04-24 23:36:52 +00:00
|
|
|
# Provide a basic configuration for installation devices like CDs.
|
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
imports =
|
|
|
|
[ # Enable devices which are usually scanned, because we don't know the
|
|
|
|
# target system.
|
|
|
|
../installer/scan/detected.nix
|
|
|
|
../installer/scan/not-detected.nix
|
|
|
|
|
|
|
|
# Allow "nixos-rebuild" to work properly by providing
|
|
|
|
# /etc/nixos/configuration.nix.
|
|
|
|
./clone-config.nix
|
|
|
|
|
|
|
|
# Include a copy of Nixpkgs so that nixos-install works out of
|
|
|
|
# the box.
|
|
|
|
../installer/cd-dvd/channel.nix
|
|
|
|
];
|
|
|
|
|
|
|
|
config = {
|
2023-01-11 07:51:40 +00:00
|
|
|
system.nixos.variant_id = lib.mkDefault "installer";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Enable in installer, even if the minimal profile disables it.
|
2022-09-11 15:47:08 +00:00
|
|
|
documentation.enable = mkImageMediaOverride true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Show the manual.
|
2022-09-11 15:47:08 +00:00
|
|
|
documentation.nixos.enable = mkImageMediaOverride true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Use less privileged nixos user
|
|
|
|
users.users.nixos = {
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [ "wheel" "networkmanager" "video" ];
|
|
|
|
# Allow the graphical user to login without password
|
|
|
|
initialHashedPassword = "";
|
|
|
|
};
|
|
|
|
|
|
|
|
# Allow the user to log in as root without a password.
|
|
|
|
users.users.root.initialHashedPassword = "";
|
|
|
|
|
|
|
|
# Allow passwordless sudo from nixos user
|
|
|
|
security.sudo = {
|
|
|
|
enable = mkDefault true;
|
2022-09-11 15:47:08 +00:00
|
|
|
wheelNeedsPassword = mkImageMediaOverride false;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# Automatically log in at the virtual consoles.
|
2021-01-05 17:05:55 +00:00
|
|
|
services.getty.autologinUser = "nixos";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Some more help text.
|
2021-01-05 17:05:55 +00:00
|
|
|
services.getty.helpLine = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
The "nixos" and "root" accounts have empty passwords.
|
|
|
|
|
2023-04-12 12:48:02 +00:00
|
|
|
To log in over ssh you must set a password for either "nixos" or "root"
|
|
|
|
with `passwd` (prefix with `sudo` for "root"), or add your public key to
|
|
|
|
/home/nixos/.ssh/authorized_keys or /root/.ssh/authorized_keys.
|
2021-08-18 13:19:15 +00:00
|
|
|
|
|
|
|
If you need a wireless connection, type
|
|
|
|
`sudo systemctl start wpa_supplicant` and configure a
|
|
|
|
network using `wpa_cli`. See the NixOS manual for details.
|
2020-04-24 23:36:52 +00:00
|
|
|
'' + optionalString config.services.xserver.enable ''
|
2021-08-18 13:19:15 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
Type `sudo systemctl start display-manager' to
|
|
|
|
start the graphical user interface.
|
|
|
|
'';
|
|
|
|
|
2023-04-12 12:48:02 +00:00
|
|
|
# We run sshd by default. Login is only possible after adding a
|
|
|
|
# password via "passwd" or by adding a ssh key to ~/.ssh/authorized_keys.
|
2020-09-25 04:45:31 +00:00
|
|
|
# The latter one is particular useful if keys are manually added to
|
|
|
|
# installation device for head-less systems i.e. arm boards by manually
|
|
|
|
# mounting the storage in a different system.
|
2020-04-24 23:36:52 +00:00
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
2023-01-20 10:41:00 +00:00
|
|
|
settings.PermitRootLogin = "yes";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# Enable wpa_supplicant, but don't start it by default.
|
|
|
|
networking.wireless.enable = mkDefault true;
|
2021-08-18 13:19:15 +00:00
|
|
|
networking.wireless.userControlled.enable = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
systemd.services.wpa_supplicant.wantedBy = mkOverride 50 [];
|
|
|
|
|
|
|
|
# Tell the Nix evaluator to garbage collect more aggressively.
|
|
|
|
# This is desirable in memory-constrained environments that don't
|
|
|
|
# (yet) have swap set up.
|
|
|
|
environment.variables.GC_INITIAL_HEAP_SIZE = "1M";
|
|
|
|
|
|
|
|
# Make the installer more likely to succeed in low memory
|
|
|
|
# environments. The kernel's overcommit heustistics bite us
|
|
|
|
# fairly often, preventing processes such as nix-worker or
|
|
|
|
# download-using-manifests.pl from forking even if there is
|
|
|
|
# plenty of free memory.
|
|
|
|
boot.kernel.sysctl."vm.overcommit_memory" = "1";
|
|
|
|
|
|
|
|
# To speed up installation a little bit, include the complete
|
|
|
|
# stdenv in the Nix store on the CD.
|
|
|
|
system.extraDependencies = with pkgs;
|
|
|
|
[
|
|
|
|
stdenv
|
|
|
|
stdenvNoCC # for runCommand
|
|
|
|
busybox
|
|
|
|
jq # for closureInfo
|
2022-04-27 09:35:20 +00:00
|
|
|
# For boot.initrd.systemd
|
|
|
|
makeInitrdNGTool
|
|
|
|
systemdStage1
|
|
|
|
systemdStage1Network
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# Show all debug messages from the kernel but don't log refused packets
|
|
|
|
# because we have the firewall enabled. This makes installs from the
|
|
|
|
# console less cumbersome if the machine has a public IP.
|
|
|
|
networking.firewall.logRefusedConnections = mkDefault false;
|
2021-05-20 23:08:51 +00:00
|
|
|
|
|
|
|
# Prevent installation media from evacuating persistent storage, as their
|
|
|
|
# var directory is not persistent and it would thus result in deletion of
|
|
|
|
# those entries.
|
|
|
|
environment.etc."systemd/pstore.conf".text = ''
|
|
|
|
[PStore]
|
|
|
|
Unlink=no
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|