Skip to content

Commit 7b75458

Browse files
committed
Add .#allSettingsSchemas output
1 parent ae23c82 commit 7b75458

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

flake.nix

+1-9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
# Tests use flake to do packageSearch builds
2727
inherit (codedown) codedownSearcher;
28+
allSettingsSchemas = pkgsStable.callPackage ./nix/all-settings-schemas.nix { inherit (sampleOutputs) sample_environments; };
2829

2930
# For .envrc
3031
nixpkgsPath = pkgsStable.writeShellScriptBin "nixpkgsPath.sh" "echo -n ${pkgsStable.path}";
@@ -39,15 +40,6 @@
3940
}
4041
// sampleOutputs.inner
4142
;
42-
43-
checks = {
44-
customScript = pkgsStable.writeShellScript "test-script" ''
45-
#!/bin/sh
46-
echo "Running custom test..."
47-
# Add your test logic here
48-
exit 0
49-
'';
50-
};
5143
}
5244
);
5345
}

nix/all-settings-schemas.nix

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{ lib
2+
, writeShellScript
3+
, writeTextFile
4+
5+
, sample_environments
6+
}:
7+
8+
let
9+
all_settings_schemas = let
10+
gatherSchemas = prefix: pkg:
11+
(if !(lib.hasAttrByPath ["meta" "settings_schema"] pkg) then []
12+
else [{ name = prefix + pkg.name; value = pkg.meta.settings_schema; }])
13+
++ builtins.concatLists (map (gatherSchemas (prefix + pkg.name + ".")) (pkg.packages or []))
14+
;
15+
16+
gatherSchemasFromEnvironment = prefix: env:
17+
builtins.concatLists (lib.mapAttrsToList (n: v: gatherSchemas prefix v) env.ui_metadata.packages);
18+
19+
in
20+
lib.listToAttrs (
21+
builtins.concatLists (lib.mapAttrsToList (n: v: gatherSchemasFromEnvironment (n + ".") v) sample_environments)
22+
);
23+
24+
in
25+
26+
writeTextFile {
27+
name = "all_settings_schemas.json";
28+
text = builtins.toJSON all_settings_schemas;
29+
}

nix/sample-outputs.nix

-22
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,6 @@ in
3232
sample_environments
3333
);
3434

35-
# TODO: add test that all settings schemas are valid in certain ways:
36-
# - they all have a title
37-
all_settings_schemas = let
38-
gatherSchemas = prefix: pkg:
39-
(if !(lib.hasAttrByPath ["meta" "settings_schema"] pkg) then []
40-
else [{ name = prefix + pkg.name; value = pkg.meta.settings_schema; }])
41-
++ builtins.concatLists (map (gatherSchemas (prefix + pkg.name + ".")) (pkg.packages or []))
42-
;
43-
44-
gatherSchemasFromEnvironment = prefix: env:
45-
builtins.concatLists (lib.mapAttrsToList (n: v: gatherSchemas prefix v) env.ui_metadata.packages);
46-
47-
in
48-
writeTextFile {
49-
name = "all_settings_schemas.json";
50-
text = builtins.toJSON (
51-
lib.listToAttrs (
52-
builtins.concatLists (lib.mapAttrsToList (n: v: gatherSchemasFromEnvironment (n + ".") v) sample_environments)
53-
)
54-
);
55-
};
56-
5735
printVersions = let
5836
versionsMap = with lib;
5937
mapAttrs (lang: value: if (hasAttr "versions" value) then value.versions else {})

0 commit comments

Comments
 (0)