Skip to content

Commit

Permalink
Add .#allSettingsSchemas output
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Sep 26, 2024
1 parent ae23c82 commit 7b75458
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 31 deletions.
10 changes: 1 addition & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

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

# For .envrc
nixpkgsPath = pkgsStable.writeShellScriptBin "nixpkgsPath.sh" "echo -n ${pkgsStable.path}";
Expand All @@ -39,15 +40,6 @@
}
// sampleOutputs.inner
;

checks = {
customScript = pkgsStable.writeShellScript "test-script" ''
#!/bin/sh
echo "Running custom test..."
# Add your test logic here
exit 0
'';
};
}
);
}
29 changes: 29 additions & 0 deletions nix/all-settings-schemas.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ lib
, writeShellScript
, writeTextFile

, sample_environments
}:

let
all_settings_schemas = let
gatherSchemas = prefix: pkg:
(if !(lib.hasAttrByPath ["meta" "settings_schema"] pkg) then []
else [{ name = prefix + pkg.name; value = pkg.meta.settings_schema; }])
++ builtins.concatLists (map (gatherSchemas (prefix + pkg.name + ".")) (pkg.packages or []))
;

gatherSchemasFromEnvironment = prefix: env:
builtins.concatLists (lib.mapAttrsToList (n: v: gatherSchemas prefix v) env.ui_metadata.packages);

in
lib.listToAttrs (
builtins.concatLists (lib.mapAttrsToList (n: v: gatherSchemasFromEnvironment (n + ".") v) sample_environments)
);

in

writeTextFile {
name = "all_settings_schemas.json";
text = builtins.toJSON all_settings_schemas;
}
22 changes: 0 additions & 22 deletions nix/sample-outputs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,6 @@ in
sample_environments
);

# TODO: add test that all settings schemas are valid in certain ways:
# - they all have a title
all_settings_schemas = let
gatherSchemas = prefix: pkg:
(if !(lib.hasAttrByPath ["meta" "settings_schema"] pkg) then []
else [{ name = prefix + pkg.name; value = pkg.meta.settings_schema; }])
++ builtins.concatLists (map (gatherSchemas (prefix + pkg.name + ".")) (pkg.packages or []))
;

gatherSchemasFromEnvironment = prefix: env:
builtins.concatLists (lib.mapAttrsToList (n: v: gatherSchemas prefix v) env.ui_metadata.packages);

in
writeTextFile {
name = "all_settings_schemas.json";
text = builtins.toJSON (
lib.listToAttrs (
builtins.concatLists (lib.mapAttrsToList (n: v: gatherSchemasFromEnvironment (n + ".") v) sample_environments)
)
);
};

printVersions = let
versionsMap = with lib;
mapAttrs (lang: value: if (hasAttr "versions" value) then value.versions else {})
Expand Down

0 comments on commit 7b75458

Please sign in to comment.