nixos/modules/hardware/raspi4/default.nix

79 lines
1.9 KiB
Nix

{ config, inputs, lib, pkgs, ... }:
let
cfg = config.hardware.az-raspi4;
in
{
imports = [
inputs.nixos-hardware.nixosModules.raspberry-pi-4
];
options = {
hardware.az-raspi4 = {
enable = lib.mkEnableOption "Enable options required for Raspberry Pi 4.";
hostname = lib.mkOption {
type = lib.types.str;
description = "The hostname of the system.";
};
ip = lib.mkOption {
type = lib.types.str;
description = "The IP of the system.";
};
};
};
config = lib.mkIf cfg.enable {
boot = {
supportedFilesystems = lib.mkForce [ "f2fs" "ntfs" "cifs" "ext4" "vfat" "nfs" "nfs4" ];
};
fileSystems = {
"/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
options = [ "noatime" ];
};
};
hardware.raspberry-pi."4".fkms-3d.enable = true;
hardware.raspberry-pi."4".audio.enable = true;
hardware.pulseaudio.enable = true;
environment.systemPackages = with pkgs; [
libraspberrypi
raspberrypi-eeprom
];
networking = {
useDHCP = false;
hostName = cfg.hostname;
hosts = {
"127.0.0.1" = [ "${cfg.hostname}.2li.local" ];
ip = [ "${cfg.hostname}.2li.local" ];
};
defaultGateway = "10.7.89.1";
nameservers = [ "10.7.89.1" ];
interfaces.eth0.ipv4.addresses = [
{
address = cfg.ip;
prefixLength = 24;
}
];
};
environment.shellAliases = {
raspi-cpu = ''
sudo vcgencmd get_throttled && sudo vcgencmd measure_temp
'';
raspi-firmware-update = ''
sudo mkdir -p /mnt && \
sudo mount /dev/disk/by-label/FIRMWARE /mnt && \
BOOTFS=/mnt FIRMWARE_RELEASE_STATUS=stable sudo -E rpi-eeprom-update -d -a && \
sudo umount /mnt
'';
};
services = {
az-log2ram.enable = true;
az-syslog.enable = true;
};
};
}