From 96674e139c35fd41f349ad6cd202c18c34b538d6 Mon Sep 17 00:00:00 2001 From: Gonne Date: Mon, 18 Dec 2023 17:55:00 +0100 Subject: [PATCH] Create backuphost Bragi --- nixos/machines/bragi/configuration.nix | 15 +++++++++ .../machines/bragi/hardware-configuration.nix | 32 +++++++++++++++++++ nixos/machines/bragi/network.nix | 16 ++++++++++ nixos/modules/borgbackup.nix | 32 +++++++++++++++++++ nixos/roles/hardware.nix | 4 +-- 5 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 nixos/machines/bragi/configuration.nix create mode 100644 nixos/machines/bragi/hardware-configuration.nix create mode 100644 nixos/machines/bragi/network.nix create mode 100644 nixos/modules/borgbackup.nix diff --git a/nixos/machines/bragi/configuration.nix b/nixos/machines/bragi/configuration.nix new file mode 100644 index 0000000..f74fbb9 --- /dev/null +++ b/nixos/machines/bragi/configuration.nix @@ -0,0 +1,15 @@ +{ + imports = [ + ./hardware-configuration.nix + ../../roles + ../../roles/hardware.nix + ./network.nix + ../../modules/borgbackup.nix + ]; + + services.mathebau-borgbackup.enable = true; + + # System configuration here + networking.hostName = "bragi"; + system.stateVersion = "23.11"; +} diff --git a/nixos/machines/bragi/hardware-configuration.nix b/nixos/machines/bragi/hardware-configuration.nix new file mode 100644 index 0000000..dd45ba0 --- /dev/null +++ b/nixos/machines/bragi/hardware-configuration.nix @@ -0,0 +1,32 @@ +{lib, ...}: { + imports = []; + + fileSystems."/" = { + device = "gha-root"; + fsType = "tmpfs"; + options = ["size=1G" "mode=755"]; + }; + fileSystems."/persist" = { + device = "/dev/disk/by-uuid/b75e52a1-deee-45d4-b958-086bdaeb4fa4"; #TODO + fsType = "btrfs"; + options = ["subvol=persist"]; + neededForBoot = true; + }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/6b86ec51-b854-4227-9b05-c8e15f7b2e62"; #TODO + fsType = "ext4"; + }; + fileSystems."/nix" = { + device = "/dev/disk/by-uuid/b75e52a1-deee-45d4-b958-086bdaeb4fa4"; #TODO + fsType = "btrfs"; + options = ["subvol=nix"]; + }; + + # swapDevices = [{device = "/dev/disk/by-uuid/";}]; #TODO + + boot.loader.grub.device = "/dev/sda"; + + nix.settings.max-jobs = lib.mkDefault 4; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +} diff --git a/nixos/machines/bragi/network.nix b/nixos/machines/bragi/network.nix new file mode 100644 index 0000000..3d130f0 --- /dev/null +++ b/nixos/machines/bragi/network.nix @@ -0,0 +1,16 @@ +# We sohuld put that config somewhere in roles and give it a parameter or something, +# everyone gets the same nameserver and the same prefixLength and address vs defaultGateway alsways +# depend on the same thing +{ + imports = []; + networking = { + interfaces.enp0s25.ipv4.addresses = [ + { + address = "192.168.1.11"; + prefixLength = 24; + } + ]; + defaultGateway = "192.168.1.137"; + nameservers = ["130.83.2.22" "130.83.56.60" "130.83.22.60" "130.82.22.63"]; + }; +} diff --git a/nixos/modules/borgbackup.nix b/nixos/modules/borgbackup.nix new file mode 100644 index 0000000..fc43eaf --- /dev/null +++ b/nixos/modules/borgbackup.nix @@ -0,0 +1,32 @@ +{ + config, + lib, + ... +}: let + inherit + (lib) + mkIf + mkEnableOption + ; + cfg = config.services.mathebau-borgbackup; +in { + imports = []; + + options.services.mathebau-borgbackup = { + enable = mkEnableOption "mathebau borgbackup service"; + }; + + config = mkIf cfg.enable { + services.borgbackup = { + repos = { + cthulhu = { + authorizedKeys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMSJl1MvabUADTdOCgufsBzn1tIIpxMq4iDcYZsaW1lV Cthulhu Backup" + ]; + path = "/var/lib/cthulhu"; + allowSubRepos = true; + }; + }; + }; + }; +} diff --git a/nixos/roles/hardware.nix b/nixos/roles/hardware.nix index ac55bcc..2491df0 100644 --- a/nixos/roles/hardware.nix +++ b/nixos/roles/hardware.nix @@ -1,5 +1,5 @@ { # Bootloader - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; + boot.loader.grub.enable = true; + # boot.loader.efi.canTouchEfiVariables = true; }