From 81e704b638a8a7158bd9106b7fd592fb982d1864 Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 25 Aug 2022 21:46:17 +0200 Subject: add btrfs subvolumes --- default.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'default.nix') 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 -- cgit v1.2.3