mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
nixosTests: extract readOnlyPkgs to its own module file
Move the inline readOnlyPkgs module to nixos/tests/read-only-pkgs.nix so the module system sets _file automatically from the file path, removing the need for __curPos.
This commit is contained in:
parent
4799c4d297
commit
59a9cbba4a
2 changed files with 18 additions and 19 deletions
|
|
@ -112,7 +112,7 @@ let
|
|||
((import ../lib/testing-python.nix { inherit system pkgs; }).evalTest {
|
||||
imports = [
|
||||
arg
|
||||
readOnlyPkgs
|
||||
./read-only-pkgs.nix
|
||||
];
|
||||
}).config.result;
|
||||
findTests =
|
||||
|
|
@ -140,24 +140,6 @@ let
|
|||
runTestOn
|
||||
;
|
||||
|
||||
# Using a single instance of nixpkgs makes test evaluation faster.
|
||||
# To make sure we don't accidentally depend on a modified pkgs, we make the
|
||||
# related options read-only. We need to test the right configuration.
|
||||
#
|
||||
# If your service depends on a nixpkgs setting, first try to avoid that, but
|
||||
# otherwise, you can remove the readOnlyPkgs import and test your service as
|
||||
# usual.
|
||||
readOnlyPkgs =
|
||||
# TODO: We currently accept this for nixosTests, so that the `pkgs` argument
|
||||
# is consistent with `pkgs` in `pkgs.nixosTests`. Can we reinitialize
|
||||
# it with `allowAliases = false`?
|
||||
# warnIf pkgs.config.allowAliases "nixosTests: pkgs includes aliases."
|
||||
{
|
||||
_file = "${__curPos.file} readOnlyPkgs";
|
||||
_class = "nixosTest";
|
||||
node.pkgs = pkgs.pkgsLinux;
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
|
||||
|
|
|
|||
17
nixos/tests/read-only-pkgs.nix
Normal file
17
nixos/tests/read-only-pkgs.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Using a single instance of nixpkgs makes test evaluation faster.
|
||||
# To make sure we don't accidentally depend on a modified pkgs, we make the
|
||||
# related options read-only. We need to test the right configuration.
|
||||
#
|
||||
# If your service depends on a nixpkgs setting, first try to avoid that, but
|
||||
# otherwise, you can remove the readOnlyPkgs import and test your service as
|
||||
# usual.
|
||||
|
||||
# TODO: We currently accept this for nixosTests, so that the `pkgs` argument
|
||||
# is consistent with `pkgs` in `pkgs.nixosTests`. Can we reinitialize
|
||||
# it with `allowAliases = false`?
|
||||
# warnIf pkgs.config.allowAliases "nixosTests: pkgs includes aliases."
|
||||
{ hostPkgs, ... }:
|
||||
{
|
||||
_class = "nixosTest";
|
||||
node.pkgs = hostPkgs.pkgsLinux;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue