Skip to content
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

tests.trivial-builders.references: provide passthru attributes and override interface on non-Linux platforms #273183

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions pkgs/build-support/trivial-builders/test/default.nix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather suggest to keep static attribute names, but set meta.platforms so that the attributes aren't evaluated outside linux

Copy link
Contributor Author

@ShamrockLee ShamrockLee Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, the NixOS test modules do not provide an option to specify/expose meta.platforms, nor does the result derivation come with overrideAttrs.

Copy link
Contributor

@SomeoneSerge SomeoneSerge Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting

nix-repl> :lf github:ShamrockLee/nixpkgs/test-references-shellcheck-fix
nix-repl> legacyPackages.x86_64-linux.tests.trivial-builders.references.meta                      
{ broken = false; maintainers = [ ... ]; timeout = 3600; }
nix-repl> legacyPackages.x86_64-linux.tests.trivial-builders.references.override<TAB>
legacyPackages.x86_64-linux.tests.trivial-builders.references.override
legacyPackages.x86_64-linux.tests.trivial-builders.references.overrideDerivation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you need meta.platforms? If so, it can be added in nixos/lib/testing/meta.nix, or we could give that a freeformType.

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 {};
}