Skip to content

Commit

Permalink
πŸ› Fix C platform output
Browse files Browse the repository at this point in the history
Previously, setting `output` would make the derivation
end up on the correct component attribute but when splicing happened
it would look for the target named by `name` in other components.
  • Loading branch information
abbec committed Sep 13, 2024
1 parent 136046e commit 03c2f9e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Fixed
- Overriding the factory of a C platform caused the 'override' function
to disappear from the resulting set.
- `output` now works as expected on C platforms. Previously, setting
output to a different value than `name` created a broken
configuration.

## [4.1.4] - 2024-06-03

Expand Down
6 changes: 3 additions & 3 deletions c/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ let
{ name
, pkgs
, stdenv ? pkgs.stdenv
, output ? null
, output ? name
, platformOverrides ? _: { }
, factoryOverrides ? { }
}@args:
Expand All @@ -45,7 +45,7 @@ let
(import ./make-derivation.nix platformOverrides)
({
inherit base stdenv components;
targetName = name;
targetName = output;
mathjax = mathjax';
} // factoryOverrides);

Expand All @@ -71,7 +71,7 @@ let
createPlatformTargets = attrsOrFn:
lib.mapAttrs'
(name: platform: {
name = platform.output or name;
name = platform.output;
value = platform attrsOrFn;
})
platforms';
Expand Down
7 changes: 4 additions & 3 deletions tests/c.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ let
platforms = {
_default = cCross.mkPlatform {
name = "risk-πŸ•”";
output = "risc-v";
pkgs = pkgs.pkgsCross.riscv32;

platformOverrides = pkgAttrs: {
Expand All @@ -57,11 +58,11 @@ let
};
in
# With new default target we should have only _default
assert library ? _default && !(library ? windows);
assert library ? "πŸͺŸ" && !(library ? _default);
# Default target should be there unless overridden
assert libraryWasi ? _default && libraryWasi ? wasi && libraryWasi._default != libraryWasi.wasi;
assert libraryWasi ? _default && libraryWasi ? "πŸ‘" && libraryWasi._default != libraryWasi."πŸ‘";
# With inline, default cross target
assert libraryRiscv ? _default;
assert libraryRiscv ? "risc-v";

builtins.trace ''βœ”οΈ C tests succeeded ${c.emoji}''
{ }

0 comments on commit 03c2f9e

Please sign in to comment.