infra/nix/os/profiles/install-medium/iso/iso.nix

110 lines
2.7 KiB
Nix
Raw Normal View History

2018-09-16 18:21:16 +02:00
# This module defines a small NixOS installation CD. It does not
# contain any graphical stuff.
2023-02-07 18:24:28 +01:00
{
config,
pkgs,
lib,
...
2024-11-15 10:17:56 +01:00
}:
let
2022-10-31 11:04:38 +01:00
nixos-init-script = ''
#!${pkgs.stdenv.shell}
export HOME=/root
export PATH=${
2024-11-15 10:17:56 +01:00
pkgs.lib.makeBinPath [
config.nix.package
pkgs.systemd
pkgs.gnugrep
pkgs.gnused
config.system.build.nixos-rebuild
config.system.build.nixos-install
pkgs.utillinux
pkgs.e2fsprogs
pkgs.coreutils
pkgs.hdparm
]
}:$PATH
2022-10-31 11:04:38 +01:00
export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
set -xe
fdisk -w always -W always /dev/vda <<EOF
g
n
1
+8M
n
2
+1G
n
3
t
1
4
w
EOF
lsblk
mkfs.ext4 -m0 -L nixos /dev/vda3
mount -L nixos /mnt
mkswap -L swap /dev/vda2
swapon -L swap
mkdir /mnt/etc/nixos -p
cp /dev/vdb /mnt/etc/nixos/configuration.nix
nix-channel --update
nixos-install
reboot
2023-02-07 18:24:28 +01:00
'';
2024-11-15 10:17:56 +01:00
in
{
2018-09-16 18:21:16 +02:00
imports = [
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix>
# Provide an initial copy of the NixOS channel so that the user
# doesn't need to run "nix-channel --update" first.
# <nixpkgs/nixos/modules/installer/cd-dvd/channel.nix>
];
2024-11-15 10:17:56 +01:00
isoImage.isoName = lib.mkForce "${config.isoImage.isoBaseName}-${pkgs.stdenv.hostPlatform.system}.iso";
2018-09-16 18:21:16 +02:00
boot.loader.timeout = lib.mkForce 0;
2022-10-31 11:04:38 +01:00
boot.postBootCommands = "";
2018-09-16 18:21:16 +02:00
2024-11-15 10:17:56 +01:00
environment.systemPackages = [ ];
2018-09-16 18:21:16 +02:00
users.users.root = {
2022-10-31 11:04:38 +01:00
openssh.authorizedKeys.keys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4RFtHz0sE5y0AyZZm/tH7bBBgsx55gLPt5tGsl9yZlOzih6n4qbJE/9OOdwnOY2AHRe2lrlTekbW5ewWSBBCbiBE3Vux86sLgy7LM9zoKaNC+E3hmxaoS9SExn0BTkb3kNlOcj2k6UyJhkZWEsqVMV5C21R8EWmMlLY/qm3AxptNjOyzKDwNX2zlHZ5IyjgzO4ZjIxjawmJlUrVEn7/m+M7qK3I1Tyg/ZvDSfmxVJS97sVzseYE0rVwLEWJQOnHh0wnfl27smr2McAB7Cy6sxKyPKvEGyXbNqqb8fqk4okZlRRxhq/XkKlC7IZr+uqYxlL4HN8vjkTRNlgenDUSVT cardno:000604870382"
];
2018-09-16 18:21:16 +02:00
};
services.gpm.enable = true;
2024-11-15 10:17:56 +01:00
systemd.services.sshd.wantedBy = lib.mkForce [ "multi-user.target" ];
2018-09-16 18:21:16 +02:00
systemd.services.nixos-init = {
script = nixos-init-script;
2024-11-15 10:17:56 +01:00
path = with pkgs; [ ];
2018-09-16 18:21:16 +02:00
2023-02-07 18:24:28 +01:00
description = "Initialize /dev/vda from configuration.nix found at /dev/vdb";
2018-09-16 18:21:16 +02:00
enable = true;
2024-11-15 10:17:56 +01:00
wantedBy = [ "multi-user.target" ];
after = [ "multi-user.target" ];
requires = [ "network-online.target" ];
2022-10-31 11:04:38 +01:00
2018-09-16 18:21:16 +02:00
restartIfChanged = false;
unitConfig.X-StopOnRemoval = false;
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
};
}