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
26 # Pi Zero 2W specific settings
27 (
28 { pkgs, lib, ... }:
29 {
30 networking.hostName = "pizero";
31
32 pi = {
33 streamName = "pizerocam";
34 resolution = {
35 width = 1280;
36 height = 720;
37 };
38 framerate = 15;
39 deviceTreeFilter = "bcm2837-rpi-zero-2-w.dtb";
40 deviceTreeCompatible = "brcm,bcm2837";
41 gpuMem = 128;
42 flipCamera = true;
43 };
44
45 # Use RPi kernel which includes IMX708 camera driver
46 boot.kernelPackages = pkgs.linuxPackages_rpi3;
47
48 # Disable NixOS DTB so U-Boot uses the firmware's DTB
49 hardware.deviceTree.enable = lib.mkForce false;
50 sdImage.populateFirmwareCommands = lib.mkAfter ''
51 chmod u+w ./firmware/config.txt
52 echo "dtoverlay=imx708" >> ./firmware/config.txt
53 echo "camera_auto_detect=1" >> ./firmware/config.txt
54 '';
55
56 system.stateVersion = "24.11";
57 }
58 )
59 ];
60 };
61}