Move raspi4 to modules/hardware
This commit is contained in:
parent
8d6a947382
commit
3fb44aed2c
|
@ -0,0 +1,20 @@
|
|||
# Raspberry Pi 4 Module
|
||||
|
||||
Do not import this module into the main `default.nix` file. Otherwise the other
|
||||
systems aren't buildable anymore because some options from the `nixos-hardware`
|
||||
input get applied immediately.
|
||||
|
||||
Just import it in any system you need with the following code:
|
||||
|
||||
```nix
|
||||
imports = [
|
||||
"${inputs.self}/modules/hardware/raspi4"
|
||||
];
|
||||
hardware = {
|
||||
az-raspi4 = {
|
||||
enable = true;
|
||||
hostname = "some-hostname";
|
||||
ip = "10.7.89.150";
|
||||
};
|
||||
};
|
||||
```
|
|
@ -0,0 +1,78 @@
|
|||
{ 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;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -4,11 +4,16 @@ let
|
|||
in
|
||||
{
|
||||
imports = [
|
||||
(import "${inputs.self}/systems/raspi4" {
|
||||
ip = "10.7.89.109";
|
||||
inherit hostname;
|
||||
})
|
||||
"${inputs.self}/modules/hardware/raspi4"
|
||||
];
|
||||
hardware = {
|
||||
az-raspi4 = {
|
||||
enable = true;
|
||||
hostname = hostname;
|
||||
ip = "10.7.89.109";
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
az-gitea = {
|
||||
enable = true;
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
{ hostname }: { inputs, pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
(import "${inputs.self}/systems/raspi4" {
|
||||
ip = "10.7.89.10";
|
||||
inherit hostname;
|
||||
})
|
||||
"${inputs.self}/modules/hardware/raspi4"
|
||||
];
|
||||
hardware = {
|
||||
az-raspi4 = {
|
||||
enable = true;
|
||||
hostname = hostname;
|
||||
ip = "10.7.89.10";
|
||||
};
|
||||
};
|
||||
|
||||
services.az-docker.enable = true;
|
||||
programs.az-tmux.enable = true;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
{ hostname }: { inputs, pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
(import "${inputs.self}/systems/raspi4" {
|
||||
ip = "10.7.89.123";
|
||||
inherit hostname;
|
||||
})
|
||||
"${inputs.self}/modules/hardware/raspi4"
|
||||
];
|
||||
hardware = {
|
||||
az-raspi4 = {
|
||||
enable = true;
|
||||
hostname = hostname;
|
||||
ip = "10.7.89.123";
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
az-mailserver.enable = true;
|
||||
az-nginx-proxy = {
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
{ hostname }: { inputs, ... }:
|
||||
{
|
||||
imports = [
|
||||
(import "${inputs.self}/systems/raspi4" {
|
||||
ip = "10.7.89.150";
|
||||
inherit hostname;
|
||||
})
|
||||
"${inputs.self}/modules/hardware/raspi4"
|
||||
];
|
||||
fileSystems = {
|
||||
"/mnt/external" = {
|
||||
|
@ -14,6 +11,13 @@
|
|||
};
|
||||
};
|
||||
|
||||
hardware = {
|
||||
az-raspi4 = {
|
||||
enable = true;
|
||||
hostname = hostname;
|
||||
ip = "10.7.89.150";
|
||||
};
|
||||
};
|
||||
# Features
|
||||
services = {
|
||||
az-data-share.enable = true;
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
{ hostname }: { inputs, pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
(import "${inputs.self}/systems/raspi4" {
|
||||
ip = "10.7.89.103";
|
||||
inherit hostname;
|
||||
})
|
||||
"${inputs.self}/modules/hardware/raspi4"
|
||||
];
|
||||
hardware = {
|
||||
az-raspi4 = {
|
||||
enable = true;
|
||||
hostname = hostname;
|
||||
ip = "10.7.89.103";
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
services = {
|
||||
az-nextcloud = {
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
{ hostname }: { inputs, pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
(import "${inputs.self}/systems/raspi4" {
|
||||
ip = "10.7.89.112";
|
||||
inherit hostname;
|
||||
})
|
||||
"${inputs.self}/modules/hardware/raspi4"
|
||||
];
|
||||
hardware = {
|
||||
az-raspi4 = {
|
||||
enable = true;
|
||||
hostname = hostname;
|
||||
ip = "10.7.89.112";
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
az-media-share.enable = true;
|
||||
az-plex.enable = true;
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
{ hostname }: { inputs, pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
(import "${inputs.self}/systems/raspi4" {
|
||||
ip = "10.7.89.99";
|
||||
inherit hostname;
|
||||
})
|
||||
"${inputs.self}/modules/hardware/raspi4"
|
||||
];
|
||||
hardware = {
|
||||
az-raspi4 = {
|
||||
enable = true;
|
||||
hostname = hostname;
|
||||
ip = "10.7.89.99";
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
services = {
|
||||
az-acme-base.enable = true;
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
{ hostname, ip }: { inputs, lib, pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
inputs.nixos-hardware.nixosModules.raspberry-pi-4
|
||||
];
|
||||
|
||||
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 = hostname;
|
||||
hosts = {
|
||||
"127.0.0.1" = [ "${hostname}.2li.local" ];
|
||||
ip = [ "${hostname}.2li.local" ];
|
||||
};
|
||||
defaultGateway = "10.7.89.1";
|
||||
nameservers = [ "10.7.89.1" ];
|
||||
interfaces.eth0.ipv4.addresses = [
|
||||
{
|
||||
address = 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;
|
||||
};
|
||||
}
|
|
@ -1,11 +1,16 @@
|
|||
{ hostname }: { inputs, pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
(import "${inputs.self}/systems/raspi4" {
|
||||
ip = "10.7.89.30";
|
||||
inherit hostname;
|
||||
})
|
||||
"${inputs.self}/modules/hardware/raspi4"
|
||||
];
|
||||
hardware = {
|
||||
az-raspi4 = {
|
||||
enable = true;
|
||||
hostname = hostname;
|
||||
ip = "10.7.89.30";
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
az-restic-server.enable = true;
|
||||
};
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
{ hostname }: { inputs, pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
(import "${inputs.self}/systems/raspi4" {
|
||||
ip = "10.7.89.40";
|
||||
inherit hostname;
|
||||
})
|
||||
"${inputs.self}/modules/hardware/raspi4"
|
||||
];
|
||||
hardware = {
|
||||
az-raspi4 = {
|
||||
enable = true;
|
||||
hostname = hostname;
|
||||
ip = "10.7.89.40";
|
||||
};
|
||||
};
|
||||
|
||||
services.az-docker.enable = true;
|
||||
programs = {
|
||||
az-nix-direnv.enable = true;
|
||||
|
|
|
@ -4,11 +4,16 @@ let
|
|||
in
|
||||
{
|
||||
imports = [
|
||||
(import "${inputs.self}/systems/raspi4" {
|
||||
ip = "10.7.89.115";
|
||||
inherit hostname;
|
||||
})
|
||||
"${inputs.self}/modules/hardware/raspi4"
|
||||
];
|
||||
hardware = {
|
||||
az-raspi4 = {
|
||||
enable = true;
|
||||
hostname = hostname;
|
||||
ip = "10.7.89.115";
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
az-nginx-proxy = {
|
||||
enable = true;
|
||||
|
|
Loading…
Reference in New Issue