diff --git a/flake.nix b/flake.nix index b6d2153..5a3d537 100644 --- a/flake.nix +++ b/flake.nix @@ -38,8 +38,8 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - inputs.disko.url = "github:nix-community/disko"; - inputs.disko.inputs.nixpkgs.follows = "nixpkgs"; + disko.url = "github:nix-community/disko"; + disko.inputs.nixpkgs.follows = "nixpkgs"; # my stuff dhist = { @@ -116,15 +116,18 @@ ++ lib.optional (desktop == "kde") ./system/kde.nix; in { + checks."${system}" = { + disko-format-i15 = pkgs.callPackage ./hosts/i15/partitions-test.nix { }; + }; nixosConfigurations = { i15 = lib.nixosSystem { inherit system specialArgs; - modules = [ ./hosts/i15.nix ] ++ common_modules; + modules = [ ./hosts/i15 ] ++ common_modules; }; monolith = lib.nixosSystem { inherit system specialArgs; modules = [ - ./hosts/monolith.nix + ./hosts/monolith ./system/monolith-gitlab-runner.nix ./system/monolith-forgejo-runner.nix ./system/nix-serve.nix @@ -134,7 +137,7 @@ rainbow = lib.nixosSystem { inherit system specialArgs; modules = [ - ./hosts/rainbow.nix + ./hosts/rainbow ./system/rainbow-gitlab-runner.nix ] ++ common_modules; }; diff --git a/hosts/i15/default.nix b/hosts/i15/default.nix new file mode 100644 index 0000000..6518e66 --- /dev/null +++ b/hosts/i15/default.nix @@ -0,0 +1,25 @@ +{ config, lib, pkgs, modulesPath, ... }: { + networking.hostName = "i15"; # Define your hostname. + + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + + boot.initrd.availableKernelModules = + [ "xhci_pci" "ahci" "usb_storage" "sd_mod" "rtsx_usb_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + disko.devices = (import ./partitions.nix { disks = [ "/dev/sda" ]; }); + boot.loader.efi.efiSysMountPoint = "/boot/efi"; + + swapDevices = [{ + device = "/swap/swapfile"; + size = (1024 * 8) + (1024 * 2); # RAM size + 2 GB + }]; + + networking.useDHCP = lib.mkDefault true; + + powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand"; + hardware.cpu.intel.updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/i15/partitions-test.nix b/hosts/i15/partitions-test.nix new file mode 100644 index 0000000..89f06b7 --- /dev/null +++ b/hosts/i15/partitions-test.nix @@ -0,0 +1,14 @@ +{ config, lib, pkgs, ... }: +pkgs.makeDiskoTest { + name = "test-disko-i15"; + disko-config = ./partitions.nix; + enableOCR = true; + bootCommands = '' + machine.wait_for_text("[Pp]assphrase for") + machine.send_chars("secretsecret\n") + ''; + extraTestScript = '' + machine.succeed("cryptsetup isLuks /dev/vda2"); + machine.succeed("mountpoint /home"); + ''; +} diff --git a/hosts/partition/i15.nix b/hosts/i15/partitions.nix similarity index 50% rename from hosts/partition/i15.nix rename to hosts/i15/partitions.nix index f97dad3..ed7ff7e 100644 --- a/hosts/partition/i15.nix +++ b/hosts/i15/partitions.nix @@ -1,4 +1,8 @@ -{ disks ? [ "/dev/sda" ], ... }: { +{ disks ? [ "/dev/sda" ], ... }: +let + btrfs_options = [ "compress=zstd:3" "noatime" ]; +in +{ disk.sda = { type = "disk"; device = builtins.elemAt disks 0; @@ -10,28 +14,36 @@ type = "partition"; name = "NIX_BOOT"; start = "1MiB"; - end = "1GiB"; + end = "300MiB"; bootable = true; content = { type = "filesystem"; + extraArgs = [ "-n" "BOOT_I15" ]; format = "vfat"; mountpoint = "/boot"; - options = [ "defaults" ]; + # options = [ "defaults" ]; }; } { type = "partition"; - name = "NIX_CRYPT_ROOT"; - start = "1GiB"; + name = "CRYPT_I15"; + start = "300MiB"; end = "100%"; content = { type = "luks"; name = "main"; + keyFile = "/tmp/secret.key"; content = { type = "btrfs"; - name = "BTRFS_ROOT"; - mountpoint = "/"; - subvolumes = [ "/home" "/nixos" "/swap" ]; + extraArgs = [ "--label" "ROOT_I15" ]; + subvolumes = let mountOptions = btrfs_options; in { + "/home" = { inherit mountOptions; }; + "/nixos" = { + inherit mountOptions; + mountpoint = "/"; + }; + "/swap" = { inherit mountOptions; }; + }; }; }; } diff --git a/hosts/monolith.nix b/hosts/monolith/default.nix similarity index 100% rename from hosts/monolith.nix rename to hosts/monolith/default.nix diff --git a/hosts/pixie.nix b/hosts/pixie/default.nix similarity index 100% rename from hosts/pixie.nix rename to hosts/pixie/default.nix diff --git a/hosts/rainbow.nix b/hosts/rainbow/default.nix similarity index 100% rename from hosts/rainbow.nix rename to hosts/rainbow/default.nix diff --git a/overlays/default.nix b/overlays/default.nix index e83ed4c..d9f41ae 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -6,6 +6,7 @@ rec { new-packages patches lib_extended + disko ]; scripts = (import ../scripts); @@ -69,4 +70,13 @@ rec { }; } ); + + disko = final: prev: { + makeDiskoTest = + let + makeTest = import (prev.path + "/nixos/tests/make-test-python.nix"); + eval-config = import (prev.path + "/nixos/lib/eval-config.nix"); + in + (prev.callPackage "${inputs.disko}/tests/lib.nix" { inherit makeTest eval-config; }).makeDiskoTest; + }; }