1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-11 07:10:39 +02:00

feat: convert nom to disko

This commit is contained in:
oddlama 2023-06-25 22:58:11 +02:00
parent 02a8544825
commit 9a810bd125
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
4 changed files with 69 additions and 42 deletions

View file

@ -1,18 +1,55 @@
{
fileSystems = {
"/" = {
device = "rpool/root/nixos";
fsType = "zfs";
options = ["zfsutil" "X-mount.mkdir"];
config,
lib,
extraLib,
pkgs,
...
}: {
disko.devices = {
disk = {
m2-ssd = {
type = "disk";
device = "/dev/disk/by-id/${config.repo.secrets.local.disk.m2-ssd}";
content = with extraLib.disko.gpt; {
type = "table";
format = "gpt";
partitions = [
(partLuksZfs "rpool" "0%" "100%")
];
};
};
boot-ssd = {
type = "disk";
device = "/dev/disk/by-id/${config.repo.secrets.local.disk.boot-ssd}";
content = with extraLib.disko.gpt; {
type = "table";
format = "gpt";
partitions = [
(partEfi "efi" "0%" "8GiB")
(partSwap "swap" "8GiB" "100%")
];
};
};
};
"/boot" = {
device = "/dev/disk/by-uuid/91ED-0E13";
fsType = "vfat";
zpool = with extraLib.disko.zfs; {
rpool = defaultZpoolOptions // {datasets = defaultZfsDatasets;};
};
};
swapDevices = [
{device = "/dev/disk/by-uuid/1122527a-71d3-4ec7-8d41-65d0c8494b04";}
];
# TODO remove once this is upstreamed
boot.initrd.systemd.services."zfs-import-rpool".after = ["cryptsetup.target"];
fileSystems."/state".neededForBoot = true;
fileSystems."/persist".neededForBoot = true;
# After importing the rpool, rollback the root system to be empty.
boot.initrd.systemd.services.impermanence-root = {
wantedBy = ["initrd.target"];
after = ["zfs-import-rpool.service"];
before = ["sysroot.mount"];
unitConfig.DefaultDependencies = "no";
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.zfs}/bin/zfs rollback -r rpool/local/root@blank";
};
};
}

View file

@ -21,22 +21,7 @@
};
};
zpool = with extraLib.disko.zfs; {
rpool =
defaultZpoolOptions
// {
datasets = {
"local" = unmountable;
"local/root" =
filesystem "/"
// {
postCreateHook = "zfs snapshot rpool/local/root@blank";
};
"local/nix" = filesystem "/nix";
"local/state" = filesystem "/state";
"safe" = unmountable;
"safe/persist" = filesystem "/persist";
};
};
rpool = defaultZpoolOptions // {datasets = defaultZfsDatasets;};
};
};

View file

@ -25,19 +25,11 @@
rpool =
defaultZpoolOptions
// {
datasets = {
"local" = unmountable;
"local/root" =
filesystem "/"
// {
postCreateHook = "zfs snapshot rpool/local/root@blank";
};
"local/nix" = filesystem "/nix";
"local/state" = filesystem "/state";
"safe" = unmountable;
"safe/persist" = filesystem "/persist";
"safe/vms" = unmountable;
};
datasets =
defaultZfsDatasets
// {
"safe/vms" = unmountable;
};
};
};
};

View file

@ -166,7 +166,7 @@ in rec {
};
};
};
zfs = {
zfs = rec {
defaultZpoolOptions = {
type = "zpool";
mountRoot = "/mnt";
@ -183,6 +183,19 @@ in rec {
options.ashift = "12";
};
defaultZfsDatasets = {
"local" = unmountable;
"local/root" =
filesystem "/"
// {
postCreateHook = "zfs snapshot rpool/local/root@blank";
};
"local/nix" = filesystem "/nix";
"local/state" = filesystem "/state";
"safe" = unmountable;
"safe/persist" = filesystem "/persist";
};
unmountable = {type = "zfs_fs";};
filesystem = mountpoint: {
type = "zfs_fs";