I am trying to create a disk image that I can copy to an SD card and boot a Raspberry Pi 3 B+ from without having to install NixOS from an ISO and then switch to my configuration.
This is my config:
# configuration.nix
{ inputs, lib, modulesPath, pkgs, ... }:
{
imports = [
"${inputs.nixos-hardware.result}/raspberry-pi/3"
./hardware-configuration.nix
# ./services
];
networking = {
interfaces.eth0.useDHCP = lib.mkDefault true;
hostName = "rpi3-dns";
};
hardware.enableRedistributableFirmware = true;
services.timesyncd.enable = lib.mkDefault true;
systemd.services.sshd.wantedBy = lib.mkOverride 40 [ "multi-user.target" ];
services.sshd.enable = true;
# Removes ZFS from the kernel and makes builds faster.
boot.supportedFilesystems = lib.mkForce [ "ext4" "vfat" ];
services.fwupd.enable = false;
services.udisks2.enable = false;
programs.command-not-found.enable = false;
boot.enableContainers = false;
environment.systemPackages = with pkgs; [
dig
];
users = {
mutableUsers = false;
users.plumber = {
description = "Maintenance account for remote access.";
isNormalUser = true;
hashedPassword = "!";
extraGroups = [ "wheel" ];
openssh.authorizedKeys.keys = [
"<removed>"
];
};
users.root = {
password = "root";
};
};
networking.useNetworkd = true;
time.timeZone = "utc";
boot.tmp.cleanOnBoot = true;
nix.gc.automatic = true;
nix.gc.options = "--delete-older-than 30d";
networking.firewall = {
enable = true;
allowedTCPPorts = [ 53 ];
allowedUDPPorts = [ 53 ];
};
nixpkgs.buildPlatform = "aarch64-linux";
system.stateVersion = "24.11";
}
# hardware-configuration.nix
{ config, lib, modulesPath, pkgs, ... }:
{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "usbhid" ];
boot.initrd.kernelModules = [];
boot.kernelModules = [];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
options = [ "noatime" ];
};
swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.end0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlan0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux";
}
I use the command nix run nixpkgs#nixos-generators -- -f sd-aarch64 --flake .#rpi3-dns --system aarch64-linux -o ./pi.sdcard
to generate the SD card image and copy it to a SD card using dd if=nixos.img of=/dev/sda bs=1m
.
The log outputs that are not marked OK
are:
[ TIME ] Timed out waiting for device /dev/disk/by-label/nix-store
[DEPEND] Dependency failed for /sysroot/nix/store
[DEPEND] Dependency failed for Initrd filesystem
[DEPEND] Dependency failed for Find NixOS Closure
...
[ TIME ] Timed out waiting for device /dev/disk/by-label/nix-store
[DEPEND] Dependency failed for /sysroot/nix/store
[DEPEND] Dependency failed for Initrd filesystem
[FAILED] Failed to start NixOS Activation
I don’t see the issue in my config. I was hoping someone with more knowledge could help me out! Thank you for taking your time!