Skip to content

Commit d953e39

Browse files
committed
fix: simplify test files for flake compatibility
1 parent 0c1f2f3 commit d953e39

18 files changed

+474
-249
lines changed

example/bcachefs-tpm2-edge-cases.nix

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
label = "edge-empty.vdb2";
2727
};
2828
};
29-
29+
3030
vdb3 = {
3131
size = "25%";
3232
content = {
@@ -35,7 +35,7 @@
3535
label = "edge-corrupted.vdb3";
3636
};
3737
};
38-
38+
3939
vdb4 = {
4040
size = "25%";
4141
content = {
@@ -44,7 +44,7 @@
4444
label = "edge-missing.vdb4";
4545
};
4646
};
47-
47+
4848
vdb5 = {
4949
size = "25%";
5050
content = {
@@ -56,7 +56,7 @@
5656
};
5757
};
5858
};
59-
59+
6060
vdc = {
6161
device = "/dev/vdc";
6262
type = "disk";
@@ -74,7 +74,7 @@
7474
};
7575
};
7676
};
77-
77+
7878
vdd = {
7979
device = "/dev/vdd";
8080
type = "disk";
@@ -101,10 +101,10 @@
101101
passwordFile = "/tmp/secret.key";
102102
unlock = {
103103
enable = true;
104-
secretFiles = [];
104+
secretFiles = [ ];
105105
};
106106
};
107-
107+
108108
# Test 2: Corrupted JWE file
109109
corrupted_test = {
110110
type = "bcachefs_filesystem";
@@ -114,7 +114,7 @@
114114
secretFiles = [ ./secrets/corrupted.jwe ];
115115
};
116116
};
117-
117+
118118
# Test 3: Missing secret files directory (unlock disabled)
119119
missing_test = {
120120
type = "bcachefs_filesystem";
@@ -123,7 +123,7 @@
123123
enable = false;
124124
};
125125
};
126-
126+
127127
# Test 4: Multiple valid keys
128128
multi_test = {
129129
type = "bcachefs_filesystem";
@@ -138,7 +138,7 @@
138138
extraPackages = [ ];
139139
};
140140
};
141-
141+
142142
# Test 5: Malformed JWE files
143143
malformed_test = {
144144
type = "bcachefs_filesystem";
@@ -148,7 +148,7 @@
148148
secretFiles = [ ./secrets/invalid.jwe ];
149149
};
150150
};
151-
151+
152152
# Test 6: Single device configuration
153153
single_device_test = {
154154
type = "bcachefs_filesystem";
@@ -160,4 +160,4 @@
160160
};
161161
};
162162
};
163-
}
163+
}

example/bcachefs-tpm2-fallback.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"--compression=lz4"
6464
"--background_compression=lz4"
6565
];
66-
66+
6767
# TPM2 unlocking configuration (will fail due to missing TPM2 device)
6868
unlock = {
6969
enable = true;
@@ -73,7 +73,7 @@
7373
];
7474
extraPackages = [ ];
7575
};
76-
76+
7777
subvolumes = {
7878
"subvolumes/root" = {
7979
mountpoint = "/";
@@ -89,4 +89,4 @@
8989
};
9090
};
9191
};
92-
}
92+
}

example/bcachefs-tpm2-performance.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"--compression=lz4"
4444
"--background_compression=lz4"
4545
];
46-
46+
4747
# Performance test configuration with multiple keys
4848
unlock = {
4949
enable = true;
@@ -54,7 +54,7 @@
5454
];
5555
extraPackages = [ ];
5656
};
57-
57+
5858
subvolumes = {
5959
"subvolumes/root" = {
6060
mountpoint = "/";
@@ -70,4 +70,4 @@
7070
};
7171
};
7272
};
73-
}
73+
}

example/bcachefs-tpm2.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"--compression=lz4"
6464
"--background_compression=lz4"
6565
];
66-
66+
6767
# TPM2 unlocking configuration
6868
unlock = {
6969
enable = true;
@@ -73,7 +73,7 @@
7373
];
7474
extraPackages = [ ];
7575
};
76-
76+
7777
subvolumes = {
7878
"subvolumes/root" = {
7979
mountpoint = "/";
@@ -89,4 +89,4 @@
8989
};
9090
};
9191
};
92-
}
92+
}

flake.nix

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@
6161
system:
6262
let
6363
pkgs = nixpkgs.legacyPackages.${system};
64+
65+
# Import diskoLib for this system
66+
diskoLibForSystem = import ./lib {
67+
lib = pkgs.lib;
68+
makeTest = import (nixpkgs + "/nixos/tests/make-test-python.nix");
69+
eval-config = import (nixpkgs + "/nixos/lib/eval-config.nix");
70+
qemu-common = import (nixpkgs + "/nixos/lib/qemu-common.nix");
71+
};
72+
6473
# FIXME: aarch64-linux seems to hang on boot
6574
nixosTests = lib.optionalAttrs pkgs.stdenv.hostPlatform.isx86_64 (
6675
import ./tests {
@@ -84,7 +93,7 @@
8493

8594
jsonTypes = pkgs.writeTextFile {
8695
name = "jsonTypes";
87-
text = (builtins.toJSON diskoLib.jsonTypes);
96+
text = (builtins.toJSON diskoLibForSystem.jsonTypes);
8897
};
8998

9099
treefmt = pkgs.runCommand "treefmt" { } ''

lib/default.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,8 @@ let
11171117
description = option.description or null;
11181118
default = option.defaultText or option.default or null;
11191119
};
1120+
literalExpression = str: str;
1121+
literalMD = str: str;
11201122
types = {
11211123
attrsOf = subType: {
11221124
type = "attrsOf";
@@ -1146,6 +1148,8 @@ let
11461148
inherit choices;
11471149
};
11481150
anything = "anything";
1151+
package = "package";
1152+
path = "path";
11491153
nonEmptyStr = "str";
11501154
strMatching = _: "str";
11511155
str = "str";

lib/types/bcachefs.nix

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,31 @@
8989
default = { };
9090
description = "NixOS configuration.";
9191
};
92+
unlock = lib.mkOption {
93+
type = lib.types.submodule (
94+
{ ... }:
95+
{
96+
options = {
97+
enable = lib.mkOption {
98+
type = lib.types.bool;
99+
default = false;
100+
description = "Enable Clevis-based unlocking for encrypted bcachefs filesystems.";
101+
};
102+
secretFiles = lib.mkOption {
103+
type = lib.types.listOf diskoLib.optionTypes.absolute-pathname;
104+
default = [ ];
105+
description = "List of JWE token files for automatic unlock (TPM2, FIDO2, Tang).";
106+
example = [
107+
"/path/to/secrets/tpm.jwe"
108+
"/path/to/secrets/yubi.jwe"
109+
];
110+
};
111+
};
112+
}
113+
);
114+
default = { };
115+
description = "Clevis-based unlocking configuration for encrypted bcachefs.";
116+
};
92117
_pkgs = lib.mkOption {
93118
internal = true;
94119
readOnly = true;

0 commit comments

Comments
 (0)