···14 types
15 ;
1617+ inherit (hostPkgs) hostPlatform;
18+19+ guestSystem =
20+ if hostPlatform.isLinux
21+ then hostPlatform.system
22+ else
23+ let
24+ hostToGuest = {
25+ "x86_64-darwin" = "x86_64-linux";
26+ "aarch64-darwin" = "aarch64-linux";
27+ };
28+29+ supportedHosts = lib.concatStringsSep ", " (lib.attrNames hostToGuest);
30+31+ message =
32+ "NixOS Test: don't know which VM guest system to pair with VM host system: ${hostPlatform.system}. Perhaps you intended to run the tests on a Linux host, or one of the following systems that may run NixOS tests: ${supportedHosts}";
33+ in
34+ hostToGuest.${hostPlatform.system} or (throw message);
35+36 baseOS =
37 import ../eval-config.nix {
38 inherit lib;
···46 ({ config, ... }:
47 {
48 virtualisation.qemu.package = testModuleArgs.config.qemu.package;
49+ virtualisation.host.pkgs = hostPkgs;
50 })
51 ({ options, ... }: {
52 key = "nodes.nix-pkgs";
53 config = optionalAttrs (!config.node.pkgsReadOnly) (
54 mkIf (!options.nixpkgs.pkgs.isDefined) {
55 # TODO: switch to nixpkgs.hostPlatform and make sure containers-imperative test still evaluates.
56+ nixpkgs.system = guestSystem;
57 }
58 );
59 })
+5-1
nixos/lib/testing/pkgs.nix
···2{
3 config = {
4 # default pkgs for use in VMs
5- _module.args.pkgs = hostPkgs;
000067 defaults = {
8 # TODO: a module to set a shared pkgs, if options.nixpkgs.* is untouched by user (highestPrio) */
···2{
3 config = {
4 # default pkgs for use in VMs
5+ _module.args.pkgs =
6+ # TODO: deprecate it everywhere; not just on darwin. Throw on darwin?
7+ lib.warnIf hostPkgs.stdenv.hostPlatform.isDarwin
8+ "Do not use the `pkgs` module argument in tests you want to run on darwin. It is ambiguous, and many tests are broken because of it. If you need to use a package on the VM host, use `hostPkgs`. Otherwise, use `config.node.pkgs`, or `config.nodes.<name>.nixpkgs.pkgs`."
9+ hostPkgs;
1011 defaults = {
12 # TODO: a module to set a shared pkgs, if options.nixpkgs.* is untouched by user (highestPrio) */
···8 owner = "RazrFalcon";
9 repo = pname;
10 rev = "v${version}";
11- sha256 = "sha256-lCA7C1G2xu65jn3/wzj6prWSrjQz3EqqJyMlPR/HRFs=";
12 };
1314- cargoSha256 = "sha256-fOenXn5gagFss9DRDXXsGxQlDqVXZ5LZcdM4WsXAyUU=";
1516 meta = with lib; {
17 description = "A tool and Cargo subcommand that helps you find out what takes most of the space in your executable";
···19 license = licenses.mit;
20 platforms = platforms.unix;
21 maintainers = with maintainers; [ xrelkd matthiasbeyer ];
022 };
23}
24-
···8 owner = "RazrFalcon";
9 repo = pname;
10 rev = "v${version}";
11+ hash = "sha256-lCA7C1G2xu65jn3/wzj6prWSrjQz3EqqJyMlPR/HRFs=";
12 };
1314+ cargoHash = "sha256-fOenXn5gagFss9DRDXXsGxQlDqVXZ5LZcdM4WsXAyUU=";
1516 meta = with lib; {
17 description = "A tool and Cargo subcommand that helps you find out what takes most of the space in your executable";
···19 license = licenses.mit;
20 platforms = platforms.unix;
21 maintainers = with maintainers; [ xrelkd matthiasbeyer ];
22+ mainProgram = "cargo-bloat";
23 };
24}
0
···243 };
244 } else throw "x86_64 Darwin package set can only be used on Darwin systems.";
2450000000000246 # Extend the package set with zero or more overlays. This preserves
247 # preexisting overlays. Prefer to initialize with the right overlays
248 # in one go when calling Nixpkgs, for performance and simplicity.
···243 };
244 } else throw "x86_64 Darwin package set can only be used on Darwin systems.";
245246+ # If already linux: the same package set unaltered
247+ # Otherwise, return a natively built linux package set for the current cpu architecture string.
248+ # (ABI and other details will be set to the default for the cpu/os pair)
249+ pkgsLinux =
250+ if stdenv.hostPlatform.isLinux
251+ then self
252+ else nixpkgsFun {
253+ localSystem = lib.systems.elaborate "${stdenv.hostPlatform.parsed.cpu.name}-linux";
254+ };
255+256 # Extend the package set with zero or more overlays. This preserves
257 # preexisting overlays. Prefer to initialize with the right overlays
258 # in one go when calling Nixpkgs, for performance and simplicity.