fix disko

This commit is contained in:
2024-10-18 20:25:54 -05:00
parent 782086e95a
commit 854fd1641f
6 changed files with 128 additions and 154 deletions

60
flake.lock generated
View File

@@ -189,16 +189,15 @@
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"system", "system",
"diskoConfig",
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1729099656, "lastModified": 1729281548,
"narHash": "sha256-VftVIg7UXTy1bq+tzi1aVYOWl7PQ35IpjW88yMYjjpc=", "narHash": "sha256-MuojlSnwAJAwfhgmW8ZtZrwm2Sko4fqubCvReqbUzYw=",
"owner": "nix-community", "owner": "nix-community",
"repo": "disko", "repo": "disko",
"rev": "d7d57edb72e54891fa67a6f058a46b2bb405663b", "rev": "a6a3179ddf396dfc28a078e2f169354d0c137125",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -207,22 +206,6 @@
"type": "github" "type": "github"
} }
}, },
"diskoConfig": {
"inputs": {
"disko": "disko",
"nixpkgs": "nixpkgs_10"
},
"locked": {
"lastModified": 1,
"narHash": "sha256-SakyZnAhoToQmui5hozmLqkoLw6N/AHCgKF4tCP/sTQ=",
"path": "/mnt/nix/store/6632xfzj8dykclkxzhjbigh06hkvia70-source/disko",
"type": "path"
},
"original": {
"path": "/mnt/nix/store/6632xfzj8dykclkxzhjbigh06hkvia70-source/disko",
"type": "path"
}
},
"external": { "external": {
"inputs": { "inputs": {
"digital": "digital", "digital": "digital",
@@ -1044,11 +1027,11 @@
"locked": { "locked": {
"lastModified": 0, "lastModified": 0,
"narHash": "sha256-Hz1a2OgtlwgdQhI6hiUvityjVURsoY6oXkXq25RyiBM=", "narHash": "sha256-Hz1a2OgtlwgdQhI6hiUvityjVURsoY6oXkXq25RyiBM=",
"path": "/mnt/nix/store/v3m4p7s1ncm6x2qdbfn8h7816rfidrww-source/home", "path": "/mnt/nix/store/fd7h31g5h6jvpd4hw51q3qa47maycj3b-source/home",
"type": "path" "type": "path"
}, },
"original": { "original": {
"path": "/mnt/nix/store/v3m4p7s1ncm6x2qdbfn8h7816rfidrww-source/home", "path": "/mnt/nix/store/fd7h31g5h6jvpd4hw51q3qa47maycj3b-source/home",
"type": "path" "type": "path"
} }
}, },
@@ -1294,11 +1277,11 @@
}, },
"nixpkgs_7": { "nixpkgs_7": {
"locked": { "locked": {
"lastModified": 1729044727, "lastModified": 1729181673,
"narHash": "sha256-GKJjtPY+SXfLF/yTN7M2cAnQB6RERFKnQhD8UvPSf3M=", "narHash": "sha256-LDiPhQ3l+fBjRATNtnuDZsBS7hqoBtPkKBkhpoBHv3I=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "dc2e0028d274394f73653c7c90cc63edbb696be1", "rev": "4eb33fe664af7b41a4c446f87d20c9a0a6321fa3",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -1310,11 +1293,11 @@
}, },
"nixpkgs_8": { "nixpkgs_8": {
"locked": { "locked": {
"lastModified": 1729044727, "lastModified": 1729181673,
"narHash": "sha256-GKJjtPY+SXfLF/yTN7M2cAnQB6RERFKnQhD8UvPSf3M=", "narHash": "sha256-LDiPhQ3l+fBjRATNtnuDZsBS7hqoBtPkKBkhpoBHv3I=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "dc2e0028d274394f73653c7c90cc63edbb696be1", "rev": "4eb33fe664af7b41a4c446f87d20c9a0a6321fa3",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -1434,11 +1417,11 @@
"locked": { "locked": {
"lastModified": 1, "lastModified": 1,
"narHash": "sha256-6oCDKhDSqJMWeODXDHD5XorN7/+KXBBIPZ2z+obwUNY=", "narHash": "sha256-6oCDKhDSqJMWeODXDHD5XorN7/+KXBBIPZ2z+obwUNY=",
"path": "/mnt/nix/store/6632xfzj8dykclkxzhjbigh06hkvia70-source/packages", "path": "/mnt/nix/store/2r9s3wx2jba75hvnflgiqnpmxfw3hsy5-source/packages",
"type": "path" "type": "path"
}, },
"original": { "original": {
"path": "/mnt/nix/store/6632xfzj8dykclkxzhjbigh06hkvia70-source/packages", "path": "/mnt/nix/store/2r9s3wx2jba75hvnflgiqnpmxfw3hsy5-source/packages",
"type": "path" "type": "path"
} }
}, },
@@ -1524,11 +1507,11 @@
"locked": { "locked": {
"lastModified": 1, "lastModified": 1,
"narHash": "sha256-hg0wqQn6BxQXLmfBINzZoaWpdSIlwwZxKbYz+4df83o=", "narHash": "sha256-hg0wqQn6BxQXLmfBINzZoaWpdSIlwwZxKbYz+4df83o=",
"path": "/mnt/nix/store/6632xfzj8dykclkxzhjbigh06hkvia70-source/programs", "path": "/mnt/nix/store/2r9s3wx2jba75hvnflgiqnpmxfw3hsy5-source/programs",
"type": "path" "type": "path"
}, },
"original": { "original": {
"path": "/mnt/nix/store/6632xfzj8dykclkxzhjbigh06hkvia70-source/programs", "path": "/mnt/nix/store/2r9s3wx2jba75hvnflgiqnpmxfw3hsy5-source/programs",
"type": "path" "type": "path"
} }
}, },
@@ -1655,30 +1638,31 @@
"locked": { "locked": {
"lastModified": 1, "lastModified": 1,
"narHash": "sha256-VZKans7CW3BgyWaVgi9mGKvJsCvyse2zLPRB5fJnlfA=", "narHash": "sha256-VZKans7CW3BgyWaVgi9mGKvJsCvyse2zLPRB5fJnlfA=",
"path": "/mnt/nix/store/6632xfzj8dykclkxzhjbigh06hkvia70-source/services", "path": "/mnt/nix/store/2r9s3wx2jba75hvnflgiqnpmxfw3hsy5-source/services",
"type": "path" "type": "path"
}, },
"original": { "original": {
"path": "/mnt/nix/store/6632xfzj8dykclkxzhjbigh06hkvia70-source/services", "path": "/mnt/nix/store/2r9s3wx2jba75hvnflgiqnpmxfw3hsy5-source/services",
"type": "path" "type": "path"
} }
}, },
"system": { "system": {
"inputs": { "inputs": {
"diskoConfig": "diskoConfig", "disko": "disko",
"impermanence": "impermanence", "impermanence": "impermanence",
"nixpkgs": "nixpkgs_10",
"pckgs": "pckgs", "pckgs": "pckgs",
"prgms": "prgms_2", "prgms": "prgms_2",
"srvcs": "srvcs" "srvcs": "srvcs"
}, },
"locked": { "locked": {
"lastModified": 1, "lastModified": 1,
"narHash": "sha256-4o+6OFouADJTS6Q5yawUGFLMoOUX8Mf/zIIlTARisj4=", "narHash": "sha256-Pk5COJNed5x87n/zc1ljP6CL8YvSOrKFPKcveKtjD/c=",
"path": "/mnt/nix/store/v3m4p7s1ncm6x2qdbfn8h7816rfidrww-source/system", "path": "/mnt/nix/store/fd7h31g5h6jvpd4hw51q3qa47maycj3b-source/system",
"type": "path" "type": "path"
}, },
"original": { "original": {
"path": "/mnt/nix/store/v3m4p7s1ncm6x2qdbfn8h7816rfidrww-source/system", "path": "/mnt/nix/store/fd7h31g5h6jvpd4hw51q3qa47maycj3b-source/system",
"type": "path" "type": "path"
} }
}, },

