mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-12 10:50:30 +08:00
Compare commits
14 Commits
update-ovi
...
python-tes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e54227b0df | ||
|
|
ad048019ad | ||
|
|
20ed39a036 | ||
|
|
95e249772f | ||
|
|
936309cb9b | ||
|
|
7e2d8c4ace | ||
|
|
a486968a6e | ||
|
|
9edbbf1633 | ||
|
|
5400041d4a | ||
|
|
ae64e1b4cf | ||
|
|
7a32a2eb7d | ||
|
|
4f21de5214 | ||
|
|
35068dc47f | ||
|
|
2d0a47236d |
@@ -1,7 +1,18 @@
|
||||
testModuleArgs@{ config, lib, hostPkgs, nodes, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkOption mkForce optional types mapAttrs mkDefault mdDoc;
|
||||
inherit (lib)
|
||||
literalExpression
|
||||
literalMD
|
||||
mapAttrs
|
||||
mdDoc
|
||||
mkDefault
|
||||
mkIf
|
||||
mkOption mkForce
|
||||
optional
|
||||
optionalAttrs
|
||||
types
|
||||
;
|
||||
|
||||
baseOS =
|
||||
import ../eval-config.nix {
|
||||
@@ -16,7 +27,8 @@ let
|
||||
{
|
||||
virtualisation.qemu.package = testModuleArgs.config.qemu.package;
|
||||
})
|
||||
({
|
||||
(optionalAttrs (!config.node.pkgsReadOnly) {
|
||||
key = "nodes.nix-pkgs";
|
||||
config = {
|
||||
# Ensure we do not use aliases. Ideally this is only set
|
||||
# when the test framework is used by Nixpkgs NixOS tests.
|
||||
@@ -71,6 +83,30 @@ in
|
||||
default = { };
|
||||
};
|
||||
|
||||
node.pkgs = mkOption {
|
||||
description = mdDoc ''
|
||||
The Nixpkgs to use for the nodes.
|
||||
|
||||
Setting this will make the `nixpkgs.*` options read-only, to avoid mistakenly testing with a Nixpkgs configuration that diverges from regular use.
|
||||
'';
|
||||
type = types.nullOr types.pkgs;
|
||||
default = null;
|
||||
defaultText = literalMD ''
|
||||
`null`, so construct `pkgs` according to the `nixpkgs.*` options as usual.
|
||||
'';
|
||||
};
|
||||
|
||||
node.pkgsReadOnly = mkOption {
|
||||
description = mdDoc ''
|
||||
Whether to make the `nixpkgs.*` options read-only. This is only relevant when [`node.pkgs`](#test-opt-node.pkgs) is set.
|
||||
|
||||
Set this to `false` when any of the [`nodes`](#test-opt-nodes) needs to configure any of the `nixpkgs.*` options. This will slow down evaluation of your test a bit.
|
||||
'';
|
||||
type = types.bool;
|
||||
default = config.node.pkgs != null;
|
||||
defaultText = literalExpression ''node.pkgs != null'';
|
||||
};
|
||||
|
||||
node.specialArgs = mkOption {
|
||||
type = types.lazyAttrsOf types.raw;
|
||||
default = { };
|
||||
@@ -103,5 +139,11 @@ in
|
||||
config.nodes;
|
||||
|
||||
passthru.nodes = config.nodesCompat;
|
||||
|
||||
defaults = mkIf config.node.pkgsReadOnly {
|
||||
nixpkgs.pkgs = config.node.pkgs;
|
||||
imports = [ ../../modules/misc/nixpkgs/read-only.nix ];
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ let
|
||||
inherit
|
||||
(rec {
|
||||
doRunTest = arg: ((import ../lib/testing-python.nix { inherit system pkgs; }).evalTest {
|
||||
imports = [ arg ];
|
||||
imports = [ arg readOnlyPkgs ];
|
||||
}).config.result;
|
||||
findTests = tree:
|
||||
if tree?recurseForDerivations && tree.recurseForDerivations
|
||||
@@ -65,6 +65,23 @@ 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."
|
||||
{
|
||||
_class = "nixosTest";
|
||||
node.pkgs = pkgs;
|
||||
};
|
||||
|
||||
in {
|
||||
|
||||
# Testing the test driver
|
||||
@@ -77,7 +94,7 @@ in {
|
||||
|
||||
_3proxy = runTest ./3proxy.nix;
|
||||
aaaaxy = runTest ./aaaaxy.nix;
|
||||
acme = runTest ./acme.nix;
|
||||
acme = runTest { imports = [ ./acme.nix ]; };
|
||||
adguardhome = runTest ./adguardhome.nix;
|
||||
aesmd = runTestOn ["x86_64-linux"] ./aesmd.nix;
|
||||
agate = runTest ./web-servers/agate.nix;
|
||||
|
||||
Reference in New Issue
Block a user