Move device-specific config to a separate module

This commit is contained in:
coolneng 2022-06-17 17:06:21 +02:00
parent 783d7d5982
commit 1525120e29
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
2 changed files with 53 additions and 47 deletions

View File

@ -3,33 +3,7 @@
with pkgs; with pkgs;
{ {
# NixOS wants to enable GRUB by default # Declare system packages
boot.loader.grub.enable = false;
# A bunch of boot parameters needed for optimal runtime on RPi 4B
boot.kernelPackages = linuxPackages_rpi4;
boot.kernelParams = [
"zfs.zfs_arc_max=134217728"
"console=TTYAMA0,115200"
"console=tty1"
"8250.nr_uarts=1"
"iomem=relaxed"
"strict-devmem=0"
];
# Enable SATA-HAT GPIO features
boot.loader.raspberryPi = {
enable = true;
version = 4;
firmwareConfig = ''
iomem=relaxed
strict-devmem=0
dtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4
dtoverlay=w1-gpio
dtparam=i2c1=on
'';
};
environment.systemPackages = [ environment.systemPackages = [
libraspberrypi libraspberrypi
htop htop
@ -38,26 +12,6 @@ with pkgs;
inputs.agenix.defaultPackage.aarch64-linux inputs.agenix.defaultPackage.aarch64-linux
]; ];
# Load PWM hardware timers
boot.kernelModules = [ "pwm_bcm2835" "w1-gpio" "w1-therm" ];
hardware.deviceTree = {
enable = true;
filter = "*-rpi-*.dtb";
overlays = [
{
name = "pwm-2chan";
dtboFile = "${device-tree_rpi.overlays}/pwm-2chan.dtbo";
}
{
name = "w1-gpio";
dtboFile = "${device-tree_rpi.overlays}/w1-gpio.dtbo";
}
];
};
# Enable I2C
hardware.i2c.enable = true;
# Add a swap file # Add a swap file
swapDevices = [{ swapDevices = [{
device = "/swapfile"; device = "/swapfile";
@ -208,6 +162,7 @@ with pkgs;
./modules/periodic.nix ./modules/periodic.nix
./modules/communication.nix ./modules/communication.nix
./modules/information.nix ./modules/information.nix
./modules/device.nix
]; ];
} }

51
modules/device.nix Normal file
View File

@ -0,0 +1,51 @@
{ config, lib, pkgs, ... }:
with pkgs;
{
# A bunch of boot parameters needed for optimal runtime on RPi 4B
boot.kernelPackages = linuxPackages_rpi4;
boot.kernelParams = [
"zfs.zfs_arc_max=134217728"
"console=TTYAMA0,115200"
"console=tty1"
"8250.nr_uarts=1"
"iomem=relaxed"
"strict-devmem=0"
];
# Enable SATA-HAT GPIO features
boot.loader.grub.enable = false;
boot.loader.raspberryPi = {
enable = true;
version = 4;
firmwareConfig = ''
iomem=relaxed
strict-devmem=0
dtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4
dtoverlay=w1-gpio
dtparam=i2c1=on
'';
};
# Load PWM hardware timers
boot.kernelModules = [ "pwm_bcm2835" "w1-gpio" "w1-therm" ];
hardware.deviceTree = {
enable = true;
filter = "*-rpi-*.dtb";
overlays = [
{
name = "pwm-2chan";
dtboFile = "${device-tree_rpi.overlays}/pwm-2chan.dtbo";
}
{
name = "w1-gpio";
dtboFile = "${device-tree_rpi.overlays}/w1-gpio.dtbo";
}
];
};
# Enable I2C
hardware.i2c.enable = true;
}