-
Notifications
You must be signed in to change notification settings - Fork 3
Support flake-schemas 0.3.0 #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| json = {}; | ||
| json.docs = {}; | ||
| json.docs.bySystem = "The `bySystem` flake output defines a per-system output, like a flake's `formatter`.\n"; | ||
| json.inventory = {}; | ||
| json.inventory.bySystem = {}; | ||
| json.inventory.bySystem.children = {}; | ||
| json.inventory.bySystem.children["aarch64-darwin"] = {}; | ||
| json.inventory.bySystem.children["aarch64-darwin"].forSystems = []; | ||
| json.inventory.bySystem.children["aarch64-darwin"].forSystems[0] = "aarch64-darwin"; | ||
| json.inventory.bySystem.children["aarch64-darwin"].shortDescription = ""; | ||
| json.inventory.bySystem.children["aarch64-darwin"].what = "bySystem"; | ||
| json.inventory.bySystem.children["x86_64-linux"] = {}; | ||
| json.inventory.bySystem.children["x86_64-linux"].forSystems = []; | ||
| json.inventory.bySystem.children["x86_64-linux"].forSystems[0] = "x86_64-linux"; | ||
| json.inventory.bySystem.children["x86_64-linux"].shortDescription = ""; | ||
| json.inventory.bySystem.children["x86_64-linux"].what = "bySystem"; | ||
| json.version = 1; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| json = {}; | ||
| json.docs = {}; | ||
| json.docs.bySystem = "The `bySystem` flake output defines a per-system output, like a flake's `formatter`.\n"; | ||
| json.inventory = {}; | ||
| json.inventory.bySystem = {}; | ||
| json.inventory.bySystem.children = {}; | ||
| json.inventory.bySystem.children["aarch64-darwin"] = {}; | ||
| json.inventory.bySystem.children["aarch64-darwin"].derivation = "/nix/store/0hbva7czr00sf4m97jlw4swagc8ccz87-simple.drv"; | ||
| json.inventory.bySystem.children["aarch64-darwin"].forSystems = []; | ||
| json.inventory.bySystem.children["aarch64-darwin"].forSystems[0] = "aarch64-darwin"; | ||
| json.inventory.bySystem.children["aarch64-darwin"].outputs = {}; | ||
| json.inventory.bySystem.children["aarch64-darwin"].outputs.doc = "/nix/store/3jvc25bixqghypgda09hhg7sm2sdvi1k-simple-doc"; | ||
| json.inventory.bySystem.children["aarch64-darwin"].outputs.out = "/nix/store/9nnh702lr0klxsgsqff3p198ycxa2gbj-simple"; | ||
| json.inventory.bySystem.children["aarch64-darwin"].shortDescription = ""; | ||
| json.inventory.bySystem.children["aarch64-darwin"].what = "bySystem"; | ||
| json.inventory.bySystem.children["x86_64-linux"] = {}; | ||
| json.inventory.bySystem.children["x86_64-linux"].derivation = "/nix/store/pxlb58dhphzbzhk40gbasdlaxnrjxndr-simple.drv"; | ||
| json.inventory.bySystem.children["x86_64-linux"].forSystems = []; | ||
| json.inventory.bySystem.children["x86_64-linux"].forSystems[0] = "x86_64-linux"; | ||
| json.inventory.bySystem.children["x86_64-linux"].outputs = {}; | ||
| json.inventory.bySystem.children["x86_64-linux"].outputs.doc = "/nix/store/5yf9i39g2kk2xs7kzwq3v3pcar92r47z-simple-doc"; | ||
| json.inventory.bySystem.children["x86_64-linux"].outputs.out = "/nix/store/bc36n9f0as5lxkq35xyvc2ch40j7y3ya-simple"; | ||
| json.inventory.bySystem.children["x86_64-linux"].shortDescription = ""; | ||
| json.inventory.bySystem.children["x86_64-linux"].what = "bySystem"; | ||
| json.version = 1; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| json = {}; | ||
| json.docs = {}; | ||
| json.docs.bySystem = "The `bySystem` flake output defines a per-system output, like a flake's `formatter`.\n"; | ||
| json.inventory = {}; | ||
| json.inventory.bySystem = {}; | ||
| json.inventory.bySystem.children = {}; | ||
| json.inventory.bySystem.children["aarch64-darwin"] = {}; | ||
| json.inventory.bySystem.children["aarch64-darwin"].forSystems = []; | ||
| json.inventory.bySystem.children["aarch64-darwin"].forSystems[0] = "aarch64-darwin"; | ||
| json.inventory.bySystem.children["aarch64-darwin"].shortDescription = ""; | ||
| json.inventory.bySystem.children["aarch64-darwin"].what = "bySystem"; | ||
| json.inventory.bySystem.children["x86_64-linux"] = {}; | ||
| json.inventory.bySystem.children["x86_64-linux"].forSystems = []; | ||
| json.inventory.bySystem.children["x86_64-linux"].forSystems[0] = "x86_64-linux"; | ||
| json.inventory.bySystem.children["x86_64-linux"].shortDescription = ""; | ||
| json.inventory.bySystem.children["x86_64-linux"].what = "bySystem"; | ||
| json.version = 1; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| json = {}; | ||
| json.docs = {}; | ||
| json.docs.bySystem = "The `bySystem` flake output defines a per-system output, like a flake's `formatter`.\n"; | ||
| json.inventory = {}; | ||
| json.inventory.bySystem = {}; | ||
| json.inventory.bySystem.children = {}; | ||
| json.inventory.bySystem.children["aarch64-darwin"] = {}; | ||
| json.inventory.bySystem.children["aarch64-darwin"].derivation = "/nix/store/0hbva7czr00sf4m97jlw4swagc8ccz87-simple.drv"; | ||
| json.inventory.bySystem.children["aarch64-darwin"].forSystems = []; | ||
| json.inventory.bySystem.children["aarch64-darwin"].forSystems[0] = "aarch64-darwin"; | ||
| json.inventory.bySystem.children["aarch64-darwin"].outputs = {}; | ||
| json.inventory.bySystem.children["aarch64-darwin"].outputs.doc = "/nix/store/3jvc25bixqghypgda09hhg7sm2sdvi1k-simple-doc"; | ||
| json.inventory.bySystem.children["aarch64-darwin"].outputs.out = "/nix/store/9nnh702lr0klxsgsqff3p198ycxa2gbj-simple"; | ||
| json.inventory.bySystem.children["aarch64-darwin"].shortDescription = ""; | ||
| json.inventory.bySystem.children["aarch64-darwin"].what = "bySystem"; | ||
| json.inventory.bySystem.children["x86_64-linux"] = {}; | ||
| json.inventory.bySystem.children["x86_64-linux"].derivation = "/nix/store/pxlb58dhphzbzhk40gbasdlaxnrjxndr-simple.drv"; | ||
| json.inventory.bySystem.children["x86_64-linux"].forSystems = []; | ||
| json.inventory.bySystem.children["x86_64-linux"].forSystems[0] = "x86_64-linux"; | ||
| json.inventory.bySystem.children["x86_64-linux"].outputs = {}; | ||
| json.inventory.bySystem.children["x86_64-linux"].outputs.doc = "/nix/store/5yf9i39g2kk2xs7kzwq3v3pcar92r47z-simple-doc"; | ||
| json.inventory.bySystem.children["x86_64-linux"].outputs.out = "/nix/store/bc36n9f0as5lxkq35xyvc2ch40j7y3ya-simple"; | ||
| json.inventory.bySystem.children["x86_64-linux"].shortDescription = ""; | ||
| json.inventory.bySystem.children["x86_64-linux"].what = "bySystem"; | ||
| json.version = 1; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inputs.flake.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/*"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outputs = inputs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getFlakeOutputs = flake: includeOutputPaths: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -9,13 +10,24 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapAttrsToList = f: attrs: map (name: f name attrs.${name}) (builtins.attrNames attrs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getAttrFromPath = paths: obj: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| length = builtins.length paths - 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| go = acc: index: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if index > length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| then acc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else go acc.${builtins.elemAt paths index} (index + 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| go obj 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try = e: default: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let res = builtins.tryEval e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| in if res.success then res.value else default; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkChildren = children: { inherit children; }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| flakeSchemasFlakePinned = "https://api.flakehub.com/f/pinned/DeterminateSystems/flake-schemas/0.1.4/0190e653-dd76-70bd-ba6e-a3f5eaf3d415/source.tar.gz?narHash=sha256-efoDF3VaZHpcwFd2Y1axGLqNX/ou9kDL7z9mWNqzv9w%3D"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| flakeSchemasFlakePinned = "https://api.flakehub.com/f/pinned/DeterminateSystems/flake-schemas/0.3.0/019c9f61-e746-760e-a1fe-53f05b10d026/source.tar.gz?narHash=sha256-hcUPpu25%2BVLvQsf961cu4zTeA//Ab35MaMjqSS/Ojqc%3D"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rec { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -52,53 +64,67 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uncheckedOutputs = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| builtins.filter (outputName: ! schemas ? ${outputName}) (builtins.attrNames flake.outputs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inventoryFor = filterFun: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inventoryFor = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| filterFun: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| builtins.mapAttrs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (outputName: schema: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outputName: schema: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| doFilter = attrs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if filterFun attrs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if attrs ? children | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkChildren (builtins.mapAttrs (childName: child: doFilter child) attrs.children) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| doFilter = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| attrs: output: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if filterFun attrs then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if attrs ? children then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkChildren | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| builtins.mapAttrs (childName: child: doFilter child output.${childName}) attrs.children | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| forSystems = attrs.forSystems or null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shortDescription = attrs.shortDescription or null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| what = attrs.what or null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #evalChecks = attrs.evalChecks or {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } // ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if includeOutputPaths then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| derivation = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if attrs ? derivation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| then builtins.unsafeDiscardStringContext attrs.derivation.drvPath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| includeOutputPaths then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| drv = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if attrs?derivationAttrPath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| then getAttrFromPath attrs.derivationAttrPath output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # TODO: This is a fallback for legacy behavior. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Remove when most (or all) flake schemas in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # wild use derivationAttrPath instead of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # derivation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else if attrs?derivation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| then attrs.derivation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| derivation = if drv != null then builtins.unsafeDiscardStringContext drv.drvPath else null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outputs = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if attrs ? derivation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if drv != null then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| builtins.listToAttrs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| builtins.map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (outputName: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name = outputName; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value = attrs.derivation.${outputName}.outPath; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| attrs.derivation.outputs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (outputName: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name = outputName; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value = drv.${outputName}.outPath; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| drv.outputs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) else null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+91
to
+114
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard derivation path dereferences to prevent full inventory evaluation failure. Line 93, Line 100, and Line 108 can throw when a path is stale or resolves to a non-derivation value. That makes 🛡️ Suggested hardening patch- drv =
- if attrs?derivationAttrPath
- then getAttrFromPath attrs.derivationAttrPath output
+ drv =
+ if attrs ? derivationAttrPath
+ then try (getAttrFromPath attrs.derivationAttrPath output) null
# TODO: remove when no longer needed
- else if attrs?derivation
+ else if attrs ? derivation
then attrs.derivation
else null;
in
{
- derivation = if drv != null then drv.drvPath else null;
+ derivation = try (if drv != null then drv.drvPath else null) null;
outputs =
- if drv != null then
- builtins.listToAttrs
- (
- builtins.map
- (outputName: {
- name = outputName;
- value = drv.${outputName}.outPath;
- })
- drv.outputs
- ) else null;
+ try (
+ if drv != null then
+ builtins.listToAttrs
+ (
+ builtins.map
+ (outputName: {
+ name = outputName;
+ value = drv.${outputName}.outPath;
+ })
+ drv.outputs
+ )
+ else null
+ ) null;
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| doFilter ((schema.inventory or (output: { })) flake.outputs.${outputName}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| doFilter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ((schema.inventory or (output: { })) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| flake.outputs.${outputName} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| flake.outputs.${outputName} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| schemas; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| { | ||
| description = "Flake with a custom schema mimicking `formatter`, using flake-schema 0.1.4's behavior"; | ||
|
|
||
| inputs = { }; | ||
|
|
||
| outputs = | ||
| _: | ||
| let | ||
| nameValuePair = name: value: { inherit name value; }; | ||
| genAttrs = names: f: builtins.listToAttrs (map (n: nameValuePair n (f n)) names); | ||
|
|
||
| stubFor = | ||
| system: | ||
| name: | ||
| derivation { | ||
| inherit name system; | ||
|
|
||
| builder = "/bin/sh"; | ||
| args = [ | ||
| "-c" | ||
| '' | ||
| echo "out: $name/$system" >$out | ||
| echo "doc: $name/$system" >$doc | ||
| '' | ||
| ]; | ||
|
|
||
| outputs = [ | ||
| "out" | ||
| "doc" | ||
| ]; | ||
| }; | ||
|
|
||
| systems = [ | ||
| "aarch64-darwin" | ||
| "x86_64-linux" | ||
| ]; | ||
|
|
||
| forEachSystem = f: genAttrs systems (system: f (stubFor system)); | ||
| in | ||
| { | ||
| # A flat schema like formatter.${system} | ||
| schemas.bySystem = { | ||
| version = 1; | ||
| doc = '' | ||
| The `bySystem` flake output defines a per-system output, like a flake's `formatter`. | ||
| ''; | ||
|
|
||
| appendSystem = true; | ||
| defaultAttrPath = [ ]; | ||
|
|
||
| inventory = output: { | ||
| children = builtins.mapAttrs | ||
| (system: pkg: { | ||
| what = "bySystem"; | ||
| forSystems = [ system ]; | ||
| shortDescription = pkg.meta.description or ""; | ||
| derivation = pkg; | ||
| }) | ||
| output; | ||
| }; | ||
| }; | ||
|
|
||
| bySystem = forEachSystem (stub: stub "simple"); | ||
| }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| { | ||
| description = "Flake with a custom schema mimicking `formatter`, using flake-schema 0.3.0's behavior"; | ||
|
|
||
| inputs = { }; | ||
|
|
||
| outputs = | ||
| _: | ||
| let | ||
| nameValuePair = name: value: { inherit name value; }; | ||
| genAttrs = names: f: builtins.listToAttrs (map (n: nameValuePair n (f n)) names); | ||
|
|
||
| stubFor = | ||
| system: | ||
| name: | ||
| derivation { | ||
| inherit name system; | ||
|
|
||
| builder = "/bin/sh"; | ||
| args = [ | ||
| "-c" | ||
| '' | ||
| echo "out: $name/$system" >$out | ||
| echo "doc: $name/$system" >$doc | ||
| '' | ||
| ]; | ||
|
|
||
| outputs = [ | ||
| "out" | ||
| "doc" | ||
| ]; | ||
| }; | ||
|
|
||
| systems = [ | ||
| "aarch64-darwin" | ||
| "x86_64-linux" | ||
| ]; | ||
|
|
||
| forEachSystem = f: genAttrs systems (system: f (stubFor system)); | ||
| in | ||
| { | ||
| # A flat schema like formatter.${system} | ||
| schemas.bySystem = { | ||
| version = 1; | ||
| doc = '' | ||
| The `bySystem` flake output defines a per-system output, like a flake's `formatter`. | ||
| ''; | ||
|
|
||
| appendSystem = true; | ||
| defaultAttrPath = [ ]; | ||
|
|
||
| inventory = output: { | ||
| children = builtins.mapAttrs | ||
| (system: pkg: { | ||
| what = "bySystem"; | ||
| forSystems = [ system ]; | ||
| shortDescription = pkg.meta.description or ""; | ||
| derivationAttrPath = [ ]; | ||
| }) | ||
| output; | ||
| }; | ||
| }; | ||
|
|
||
| bySystem = forEachSystem (stub: stub "simple"); | ||
| }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only real change here is passing attrs.children to doFilter inside mapAttrs.