forked from mirrors_public/oddlama_nix-config
feat: convert nom to disko
This commit is contained in:
parent
02a8544825
commit
9a810bd125
4 changed files with 69 additions and 42 deletions
|
@ -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";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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;};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
15
nix/lib.nix
15
nix/lib.nix
|
@ -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";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue