me like nix
1{ inputs, config, ... }:
2
3let
4 nm = config.flake.modules.nixos;
5in
6{
7 flake.nixosConfigurations.pizero = inputs.nixpkgs.lib.nixosSystem {
8 system = "aarch64-linux";
9 modules = [
10 "${inputs.nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
11 inputs.agenix.nixosModules.default
12
13 # Allow missing kernel modules
14 ({
15 nixpkgs.overlays = [
16 (final: super: {
17 makeModulesClosure = x: super.makeModulesClosure (x // { allowMissing = true; });
18 })
19 ];
20 })
21
22 # Aspect modules
23 nm.pi-camera
24 nm.pi-wifi
25 nm.pi-stability
26
27 # Pi Zero 2W specific settings
28 (
29 { pkgs, lib, ... }:
30 {
31 networking.hostName = "pizero";
32
33 pi = {
34 streamName = "pizerocam";
35 resolution = {
36 width = 1280;
37 height = 720;
38 };
39 framerate = 15;
40 deviceTreeFilter = "bcm2837-rpi-zero-2-w.dtb";
41 deviceTreeCompatible = "brcm,bcm2837";
42 gpuMem = 128;
43 flipCamera = true;
44 };
45
46 # Use RPi kernel which includes IMX708 camera driver
47 boot.kernelPackages = pkgs.linuxPackages_rpi3;
48
49 # Disable NixOS DTB so U-Boot uses the firmware's DTB
50 hardware.deviceTree.enable = lib.mkForce false;
51 sdImage.populateFirmwareCommands = lib.mkAfter ''
52 chmod u+w ./firmware/config.txt
53 echo "dtoverlay=imx708" >> ./firmware/config.txt
54 echo "camera_auto_detect=1" >> ./firmware/config.txt
55 '';
56
57 system.stateVersion = "24.11";
58 }
59 )
60 ];
61 };
62}