nix-helpers: b830ce53eae56cc86e3d2caa963e67913df9bcf9
1: {
2: die ? import ../die { },
3: nixpkgs-lib ? import ../nixpkgs-lib { },
4: }:
5:
6: with rec {
7: inherit (builtins)
8: attrNames
9: filter
10: listToAttrs
11: map
12: readDir
13: ;
14:
15: inherit (nixpkgs-lib) hasSuffix removeSuffix;
16:
17: go =
18: suffix: dir:
19: with {
20: content = filter (hasSuffix suffix) (attrNames (readDir dir));
21:
22: entry = f: {
23: name = removeSuffix suffix f;
24: value = dir + "/${f}";
25: };
26: };
27: listToAttrs (map entry content);
28:
29: testData = go ".nix" ./.;
30: thisFile = ./default.nix;
31: };
32: assert
33: testData ? default
34: || die {
35: inherit testData;
36: error = "Expected default to appear in testData";
37: };
38: assert
39: testData.default == thisFile
40: || die {
41: inherit testData thisFile;
42: error = "Expected 'testData.default' to match 'thisFile'";
43: };
44: assert
45: dirOf testData.default == ./.
46: || die {
47: inherit testData;
48: thisDir = ./.;
49: error = "Expected 'testData.default' to be a file under 'thisDir'";
50: };
51: go
Generated by git2html.