commit 0baeb893a1f5227701cc3cf9df0d2cb273f27844 Author: Charlotte 🦝 Delenk Date: Fri Jan 14 10:19:01 2022 +0100 Initial Commit diff --git a/config/default.nix b/config/default.nix new file mode 100644 index 00000000..33c79de5 --- /dev/null +++ b/config/default.nix @@ -0,0 +1,5 @@ +{ ... }: { + imports = [ + ./zfs.nix + ]; +} diff --git a/config/grub.nix b/config/grub.nix new file mode 100644 index 00000000..a2f871d1 --- /dev/null +++ b/config/grub.nix @@ -0,0 +1,4 @@ +{ ... }: { + boot.loader.grub.enable = true; + boot.loader.grub.version = 2; +} diff --git a/config/nixos-8gb-fsn1-1.nix b/config/nixos-8gb-fsn1-1.nix new file mode 100644 index 00000000..99d25c25 --- /dev/null +++ b/config/nixos-8gb-fsn1-1.nix @@ -0,0 +1,86 @@ +{ config, pkgs, lib, modulesPath, ... }: { + networking.hostName = "nixos-8gb-fsn1-1"; + networking.hostId = "73561e1f"; + + imports = [ + (modulesPath + "/profiles/qemu-guest.nix") + ./grub.nix + ]; + + boot.initrd.availableKernelModules = [ "ata_piix" "virtio_pci" "virtio_scsi" "xhci_pci" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + boot.supportedFilesystems = [ "zfs" ]; + boot.kernelParams = ["zfs_force=1"]; # Remove after next boot + + fileSystems."/nix" = + { device = "tank/nixos/nix"; + fsType = "zfs"; + options = [ "zfsutil" ]; + }; + + fileSystems."/etc" = + { device = "tank/nixos/etc"; + fsType = "zfs"; + options = [ "zfsutil" ]; + }; + + fileSystems."/var" = + { device = "tank/nixos/var"; + fsType = "zfs"; + options = [ "zfsutil" ]; + }; + + fileSystems."/var/lib" = + { device = "tank/nixos/var/lib"; + fsType = "zfs"; + options = [ "zfsutil" ]; + }; + + fileSystems."/var/log" = + { device = "tank/nixos/var/log"; + fsType = "zfs"; + options = [ "zfsutil" ]; + }; + + fileSystems."/var/spool" = + { device = "tank/nixos/var/spool"; + fsType = "zfs"; + options = [ "zfsutil" ]; + }; + + fileSystems."/home" = + { device = "tank/userdata/home"; + fsType = "zfs"; + options = [ "zfsutil" ]; + }; + + fileSystems."/root" = + { device = "tank/userdata/home/root"; + fsType = "zfs"; + options = [ "zfsutil" ]; + }; + + fileSystems."/home/darkkirb" = + { device = "tank/userdata/home/darkkirb"; + fsType = "zfs"; + options = [ "zfsutil" ]; + }; + + fileSystems."/home/miifox" = + { device = "tank/userdata/home/miifox"; + fsType = "zfs"; + options = [ "zfsutil" ]; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/8E14-4366"; + fsType = "vfat"; + options = [ "X-mount.mkdir" ]; + }; + + swapDevices = [ ]; + + system.stateVersion = "21.11"; +} diff --git a/config/zfs.nix b/config/zfs.nix new file mode 100644 index 00000000..0de0a7f7 --- /dev/null +++ b/config/zfs.nix @@ -0,0 +1,8 @@ +{ ... }: { + boot.supportedFilesystems = [ "zfs" ]; + boot.zfs.devNodes = "/dev/"; + services.zfs.trim.enable = true; + services.zfs.autoScrub.enable = true; + services.zfs.autoScrub.pools = [ "tank" ]; + services.zfs.autoSnapshot.enable = true; +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..abca2cb5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +rec { + description = "Lotte's NixOS installation"; + + # Use NixOS unstable + inputs.nixpkgs.url = "github:nixos/nixpkgs"; + inputs.home-manager.url = "github:nix-community/home-manager"; + inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs"; + inputs.sops-nix.url = github:Mic92/sops-nix; + inputs.sops-nix.inputs.nixpkgs.follows = "nixpkgs"; + + outputs = { self, nixpkgs, ... } @ args: { + nixosConfigurations = + let + systems = [ + "nixos-8gb-fsn1-1" # Hetzner Server + ]; + in + builtins.listToAttrs (map + (name: { + name = name; + value = nixpkgs.lib.nixosSystem + { + system = "x86_64-linux"; + modules = [ + (./config + "/${name}.nix") + ./config/default.nix + ]; + }; + }) + systems); + }; +} +