Skip to content

Commit

Permalink
Update rpi4 config, make sdImage buildable
Browse files Browse the repository at this point in the history
  • Loading branch information
joinemm committed Jul 5, 2024
1 parent a021124 commit b7d783b
Showing 1 changed file with 39 additions and 10 deletions.
49 changes: 39 additions & 10 deletions hosts/archimedes/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
modules,
inputs,
pkgs,
user,
modulesPath,
...
}: {
imports = lib.flatten [
Expand All @@ -12,23 +14,39 @@
ssh-access
])
inputs.nixos-hardware.nixosModules.raspberry-pi-4
(modulesPath + "/installer/sd-card/sd-image-aarch64.nix")
];

hardware.raspberry-pi."4" = {
fkms-3d.enable = true;
touch-ft5406.enable = true;
nixpkgs.overlays = [
(_: super: {
makeModulesClosure = x:
super.makeModulesClosure (x // {allowMissing = true;});
})
];

# makes the sdImage a .img instead of .img.zst
sdImage.compressImage = false;

hardware = {
raspberry-pi."4" = {
apply-overlays-dtmerge.enable = true;
};
deviceTree = {
enable = true;
filter = "*rpi-4-*.dtb";
};
};

nixpkgs.hostPlatform = "aarch64-linux";
networking.hostName = "archimedes";

boot = {
kernelPackages = pkgs.linuxKernel.packages.linux_rpi4;
initrd.availableKernelModules = ["xhci_pci" "usbhid" "usb_storage"];
loader = {
grub.enable = false;
generic-extlinux-compatible.enable = true;
};
console.enable = false;

security.sudo.wheelNeedsPassword = false;

users.users.${user.name} = {
shell = lib.mkForce pkgs.bashInteractive;
extraGroups = ["gpio"];
};

fileSystems = {
Expand All @@ -39,8 +57,19 @@
};
};

users.groups.gpio = {};

# Use GPIO pins as non-root
services.udev.extraRules = ''
SUBSYSTEM=="bcm2835-gpiomem", KERNEL=="gpiomem", GROUP="gpio",MODE="0660"
SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", RUN+="${pkgs.bash}/bin/bash -c 'chown root:gpio /sys/class/gpio/export /sys/class/gpio/unexport ; chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'"
SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add",RUN+="${pkgs.bash}/bin/bash -c 'chown root:gpio /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value ; chmod 660 /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value'"
'';

environment.systemPackages = with pkgs; [
busybox
libraspberrypi
raspberrypi-eeprom
];

system.stateVersion = "24.05";
Expand Down

0 comments on commit b7d783b

Please sign in to comment.