From 98d6daf89ec878cf11eba347b1e80f0c29948cff Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 18 Jul 2023 17:30:04 +0300 Subject: [PATCH] Cleaned up lapetus a bit --- hosts/nixos/common/optional/syncthing.nix | 16 ------- hosts/nixos/lapetus/default.nix | 51 ++++------------------ hosts/nixos/lapetus/filesystems.nix | 13 ++++++ hosts/nixos/lapetus/services/syncthing.nix | 9 ++++ hosts/nixos/lapetus/zfs.nix | 0 hosts/nixos/tethys/default.nix | 7 ++- hosts/nixos/tethys/services/syncthing.nix | 23 ++++++++++ secrets.nix | 5 ++- 8 files changed, 60 insertions(+), 64 deletions(-) create mode 100644 hosts/nixos/lapetus/filesystems.nix create mode 100644 hosts/nixos/lapetus/services/syncthing.nix create mode 100644 hosts/nixos/lapetus/zfs.nix create mode 100644 hosts/nixos/tethys/services/syncthing.nix diff --git a/hosts/nixos/common/optional/syncthing.nix b/hosts/nixos/common/optional/syncthing.nix index d2c409a..bbbe4b7 100644 --- a/hosts/nixos/common/optional/syncthing.nix +++ b/hosts/nixos/common/optional/syncthing.nix @@ -25,21 +25,5 @@ in crashReportingEnabled = false; }; }; - - folders = { - "stellar-sanctum" = { - path = "/home/adrielus/Projects/stellar-sanctum/"; - devices = [ "enceladus" ]; - - # TODO: remove this once I switch to zfs - versioning = { - type = "staggered"; - params = { - cleanInterval = "3600"; # 1 hour in seconds - maxAge = "604800"; # 14 days in seconds. - }; - }; - }; - }; }; } diff --git a/hosts/nixos/lapetus/default.nix b/hosts/nixos/lapetus/default.nix index 4186fa0..66d4c53 100644 --- a/hosts/nixos/lapetus/default.nix +++ b/hosts/nixos/lapetus/default.nix @@ -1,61 +1,26 @@ -{ config, ... }: -let - device = "/dev/sda"; - disko = import ./partitions.nix { - disks = [ device ]; - }; -in { imports = [ ../common/global ../common/users/adrielus.nix ../common/optional/slambda.nix + ./services/syncthing.nix ./hardware-configuration.nix - disko + ./zfs.nix + + (import ./partitions.nix { + disks = [ "/dev/sda" ]; + }) ]; - # Set the name of this machine! + # Machine ids networking.hostName = "lapetus"; - - # ID required by zfs. networking.hostId = "08357db3"; - - # Set machine id for log continuity environment.etc.machine-id.text = "d9571439c8a34e34b89727b73bad3587"; # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion system.stateVersion = "23.05"; - # Configure ZFS - boot.supportedFilesystems = [ "zfs" ]; - boot.zfs.extraPools = [ "zroot" ]; - boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; - boot.kernelParams = [ "nohibernate" ]; - - # We use non-legacy mountpoints - # See [this wiki link](https://nixos.wiki/wiki/ZFS) - # systemd.services.zfs-mount.enable = false; - - # Roll back to blank snapshot on boot - # boot.initrd.postDeviceCommands = lib.mkAfter '' - # zfs rollback -r zroot@blank - # ''; - - # {{{ FileSystems - fileSystems = - let zfs = { neededForBoot = true; options = [ "zfsutil" ]; }; - in - { - "/" = zfs; - "/nix" = zfs; - "/persist/data" = zfs; - "/persist/state" = zfs; - "/persist/local/cache" = zfs; - "/boot".neededForBoot = true; - }; - # }}} - - # Boot + # Bootloader boot.loader.systemd-boot.enable = true; } diff --git a/hosts/nixos/lapetus/filesystems.nix b/hosts/nixos/lapetus/filesystems.nix new file mode 100644 index 0000000..69f2097 --- /dev/null +++ b/hosts/nixos/lapetus/filesystems.nix @@ -0,0 +1,13 @@ +{ + fileSystems = + let zfs = { neededForBoot = true; options = [ "zfsutil" ]; }; + in + { + "/" = zfs; + "/nix" = zfs; + "/persist/data" = zfs; + "/persist/state" = zfs; + "/persist/local/cache" = zfs; + "/boot".neededForBoot = true; + }; +} diff --git a/hosts/nixos/lapetus/services/syncthing.nix b/hosts/nixos/lapetus/services/syncthing.nix new file mode 100644 index 0000000..05a0710 --- /dev/null +++ b/hosts/nixos/lapetus/services/syncthing.nix @@ -0,0 +1,9 @@ +{ + imports = [ ../../common/optional/syncthing.nix ]; + + services.syncthing = { + devices.lapetus.id = ""; + + folders = { }; + }; +} diff --git a/hosts/nixos/lapetus/zfs.nix b/hosts/nixos/lapetus/zfs.nix new file mode 100644 index 0000000..e69de29 diff --git a/hosts/nixos/tethys/default.nix b/hosts/nixos/tethys/default.nix index 037b301..04e1bef 100644 --- a/hosts/nixos/tethys/default.nix +++ b/hosts/nixos/tethys/default.nix @@ -10,18 +10,16 @@ ../common/optional/slambda.nix ../common/optional/xdg-portal.nix ../common/optional/hyprland.nix - ../common/optional/syncthing.nix ../common/optional/gitea.nix ../common/optional/xmonad + ./services/syncthing.nix ./hardware-configuration.nix ./boot.nix ]; - # Set the name of this machine! + # Machine ids networking.hostName = "tethys"; - - # Set machine id for log continuity environment.etc.machine-id.text = "08357db3540c4cd2b76d4bb7f825ec88"; # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion @@ -37,6 +35,7 @@ # }}} # {{{ Ad-hoc stylix targets # TODO: include this on all gui hosts + # TODO: is this useful outside of home-manager? stylix.targets.gtk.enable = true; # }}} } diff --git a/hosts/nixos/tethys/services/syncthing.nix b/hosts/nixos/tethys/services/syncthing.nix new file mode 100644 index 0000000..81088ba --- /dev/null +++ b/hosts/nixos/tethys/services/syncthing.nix @@ -0,0 +1,23 @@ +{ + imports = [ ../../common/optional/syncthing.nix ]; + + services.syncthing = { + devices.tethys.id = "NGHX5G4-IY3ZXL2-NQMMRQV-2GDQLC6-LIDWSNG-DAJUAQH-KBAP64V-55K2LQ6"; + + folders = { + "stellar-sanctum" = { + path = "/home/adrielus/Projects/stellar-sanctum/"; + devices = [ "enceladus" "lapetus" ]; + + # TODO: remove this once I switch to zfs + versioning = { + type = "staggered"; + params = { + cleanInterval = "3600"; # 1 hour in seconds + maxAge = "604800"; # 14 days in seconds. + }; + }; + }; + }; + }; +} diff --git a/secrets.nix b/secrets.nix index f876448..0e9361a 100644 --- a/secrets.nix +++ b/secrets.nix @@ -1,7 +1,10 @@ let - adrielus_tethys = builtins.readFile ./hosts/nixos/tethys/id_ed25519.pub; tethys = builtins.readFile ./hosts/nixos/tethys/ssh_host_ed25519_key.pub; lapetus = builtins.readFile ./hosts/nixos/lapetus/ssh_host_ed25519_key.pub; + + adrielus_tethys = builtins.readFile ./hosts/nixos/tethys/id_ed25519.pub; + adrielus_lapetus = builtins.readFile ./hosts/nixos/lapetus/id_ed25519.pub; + all_hosts = [ tethys lapetus ]; in {