Skip to content

Commit

Permalink
test.trivial-builders.references: Unify interface across systems
Browse files Browse the repository at this point in the history
Forward override interface and essential passthru attributes of
`tests.trivial-builders.references` to non-Linux platforms.

Enable `pkgs`-wide `samples` overriding via the override interface
of `tests.trivial-builders.references` in Nixpkgs overlays.
  • Loading branch information
ShamrockLee committed Mar 18, 2024
1 parent 9b54fb4 commit 507db5e
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions pkgs/build-support/trivial-builders/test/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,47 @@
*/

{ callPackage, lib, stdenv }:
{ callPackage, lib, stdenv, tests }:
let
inherit (lib) recurseIntoAttrs;
references = callPackage ./references {};
# To override the `samples` for all other test cases, pass the new
# `samples` to `references.override` in Nixpkgs overlays.
final-references = tests.trivial-builders.references;
in
recurseIntoAttrs {
concat = callPackage ./concat-test.nix {};
linkFarm = callPackage ./link-farm.nix {};
overriding = callPackage ../test-overriding.nix {};
# VM test not supported beyond linux yet
# VM test not supported beyond linux yet, while non-Linux users can
# still run the test by executing `references.testScriptBin`, and
# access passthru attributes like `samples`, the way Linux users do.
# Use `references.override` to override these attributes.
references =
if stdenv.hostPlatform.isLinux
then references
else {};
if stdenv.hostPlatform.isLinux then
references
else
lib.makeOverridable (lib.mirrorFunctionArgs references.override (referenceArgs:
let
references-overridden = references.override referenceArgs;
in
{
inherit (references-overridden)
samples
references
directReferences
testScriptBin
;
meta = { inherit (references-overridden.meta) maintainers; };
}
)) { };
writeCBin = callPackage ./writeCBin.nix {};
writeShellApplication = callPackage ./writeShellApplication.nix {};
writeScriptBin = callPackage ./writeScriptBin.nix {};
writeShellScript = callPackage ./write-shell-script.nix {};
writeShellScriptBin = callPackage ./writeShellScriptBin.nix {};
writeStringReferencesToFile = callPackage ./writeStringReferencesToFile.nix {
inherit (references) samples;
inherit (final-references) samples;
};
writeTextFile = callPackage ./write-text-file.nix {};
}

0 comments on commit 507db5e

Please sign in to comment.