View File

@@ -47,7 +47,7 @@
sysconfig = { sysconfig = {
${host}.enable = true; ${host}.enable = true;
opts = { opts = {
firstBoot = false; firstBoot = true;
inherit host username devices; inherit host username devices;
}; };
}; };

View File

@@ -13,25 +13,13 @@
}; };
}; };
config = lib.mkIf config.disko.enable (lib.mkMerge [
{
imports = [
./disko.nix { device = config.sysconfig.opts.devices.main; }
];
}
(lib.mkIf (config.sysconfig.opts.devices.bonus != null) {
imports = [
(./disko_bonus.nix { devices = config.sysconfig.opts.devices.bonus; })
];
})
(lib.mkIf config.disko.impermanent {
imports = [ imports = [
./disko.nix
./disko_bonus.nix
./impermanent.nix ./impermanent.nix
]; ];
})
config = lib.mkIf config.disko.enable (lib.mkMerge [
(lib.mkIf (!config.disko.enable) { (lib.mkIf (!config.disko.enable) {
disko.impermanent = lib.mkForce false; disko.impermanent = lib.mkForce false;

View File

@@ -1,8 +1,8 @@
{ device ? throw "Set this to your device e.g. /dev/sda", ... }: { { config, lib, ... }: {
config = lib.mkIf config.disko.enable {
disko.devices = { disko.devices = {
disk.main = { disk.main = {
inherit device; device = config.sysconfig.opts.devices.main;
type = "disk"; type = "disk";
content = { content = {
type = "gpt"; type = "gpt";
@@ -69,4 +69,5 @@
}; };
}; };
}; };
};
} }

View File

@@ -1,7 +1,8 @@
{ devices ? throw "Set this to an attribute set of your devices e.g. { disk1 = \"/dev/sda\"; }", ... }: { { config, lib, ... }: {
disko.devices = builtins.mapAttrs (name: device: { config = lib.mkIf (config.disko.enable && config.sysconfig.opts.devices.bonus != null) {
disk.${name} = { disko.devices = {
disk = builtins.mapAttrs (name: device: {
inherit device; inherit device;
type = "disk"; type = "disk";
content = { content = {
@@ -17,10 +18,9 @@
}; };
}; };
}; };
}; }) config.sysconfig.opts.devices.bonus;
lvm_vg = { lvm_vg = builtins.mapAttrs (name: device: {
"${name}_vg" = {
type = "lvm_vg"; type = "lvm_vg";
lvs = { lvs = {
${name} = { ${name} = {
@@ -37,7 +37,7 @@
}; };
}; };
}; };
}) config.sysconfig.opts.devices.bonus;
}; };
}; };
}) devices;
} }

View File

@@ -1,5 +1,6 @@
{ lib, ... }: { { config, lib, ... }: {
config = lib.mkIf config.disko.impermanent {
boot.initrd.postDeviceCommands = lib.mkAfter '' boot.initrd.postDeviceCommands = lib.mkAfter ''
mkdir /btrfs_tmp mkdir /btrfs_tmp
mount /dev/root_vg/root /btrfs_tmp mount /dev/root_vg/root /btrfs_tmp
@@ -25,5 +26,5 @@
umount /btrfs_tmp umount /btrfs_tmp
''; '';
config.initialPasswords = lib.mkForce true; };
} }