2023-08-02 09:08:00 +00:00
|
|
|
{ self, lib, ... }:
|
2024-04-23 21:10:05 +00:00
|
|
|
|
2023-08-02 09:08:00 +00:00
|
|
|
let
|
2024-04-23 21:10:05 +00:00
|
|
|
wifiModule =
|
|
|
|
{ ... }:
|
|
|
|
{
|
|
|
|
# use iwd instead of wpa_supplicant
|
|
|
|
networking.wireless.enable = false;
|
|
|
|
|
|
|
|
# Use iwd instead of wpa_supplicant. It has a user friendly CLI
|
|
|
|
networking.wireless.iwd = {
|
|
|
|
enable = true;
|
|
|
|
settings = {
|
|
|
|
Network = {
|
|
|
|
EnableIPv6 = true;
|
|
|
|
RoutePriorityOffset = 300;
|
|
|
|
};
|
|
|
|
Settings.AutoConnect = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-03-17 18:48:49 +00:00
|
|
|
installerModule =
|
2024-05-12 10:39:19 +00:00
|
|
|
{ config, modulesPath, ... }:
|
2024-03-17 18:48:49 +00:00
|
|
|
{
|
|
|
|
imports = [
|
2024-04-23 21:10:05 +00:00
|
|
|
wifiModule
|
2024-03-17 18:48:49 +00:00
|
|
|
self.nixosModules.installer
|
|
|
|
self.inputs.nixos-generators.nixosModules.all-formats
|
2024-04-23 16:55:00 +00:00
|
|
|
(modulesPath + "/installer/cd-dvd/iso-image.nix")
|
2024-03-17 18:48:49 +00:00
|
|
|
];
|
2024-04-23 16:55:00 +00:00
|
|
|
|
|
|
|
isoImage.squashfsCompression = "zstd";
|
|
|
|
|
2024-03-17 18:48:49 +00:00
|
|
|
system.stateVersion = config.system.nixos.version;
|
|
|
|
nixpkgs.pkgs = self.inputs.nixpkgs.legacyPackages.x86_64-linux;
|
|
|
|
};
|
2024-03-06 08:43:50 +00:00
|
|
|
|
2024-04-23 21:10:05 +00:00
|
|
|
installerSystem = lib.nixosSystem {
|
2024-03-07 16:24:57 +00:00
|
|
|
modules = [
|
2024-05-10 13:39:46 +00:00
|
|
|
self.inputs.disko.nixosModules.default
|
2024-03-07 16:24:57 +00:00
|
|
|
installerModule
|
|
|
|
{ disko.memSize = 4096; } # FIXME: otherwise the image builder goes OOM
|
|
|
|
];
|
|
|
|
};
|
2024-04-23 16:55:00 +00:00
|
|
|
|
|
|
|
flashInstallerModule =
|
2024-05-12 10:39:19 +00:00
|
|
|
{ config, ... }:
|
2024-04-23 16:55:00 +00:00
|
|
|
{
|
|
|
|
imports = [
|
2024-04-23 21:10:05 +00:00
|
|
|
wifiModule
|
2024-04-23 16:55:00 +00:00
|
|
|
self.nixosModules.installer
|
|
|
|
];
|
|
|
|
system.stateVersion = config.system.nixos.version;
|
|
|
|
nixpkgs.pkgs = self.inputs.nixpkgs.legacyPackages.x86_64-linux;
|
2024-05-12 11:31:50 +00:00
|
|
|
}
|
|
|
|
// flashDiskoConfig;
|
|
|
|
|
|
|
|
# Important: The partition names need to be different to the clan install
|
|
|
|
flashDiskoConfig = {
|
|
|
|
boot.loader.grub.efiSupport = lib.mkDefault true;
|
|
|
|
boot.loader.grub.efiInstallAsRemovable = lib.mkDefault true;
|
|
|
|
disko.devices = {
|
|
|
|
disk = {
|
|
|
|
main = {
|
|
|
|
type = "disk";
|
|
|
|
device = lib.mkDefault "/dev/null";
|
|
|
|
content = {
|
|
|
|
type = "gpt";
|
|
|
|
partitions = {
|
|
|
|
installer-boot = {
|
|
|
|
size = "1M";
|
|
|
|
type = "EF02"; # for grub MBR
|
|
|
|
priority = 1;
|
|
|
|
};
|
|
|
|
installer-ESP = {
|
|
|
|
size = "512M";
|
|
|
|
type = "EF00";
|
|
|
|
content = {
|
|
|
|
type = "filesystem";
|
|
|
|
format = "vfat";
|
|
|
|
mountpoint = "/boot";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
installer-root = {
|
|
|
|
size = "100%";
|
|
|
|
content = {
|
|
|
|
type = "filesystem";
|
|
|
|
format = "ext4";
|
|
|
|
mountpoint = "/";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-04-23 16:55:00 +00:00
|
|
|
};
|
2024-05-12 11:31:50 +00:00
|
|
|
};
|
2023-08-02 09:08:00 +00:00
|
|
|
in
|
|
|
|
{
|
2024-04-03 11:46:17 +00:00
|
|
|
clan = {
|
2024-04-23 21:10:05 +00:00
|
|
|
# To build a generic installer image (without ssh pubkeys),
|
|
|
|
# use the following command:
|
|
|
|
# $ nix build .#iso-installer
|
|
|
|
machines.iso-installer = {
|
2024-04-03 11:46:17 +00:00
|
|
|
imports = [ installerModule ];
|
|
|
|
fileSystems."/".device = lib.mkDefault "/dev/null";
|
|
|
|
};
|
2024-04-23 21:10:05 +00:00
|
|
|
|
|
|
|
# To directly flash the installer to a disk, use the following command:
|
|
|
|
# $ clan flash flash-installer --disk main /dev/sdX --yes
|
|
|
|
# This will include your ssh public keys in the installer.
|
2024-04-23 16:55:00 +00:00
|
|
|
machines.flash-installer = {
|
|
|
|
imports = [ flashInstallerModule ];
|
2024-04-23 21:10:05 +00:00
|
|
|
boot.loader.grub.enable = lib.mkDefault true;
|
2024-04-23 16:55:00 +00:00
|
|
|
};
|
2024-03-17 18:48:49 +00:00
|
|
|
};
|
2024-04-23 21:10:05 +00:00
|
|
|
flake.packages.x86_64-linux.iso-installer = installerSystem.config.formats.iso;
|
|
|
|
flake.apps.x86_64-linux.install-vm.program = installerSystem.config.formats.vm.outPath;
|
|
|
|
flake.apps.x86_64-linux.install-vm-nogui.program = installerSystem.config.formats.vm-nogui.outPath;
|
2023-07-12 16:25:25 +00:00
|
|
|
}
|