summaryrefslogtreecommitdiffstats
path: root/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix14
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