From 927cd07d84945f88b9cbefa9eee98c7a314717f1 Mon Sep 17 00:00:00 2001 From: JuliusFreudenberger Date: Sat, 18 Jan 2025 20:48:49 +0200 Subject: [PATCH] Add configuration for backup raspberry --- flake.nix | 12 +++ hosts/backup-raspberrypi/.gitignore | 1 + hosts/backup-raspberrypi/default.nix | 77 +++++++++++++++++++ .../hardware-configuration.nix | 33 ++++++++ 4 files changed, 123 insertions(+) create mode 100644 hosts/backup-raspberrypi/.gitignore create mode 100644 hosts/backup-raspberrypi/default.nix create mode 100644 hosts/backup-raspberrypi/hardware-configuration.nix diff --git a/flake.nix b/flake.nix index dc02f56..c48f0f9 100644 --- a/flake.nix +++ b/flake.nix @@ -72,7 +72,19 @@ home-manager.users.${username} = import ./users/${username}/home.nix; } ]; + }; + backup-raspberrypi = nixpkgs.lib.nixosSystem rec { + system = "aarch64"; + + specialArgs = { + inherit inputs outputs; + }; + + modules = [ + nixos-hardware.nixosModules.raspberry-pi-4 + ./hosts/backup-raspberrypi + ]; }; }; }; diff --git a/hosts/backup-raspberrypi/.gitignore b/hosts/backup-raspberrypi/.gitignore new file mode 100644 index 0000000..3ad48c3 --- /dev/null +++ b/hosts/backup-raspberrypi/.gitignore @@ -0,0 +1 @@ +teleport-cred.nix diff --git a/hosts/backup-raspberrypi/default.nix b/hosts/backup-raspberrypi/default.nix new file mode 100644 index 0000000..8f44813 --- /dev/null +++ b/hosts/backup-raspberrypi/default.nix @@ -0,0 +1,77 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ outputs, config, pkgs, ... }: + +{ + imports = + [ + ../../modules/nix.nix + ../../modules/network-server.nix + ../../modules/locale.nix + ../../modules/server-cli.nix + ../../modules/teleport.nix + ./teleport-cred.nix + + # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + nixpkgs = { + overlays = [ + outputs.overlays.additions + ]; + }; + + # Bootloader. + # Use the extlinux boot loader. (NixOS wants to enable GRUB by default) + boot.loader.grub.enable = false; + # Enables the generation of /boot/extlinux/extlinux.conf + boot.loader.generic-extlinux-compatible.enable = true; + + fileSystems."/backups" = + { device = "/dev/disk/by-uuid/7ccdab55-fba4-47b8-aef2-74be0103f885"; + fsType = "btrfs"; + }; + + networking.hostName = "backup-raspberry"; # Define your hostname. + + users = { + users = { + julius = { + isNormalUser = true; + uid = 1000; + extraGroups = [ "wheel" "julius" ]; + }; + restic = { + isNormalUser = true; + uid = 1337; + extraGroups = [ "restic" ]; + }; + }; + groups = { + julius = { + gid = 1000; + }; + restic = { + gid = 1337; + }; + }; + }; + + location = { + latitude = 48.740556; + longitude = 9.310833; + }; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "24.11"; # Did you read the comment? + +} + diff --git a/hosts/backup-raspberrypi/hardware-configuration.nix b/hosts/backup-raspberrypi/hardware-configuration.nix new file mode 100644 index 0000000..236445a --- /dev/null +++ b/hosts/backup-raspberrypi/hardware-configuration.nix @@ -0,0 +1,33 @@ +# 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-label/NIXOS_SD"; + fsType = "ext4"; + }; + + swapDevices = [ ]; + + # 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"; +} +