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 = {
|
config,
|
||||||
"/" = {
|
lib,
|
||||||
device = "rpool/root/nixos";
|
extraLib,
|
||||||
fsType = "zfs";
|
pkgs,
|
||||||
options = ["zfsutil" "X-mount.mkdir"];
|
...
|
||||||
|
}: {
|
||||||
|
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%")
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
zpool = with extraLib.disko.zfs; {
|
||||||
"/boot" = {
|
rpool = defaultZpoolOptions // {datasets = defaultZfsDatasets;};
|
||||||
device = "/dev/disk/by-uuid/91ED-0E13";
|
|
||||||
fsType = "vfat";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
swapDevices = [
|
# TODO remove once this is upstreamed
|
||||||
{device = "/dev/disk/by-uuid/1122527a-71d3-4ec7-8d41-65d0c8494b04";}
|
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; {
|
zpool = with extraLib.disko.zfs; {
|
||||||
rpool =
|
rpool = defaultZpoolOptions // {datasets = defaultZfsDatasets;};
|
||||||
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";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,19 +25,11 @@
|
||||||
rpool =
|
rpool =
|
||||||
defaultZpoolOptions
|
defaultZpoolOptions
|
||||||
// {
|
// {
|
||||||
datasets = {
|
datasets =
|
||||||
"local" = unmountable;
|
defaultZfsDatasets
|
||||||
"local/root" =
|
// {
|
||||||
filesystem "/"
|
"safe/vms" = unmountable;
|
||||||
// {
|
};
|
||||||
postCreateHook = "zfs snapshot rpool/local/root@blank";
|
|
||||||
};
|
|
||||||
"local/nix" = filesystem "/nix";
|
|
||||||
"local/state" = filesystem "/state";
|
|
||||||
"safe" = unmountable;
|
|
||||||
"safe/persist" = filesystem "/persist";
|
|
||||||
"safe/vms" = unmountable;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
15
nix/lib.nix
15
nix/lib.nix
|
@ -166,7 +166,7 @@ in rec {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
zfs = {
|
zfs = rec {
|
||||||
defaultZpoolOptions = {
|
defaultZpoolOptions = {
|
||||||
type = "zpool";
|
type = "zpool";
|
||||||
mountRoot = "/mnt";
|
mountRoot = "/mnt";
|
||||||
|
@ -183,6 +183,19 @@ in rec {
|
||||||
options.ashift = "12";
|
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";};
|
unmountable = {type = "zfs_fs";};
|
||||||
filesystem = mountpoint: {
|
filesystem = mountpoint: {
|
||||||
type = "zfs_fs";
|
type = "zfs_fs";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue