From 78db245394834433cf9679baa14e5e39834b1583 Mon Sep 17 00:00:00 2001 From: mjallen18 Date: Sun, 18 Feb 2024 13:09:10 -0600 Subject: [PATCH] add pi4 config to repo --- pi4/configuration.nix | 85 ++++++++++++++++++++++++++++++++++ pi4/docker.nix | 33 +++++++++++++ pi4/flake.lock | 42 +++++++++++++++++ pi4/flake.nix | 18 +++++++ pi4/hardware-configuration.nix | 44 ++++++++++++++++++ 5 files changed, 222 insertions(+) create mode 100644 pi4/configuration.nix create mode 100644 pi4/docker.nix create mode 100644 pi4/flake.lock create mode 100644 pi4/flake.nix create mode 100644 pi4/hardware-configuration.nix diff --git a/pi4/configuration.nix b/pi4/configuration.nix new file mode 100644 index 0000000..e2855c1 --- /dev/null +++ b/pi4/configuration.nix @@ -0,0 +1,85 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +{ config, lib, pkgs, ... }: + +let + user = "matt"; + password = "$y$j9T$EkPXmsmIMFFZ.WRrBYCxS1$P0kwo6e4.WM5DsqUcEqWC3MrZp5KfCjxffraMFZWu06"; + SSID = "Joey’s Jungle"; + SSIDpassword = "kR8v&3Qd"; + interface = "wlan0"; + hostname = "nixos-pi4"; +in { + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ./docker.nix + ]; + + # Enable nix flakes and nix-command tools + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + boot = { + kernelPackages = pkgs.linuxKernel.packages.linux_rpi4; + initrd.availableKernelModules = [ "xhci_pci" "usbhid" "usb_storage" ]; + loader = { + grub.enable = false; + generic-extlinux-compatible.enable = true; + }; + }; + + # Set your time zone. + time.timeZone = "America/Chicago"; + + networking = { + hostName = hostname; + wireless = { + enable = true; + networks."${SSID}".psk = SSIDpassword; + interfaces = [ interface ]; + }; + }; + + environment.systemPackages = with pkgs; [ + vim + raspberrypi-eeprom + htop + git + ]; + + services.openssh.enable = true; + + users = { + mutableUsers = false; + users."${user}" = { + isNormalUser = true; + initialHashedPassword = password; + extraGroups = [ "wheel" "docker" ]; + }; + }; + + virtualisation.docker.enable = true; + + # This option defines the first version of NixOS you have installed on this particular machine, + # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions. + # + # Most users should NEVER change this value after the initial install, for any reason, + # even if you've upgraded your system to a new NixOS release. + # + # This value does NOT affect the Nixpkgs version your packages and OS are pulled from, + # so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how + # to actually do that. + # + # This value being lower than the current NixOS release does NOT mean your system is + # out of date, out of support, or vulnerable. + # + # Do NOT change this value unless you have manually inspected all the changes it would make to your configuration, + # and migrated your data accordingly. + # + # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . + system.stateVersion = "24.05"; # Did you read the comment? + +} + diff --git a/pi4/docker.nix b/pi4/docker.nix new file mode 100644 index 0000000..913a86a --- /dev/null +++ b/pi4/docker.nix @@ -0,0 +1,33 @@ +{ config, pkgs, ... }: + +{ + + # Portainer + virtualisation.oci-containers.containers."portainer" = { + autoStart = true; + image = "portainer/portainer-ce"; + ports = [ "8000:8000" "9443:9443" ]; + volumes = [ + "/var/run/docker.sock:/var/run/docker.sock" + "/media/T5/docker/config/portainer:/data" + ]; + }; + + # Jellyfin + virtualisation.oci-containers.containers."jellyfin" = { + autoStart = true; + image = "jellyfin/jellyfin"; + volumes = [ + "/media/T5/containers/jellyfin/config:/config" + "/media/T5/containers/jellyfin/cache:/cache" + "/media/T5/containers/jellyfin/log:/log" + "/media/T5/movies:/movies" + "/media/T5/tv:/tv" + ]; + ports = [ "8096:8096" ]; + environment = { + JELLYFIN_LOG_DIR = "/log"; + }; + }; + +} diff --git a/pi4/flake.lock b/pi4/flake.lock new file mode 100644 index 0000000..1199271 --- /dev/null +++ b/pi4/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "nixos-hardware": { + "locked": { + "lastModified": 1708091350, + "narHash": "sha256-o28BJYi68qqvHipT7V2jkWxDiMS1LF9nxUsou+eFUPQ=", + "owner": "NixOS", + "repo": "nixos-hardware", + "rev": "106d3fec43bcea19cb2e061ca02531d54b542ce3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixos-hardware", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1708151420, + "narHash": "sha256-MGT/4aGCWQPQiu6COqJdCj9kSpLPiShgbwpbC38YXC8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6e2f00c83911461438301db0dba5281197fe4b3a", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixos-hardware": "nixos-hardware", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/pi4/flake.nix b/pi4/flake.nix new file mode 100644 index 0000000..4021075 --- /dev/null +++ b/pi4/flake.nix @@ -0,0 +1,18 @@ +{ + description = "NixOS configuration with flakes for raspberry pi 4"; + inputs = { + nixos-hardware.url = "github:NixOS/nixos-hardware/master"; + }; + + outputs = { self, nixpkgs, nixos-hardware } @ inputs: { + nixosConfigurations = { + "nixos-pi4" = nixpkgs.lib.nixosSystem { + system = "aarch64-linux"; + modules = [ + nixos-hardware.nixosModules.raspberry-pi-4 + ./configuration.nix + ]; + }; + }; + }; +} diff --git a/pi4/hardware-configuration.nix b/pi4/hardware-configuration.nix new file mode 100644 index 0000000..863f921 --- /dev/null +++ b/pi4/hardware-configuration.nix @@ -0,0 +1,44 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/ec969af6-d557-408a-a149-ba23d31fd8a2"; + fsType = "ext4"; + }; + + fileSystems."/media/T5" = + { device = "/dev/disk/by-uuid/191ce486-899d-4718-81e3-5c9b3ea860e4"; + fsType = "ext4"; + }; + + fileSystems."/FIRMWARE" = + { device = "/dev/disk/by-uuid/5A9F-FC90"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/d9909ef7-c345-48f7-b210-ad7cbe72224b"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.end0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlan0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux"; +}