nix-builder disko

This commit is contained in:
2026-09-02 21:36:23 +09:00
parent c53a0c0bed
commit 0ff78c6848
5 changed files with 82 additions and 47 deletions
+15 -7
View File
@@ -653,7 +653,8 @@ A host registry may use a specification like this:
The current role assignment is intentional: nix-example is the development VM;
ops is the remote-access VM with host-specific static networking;
internal-app-01 is the container server VM; and installer builds the minimal
internal-app-01 is the container server VM; nix-builder is the remote Nix build
VM with dedicated build and store disks; and installer builds the minimal
installation ISO without Home Manager. x1g9 is a full NixOS desktop with niri,
labwc, ly, the shared Linux desktop applications, and the personal workload.
x1g13 is the secure NixOS development and personal ThinkPad, with the same
@@ -692,6 +693,10 @@ configuration fragments. For example:
```text
hosts/
├── nix-builder/
│ ├── disko.nix
│ ├── hardware-configuration.nix
│ └── nixos.nix
├── installer/
│ └── nixos.nix
├── internal-app-01/
@@ -721,12 +726,15 @@ hosts/
```
`hosts/x1g9/nixos.nix` explicitly loads `hardware-configuration.nix` with the
normal top-level Nix module `imports`. `hosts/x1g13/nixos.nix` loads its
generated hardware configuration and host-local `disko.nix` the same way. Do
not confuse these host imports with the prohibition on top-level `imports` in
unit configuration fragments. `hosts/galleria/disko.nix` manages only the two
dedicated NixOS partitions by PARTUUID and deliberately excludes the Windows
disk, Windows partitions, and the Windows EFI System Partition.
normal top-level Nix module `imports`. `hosts/nix-builder/nixos.nix` and
`hosts/x1g13/nixos.nix` load their generated hardware configuration and
host-local `disko.nix` the same way. The nix-builder Disko definition mounts its
existing VM filesystems by stable QEMU SCSI IDs and does not take destructive
ownership of them. Do not confuse these host imports with the prohibition on
top-level `imports` in unit configuration fragments. `hosts/galleria/disko.nix`
manages only the two dedicated NixOS partitions by PARTUUID and deliberately
excludes the Windows disk, Windows partitions, and the Windows EFI System
Partition.
Derive the system class from the host's `system`:
+66
View File
@@ -0,0 +1,66 @@
_:
let
osDisk = "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0";
in
{
disko.enableConfig = true;
# The VM disks already contain live filesystems. Model each existing
# filesystem without giving Disko ownership of their partitioning or data.
disko.devices.disk = {
boot = {
type = "disk";
device = "${osDisk}-part1";
destroy = false;
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
root = {
type = "disk";
device = "${osDisk}-part2";
destroy = false;
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
nix-build = {
type = "disk";
device = "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi1";
destroy = false;
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/var/lib/nix-build";
mountOptions = [ "noatime" ];
};
};
nix-store = {
type = "disk";
device = "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2";
destroy = false;
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/nix/store";
mountOptions = [ "noatime" ];
};
};
};
fileSystems."/nix/store".neededForBoot = true;
nix.settings.build-dir = "/var/lib/nix-build";
services.fstrim.enable = true;
}
-25
View File
@@ -1,25 +0,0 @@
{
fileSystems."/nix/store" = {
device = "/dev/disk/by-label/nix-store";
fsType = "ext4";
options = [
"noatime"
];
neededForBoot = true;
};
fileSystems."/var/lib/nix-build" = {
device = "/dev/disk/by-label/nix-build";
fsType = "ext4";
options = [
"noatime"
];
};
nix.settings.build-dir = "/var/lib/nix-build";
services.fstrim.enable = true;
}
@@ -20,20 +20,6 @@
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" = {
device = "/dev/disk/by-uuid/49fc2e1c-7909-41cc-ac78-55b4d9a01e62";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/40D4-ABBE";
fsType = "vfat";
options = [
"fmask=0077"
"dmask=0077"
];
};
swapDevices = [ ];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
+1 -1
View File
@@ -1,6 +1,6 @@
{
imports = [
./filesystem.nix
./disko.nix
./hardware-configuration.nix
];
}