diff options
author | lassulus <lassulus@lassul.us> | 2022-08-25 21:46:17 +0200 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2022-08-25 23:31:05 +0200 |
commit | 81e704b638a8a7158bd9106b7fd592fb982d1864 (patch) | |
tree | c34dd63211532f349fcc5b8b2421188975a67623 /default.nix | |
parent | dadc49133042834dada6eafc98dcb1f7f2c5e43b (diff) |
add btrfs subvolumes
Diffstat (limited to 'default.nix')
-rw-r--r-- | default.nix | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/default.nix b/default.nix index 19333fc..c6ec47c 100644 --- a/default.nix +++ b/default.nix @@ -69,6 +69,18 @@ let create-f = q: x: create.${x.type} q x; + create.btrfs = q: x: '' + mkfs.btrfs ${q.device} + ${lib.optionalString (!isNull x.subvolumes or null) '' + MNTPOINT=$(mktemp -d) + ( + mount ${q.device} "$MNTPOINT" + trap 'umount $MNTPOINT; rm -rf $MNTPOINT' EXIT + ${concatMapStringsSep "\n" (subvolume: "btrfs subvolume create \"$MNTPOINT\"/${subvolume}") x.subvolumes} + ) + ''} + ''; + create.filesystem = q: x: '' mkfs.${x.format} ${q.device} ''; @@ -178,6 +190,8 @@ let ''; }; + mount.btrfs = mount.filesystem; + mount.devices = q: x: let z = foldl' recursiveUpdate {} (mapAttrsToList (name: mount-f { device = "/dev/${name}"; inherit name; }) x.content); # attrValues returns values sorted by name. This is important, because it |