diff --git a/flake.lock b/flake.lock index bf53ed2..b7fee96 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,27 @@ { "nodes": { + "impermanence": { + "locked": { + "lastModified": 1731242966, + "narHash": "sha256-B3C3JLbGw0FtLSWCjBxU961gLNv+BOOBC6WvstKLYMw=", + "owner": "nix-community", + "repo": "impermanence", + "rev": "3ed3f0eaae9fcc0a8331e77e9319c8a4abd8a71a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "impermanence", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1731676054, - "narHash": "sha256-OZiZ3m8SCMfh3B6bfGC/Bm4x3qc1m2SVEAlkV6iY7Yg=", + "lastModified": 1732014248, + "narHash": "sha256-y/MEyuJ5oBWrWAic/14LaIr/u5E0wRVzyYsouYY3W6w=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5e4fbfb6b3de1aa2872b76d49fafc942626e2add", + "rev": "23e89b7da85c3640bbc2173fe04f4bd114342367", "type": "github" }, "original": { @@ -18,6 +33,7 @@ }, "root": { "inputs": { + "impermanence": "impermanence", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 5bb8033..3fcaed7 100644 --- a/flake.nix +++ b/flake.nix @@ -3,6 +3,7 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + impermanence.url = "github:nix-community/impermanence"; }; outputs = diff --git a/systems/base.nix b/systems/base/configuration.nix similarity index 73% rename from systems/base.nix rename to systems/base/configuration.nix index 48d203e..92c5aa5 100644 --- a/systems/base.nix +++ b/systems/base/configuration.nix @@ -5,7 +5,10 @@ ... }: { - imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; + imports = [ + (modulesPath + "/profiles/qemu-guest.nix") + ./fs.nix + ]; config = { time.timeZone = "Europe/Amsterdam"; @@ -17,10 +20,7 @@ # Enable QEMU Guest for Proxmox services.qemuGuest.enable = lib.mkDefault true; - # Use the boot drive for grub - boot.loader.grub.enable = lib.mkDefault true; - boot.loader.grub.devices = [ "/dev/sda" ]; - + boot.loader.systemd-boot.enable = true; boot.growPartition = lib.mkDefault true; # Allow remote updates with flakes and non-root users @@ -38,14 +38,14 @@ isNormalUser = true; group = "maintenance"; extraGroups = [ "wheel" ]; - openssh.authorizedKeys.keyFiles = [ ../authorized_keys ]; + openssh.authorizedKeys.keyFiles = [ ../../authorized_keys ]; }; users.groups."maintenance" = {}; # Enable mDNS for `hostname.local` addresses services.avahi.enable = true; - services.avahi.nssmdns = true; + services.avahi.nssmdns4 = true; services.avahi.publish = { enable = true; addresses = true; @@ -68,11 +68,18 @@ }; programs.ssh.startAgent = true; - # Default filesystem - fileSystems."/" = lib.mkDefault { - device = "/dev/disk/by-label/nixos"; - autoResize = true; - fsType = "ext4"; + environment.persistence."/persistent" = { + enable = true; + hideMounts = true; + directories = [ + "/var/log" + "/var/lib/nixos" + "/var/lib/systemd/coredump" + "/etc/nixos" + ]; + files = [ + "/etc/machine-id" + ]; }; system.stateVersion = lib.mkDefault "24.05"; diff --git a/systems/base/fs.nix b/systems/base/fs.nix new file mode 100644 index 0000000..0234440 --- /dev/null +++ b/systems/base/fs.nix @@ -0,0 +1,36 @@ +{ + ... +}: +{ + boot.supportedFilesystems = [ "btrfs" ]; + + fileSystems."/" = { + device = "none"; + fsType = "tmpfs"; + options = [ "default" "mode=755" ]; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-label/boot"; + fsType = "fat"; + }; + + fileSystems."/nix" = { + device = "/dev/disk/by-label/btrfs"; + fsType = "btrfs"; + options = [ "compress=zstd" "subvol=nix" "noatime" ]; + }; + + fileSystems."/persistent" = { + device = "/dev/disk/by-label/btrfs"; + fsType = "btrfs"; + options = [ "compress=zstd" "subvol=persistent" "noatime" ]; + autoResize = true; + neededForBoot = true; + }; + + fileSystems."/media" = { + device = "vm@b9b22d11-3492-49a6-92b7-b36cdf0161fe.cephfs=/media"; + fsType = "ceph"; + }; +} diff --git a/utils.nix b/utils.nix index 71b6df4..1d821d5 100644 --- a/utils.nix +++ b/utils.nix @@ -12,6 +12,9 @@ specialArgs = { inherit inputs outputs; }; - modules = [ ./systems/base.nix ] ++ configs; + modules = [ + inputs.impermanence.nixosModules.impermanence + ./systems/base/configuration.nix + ] ++ configs; }; }