summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJairo Llopis <yajo.sk8@gmail.com>2022-07-08 12:49:58 +0100
committerJairo Llopis <yajo.sk8@gmail.com>2022-07-08 12:49:58 +0100
commit9b53ee7b11b1bf28483c0c5a73f11a3e73a561cd (patch)
treeb9ac0c6f69ac0f24b808faebc8cfd9c91eed9d59
parent1af856886eca80ce39b61fd97816e4b3be07b236 (diff)
feat: noop partitions
Some deployments just need a raw block device because the app works better when handling those. Examples: Ceph, Longhorn, OpenEBS. The new `noop` type supports that. It just does nothing with the partitions created, whenever applied. @moduon MT-904
-rw-r--r--lib/default.nix6
-rw-r--r--tests/test.nix10
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/default.nix b/lib/default.nix
index ec8e4bf..7793acf 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -31,6 +31,8 @@ let {
config.lvm = q: x:
foldl' recursiveUpdate {} (mapAttrsToList (name: config-f { inherit name; vgname = x.name; }) x.lvs);
+ config.noop = q: x: {};
+
config.partition = q: x:
config-f { device = q.device + toString q.index; } x.content;
@@ -65,6 +67,8 @@ let {
${concatStrings (mapAttrsToList (name: create-f { inherit name; vgname = x.name; }) x.lvs)}
'';
+ create.noop = q: x: "";
+
create.partition = q: x: ''
parted -s ${q.device} mkpart ${x.part-type} ${x.fs-type or ""} ${x.start} ${x.end}
${optionalString (x.bootable or false) ''
@@ -119,6 +123,8 @@ let {
'';}
);
+ mount.noop = q: x: {};
+
mount.partition = q: x:
mount-f { device = q.device + toString q.index; } x.content;
diff --git a/tests/test.nix b/tests/test.nix
index 0f875e6..2ab28bf 100644
--- a/tests/test.nix
+++ b/tests/test.nix
@@ -56,13 +56,20 @@ import <nixpkgs/nixos/tests/make-test.nix> ({ pkgs, ... }: let
};
home = {
type = "lv";
- size = "100M";
+ size = "10M";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/home";
};
};
+ raw = {
+ type = "lv";
+ size = "10M";
+ content = {
+ type = "noop";
+ };
+ };
};
};
};
@@ -92,6 +99,7 @@ in {
$machine->succeed("echo 'secret' > /tmp/secret.key");
$machine->succeed("${pkgs.writeScript "create" ((import ../lib).create disko-config)}");
$machine->succeed("${pkgs.writeScript "mount" ((import ../lib).mount disko-config)}");
+ $machine->succeed("test -b /dev/mapper/pool-raw");
'';
})