74 lines
1.9 KiB
Nix
74 lines
1.9 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
modulesPath,
|
|
...
|
|
}:
|
|
{
|
|
imports = [
|
|
(modulesPath + "/installer/sd-card/sd-image-aarch64.nix")
|
|
];
|
|
|
|
# Raspberry Pi 4 platform
|
|
nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux";
|
|
|
|
# Disable ZFS (not needed, and broken with latest kernel)
|
|
boot.supportedFilesystems.zfs = lib.mkForce false;
|
|
|
|
# Boot configuration - provided by sd-image-aarch64.nix
|
|
# (grub disabled, generic-extlinux-compatible enabled, U-Boot setup)
|
|
|
|
# /boot/firmware is automatically configured by sd-image module
|
|
# Device: /dev/disk/by-label/FIRMWARE (vfat)
|
|
|
|
# tmpfs root with impermanence
|
|
# Override sd-image module's ext4 root definition with mkForce
|
|
fileSystems."/" = lib.mkForce {
|
|
device = "none";
|
|
fsType = "tmpfs";
|
|
options = [
|
|
"defaults"
|
|
"size=2G"
|
|
"mode=755"
|
|
];
|
|
};
|
|
|
|
# The SD partition contains /nix/store and /nix/persist at its root
|
|
# Mount it at a hidden location, then bind mount its /nix to /nix
|
|
fileSystems."/mnt/nixos-sd" = {
|
|
device = "/dev/disk/by-label/NIXOS_SD";
|
|
fsType = "ext4";
|
|
options = [ "noatime" ];
|
|
neededForBoot = true;
|
|
};
|
|
|
|
# Bind mount /nix from the SD partition
|
|
fileSystems."/nix" = {
|
|
device = "/mnt/nixos-sd/nix";
|
|
fsType = "none";
|
|
options = [ "bind" ];
|
|
neededForBoot = true;
|
|
depends = [ "/mnt/nixos-sd" ];
|
|
};
|
|
|
|
# No swap on SD card (wear concern)
|
|
swapDevices = [ ];
|
|
|
|
# SD image build configuration
|
|
sdImage = {
|
|
compressImage = true;
|
|
|
|
# Populate root with directories
|
|
populateRootCommands = ''
|
|
mkdir -p ./files/boot
|
|
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot
|
|
|
|
# Create /nix/persist directory structure for impermanence
|
|
mkdir -p ./files/nix/persist/var/lib/nixos
|
|
mkdir -p ./files/nix/persist/home/ppetru
|
|
mkdir -p ./files/nix/persist/etc
|
|
'';
|
|
};
|
|
}
|