summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2018-07-25 01:25:04 +0200
committerlassulus <lassulus@lassul.us>2018-07-31 21:39:51 +0200
commit0e8c5d1e6757ea049e5e58c2d56701748d99fe6a (patch)
treefbc9dc89a831c8e84f9bb3a470e8a62776db092a /lib
parentd2f8f4a6cf7881fbf330e226fe54b4d774154af7 (diff)
layout -> devices, expose body
Diffstat (limited to 'lib')
-rw-r--r--lib/default.nix41
1 files changed, 18 insertions, 23 deletions
diff --git a/lib/default.nix b/lib/default.nix
index cbb6a9d..7bfa59a 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -1,9 +1,11 @@
with import <nixpkgs/lib>;
with builtins;
-let
+let {
+
+ body.config = q: x: config.${x.type} q x;
+ body.create = q: x: create.${x.type} q x;
- config-f = q: x: config.${x.type} q x;
config.filesystem = q: x: {
fileSystems.${x.mountpoint} = {
@@ -12,51 +14,49 @@ let
};
};
- config.layout = q: x:
- foldl' mergeAttrs {} (mapAttrsToList (name: config-f { device = name; }) x.content);
+ config.devices = q: x:
+ foldl' mergeAttrs {} (mapAttrsToList (name: body.config { device = "/dev/${name}"; }) x.content);
config.luks = q: x: {
boot.initrd.luks.devices.${x.name}.device = q.device;
- } // config-f { device = "/dev/mapper/${x.name}"; } x.content;
+ } // body.config { device = "/dev/mapper/${x.name}"; } x.content;
config.lv = q: x:
- config-f { device = "/dev/${q.vgname}/${q.name}"; } x.content;
+ body.config { device = "/dev/${q.vgname}/${q.name}"; } x.content;
config.lvm = q: x:
- foldl' mergeAttrs {} (mapAttrsToList (name: config-f { inherit name; vgname = x.name; }) x.lvs);
+ foldl' mergeAttrs {} (mapAttrsToList (name: body.config { inherit name; vgname = x.name; }) x.lvs);
config.partition = q: x:
- config-f { device = q.device + toString q.index; } x.content;
+ body.config { device = q.device + toString q.index; } x.content;
config.table = q: x:
- foldl' mergeAttrs {} (imap (index: config-f (q // { inherit index; })) x.partitions);
-
+ foldl' mergeAttrs {} (imap (index: body.config (q // { inherit index; })) x.partitions);
- create-f = q: x: create.${x.type} q x;
create.filesystem = q: x: ''
mkfs.${x.format} ${q.device}
'';
- create.layout = q: x: ''
- ${concatStrings (mapAttrsToList (name: create-f { device = name; }) x.content)}
+ create.devices = q: x: ''
+ ${concatStrings (mapAttrsToList (name: body.create { device = "/dev/${name}"; }) x.content)}
'';
create.luks = q: x: ''
cryptsetup -q luksFormat ${q.device} ${x.keyfile}
cryptsetup luksOpen ${q.device} ${x.name} --key-file ${x.keyfile}
- ${create-f { device = "/dev/mapper/${x.name}"; } x.content}
+ ${body.create { device = "/dev/mapper/${x.name}"; } x.content}
'';
create.lv = q: x: ''
lvcreate -L ${x.size} -n ${q.name} ${q.vgname}
- ${create-f { device = "/dev/${q.vgname}/${q.name}"; } x.content}
+ ${body.create { device = "/dev/${q.vgname}/${q.name}"; } x.content}
'';
create.lvm = q: x: ''
pvcreate ${q.device}
vgcreate ${x.name} ${q.device}
- ${concatStrings (mapAttrsToList (name: create-f { inherit name; vgname = x.name; }) x.lvs)}
+ ${concatStrings (mapAttrsToList (name: body.create { inherit name; vgname = x.name; }) x.lvs)}
'';
create.partition = q: x: ''
@@ -64,16 +64,11 @@ let
${optionalString (x.bootable or false) ''
parted -s ${q.device} set ${toString q.index} boot on
''}
- ${create-f { device = q.device + toString q.index; } x.content}
+ ${body.create { device = q.device + toString q.index; } x.content}
'';
create.table = q: x: ''
parted -s ${q.device} mklabel ${x.format}
- ${concatStrings (imap (index: create-f (q // { inherit index; })) x.partitions)}
+ ${concatStrings (imap (index: body.create (q // { inherit index; })) x.partitions)}
'';
-in
- {
- config = device: config-f { inherit device; };
- create = device: create-f { inherit device; };
- }