mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
Merge pull request #13572 from xokdvium/nixos-tests-parametrize
tests/nixos: Parametrize on the system
This commit is contained in:
commit
6365cf1446
3 changed files with 47 additions and 43 deletions
|
|
@ -240,7 +240,9 @@ in
|
||||||
# System tests.
|
# System tests.
|
||||||
tests =
|
tests =
|
||||||
import ../tests/nixos {
|
import ../tests/nixos {
|
||||||
inherit lib nixpkgs nixpkgsFor;
|
inherit lib nixpkgs;
|
||||||
|
pkgs = nixpkgsFor.x86_64-linux.native;
|
||||||
|
nixComponents = nixpkgsFor.x86_64-linux.native.nixComponents2;
|
||||||
inherit (self.inputs) nixpkgs-23-11;
|
inherit (self.inputs) nixpkgs-23-11;
|
||||||
}
|
}
|
||||||
// {
|
// {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
|
nixComponents,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
nixpkgsFor,
|
|
||||||
nixpkgs-23-11,
|
nixpkgs-23-11,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
|
@ -19,27 +20,28 @@ let
|
||||||
);
|
);
|
||||||
|
|
||||||
# https://nixos.org/manual/nixos/unstable/index.html#sec-calling-nixos-tests
|
# https://nixos.org/manual/nixos/unstable/index.html#sec-calling-nixos-tests
|
||||||
runNixOSTestFor =
|
runNixOSTest =
|
||||||
system: test:
|
test:
|
||||||
(nixos-lib.runTest {
|
(nixos-lib.runTest {
|
||||||
imports = [
|
imports = [
|
||||||
test
|
test
|
||||||
];
|
];
|
||||||
|
|
||||||
hostPkgs = nixpkgsFor.${system}.native;
|
hostPkgs = pkgs;
|
||||||
defaults = {
|
defaults = {
|
||||||
nixpkgs.pkgs = nixpkgsFor.${system}.native;
|
nixpkgs.pkgs = pkgs;
|
||||||
nix.checkAllErrors = false;
|
nix.checkAllErrors = false;
|
||||||
# TODO: decide which packaging stage to use. `nix-cli` is efficient, but not the same as the user-facing `everything.nix` package (`default`). Perhaps a good compromise is `everything.nix` + `noTests` defined above?
|
# TODO: decide which packaging stage to use. `nix-cli` is efficient, but not the same as the user-facing `everything.nix` package (`default`). Perhaps a good compromise is `everything.nix` + `noTests` defined above?
|
||||||
nix.package = nixpkgsFor.${system}.native.nixComponents2.nix-cli;
|
nix.package = nixComponents.nix-cli;
|
||||||
|
|
||||||
# Evaluate VMs faster
|
# Evaluate VMs faster
|
||||||
documentation.enable = false;
|
documentation.enable = false;
|
||||||
# this links against nix and might break with our git version.
|
# this links against nix and might break with our git version.
|
||||||
system.tools.nixos-option.enable = false;
|
system.tools.nixos-option.enable = false;
|
||||||
};
|
};
|
||||||
|
_module.args.nixComponents = nixComponents;
|
||||||
_module.args.nixpkgs = nixpkgs;
|
_module.args.nixpkgs = nixpkgs;
|
||||||
_module.args.system = system;
|
_module.args.system = pkgs.system;
|
||||||
})
|
})
|
||||||
// {
|
// {
|
||||||
# allow running tests against older nix versions via `nix eval --apply`
|
# allow running tests against older nix versions via `nix eval --apply`
|
||||||
|
|
@ -47,13 +49,13 @@ let
|
||||||
# nix build "$(nix eval --raw --impure .#hydraJobs.tests.fetch-git --apply 't: (t.forNix "2.19.2").drvPath')^*"
|
# nix build "$(nix eval --raw --impure .#hydraJobs.tests.fetch-git --apply 't: (t.forNix "2.19.2").drvPath')^*"
|
||||||
forNix =
|
forNix =
|
||||||
nixVersion:
|
nixVersion:
|
||||||
runNixOSTestFor system {
|
runNixOSTest {
|
||||||
imports = [ test ];
|
imports = [ test ];
|
||||||
defaults.nixpkgs.overlays = [
|
defaults.nixpkgs.overlays = [
|
||||||
(curr: prev: {
|
(curr: prev: {
|
||||||
nix =
|
nix =
|
||||||
let
|
let
|
||||||
packages = (builtins.getFlake "nix/${nixVersion}").packages.${system};
|
packages = (builtins.getFlake "nix/${nixVersion}").packages.${pkgs.system};
|
||||||
in
|
in
|
||||||
packages.nix-cli or packages.nix;
|
packages.nix-cli or packages.nix;
|
||||||
})
|
})
|
||||||
|
|
@ -97,18 +99,18 @@ let
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
authorization = runNixOSTestFor "x86_64-linux" ./authorization.nix;
|
authorization = runNixOSTest ./authorization.nix;
|
||||||
|
|
||||||
remoteBuilds = runNixOSTestFor "x86_64-linux" ./remote-builds.nix;
|
remoteBuilds = runNixOSTest ./remote-builds.nix;
|
||||||
|
|
||||||
remoteBuildsSshNg = runNixOSTestFor "x86_64-linux" ./remote-builds-ssh-ng.nix;
|
remoteBuildsSshNg = runNixOSTest ./remote-builds-ssh-ng.nix;
|
||||||
|
|
||||||
}
|
}
|
||||||
// lib.concatMapAttrs (
|
// lib.concatMapAttrs (
|
||||||
nixVersion:
|
nixVersion:
|
||||||
{ setNixPackage, ... }:
|
{ setNixPackage, ... }:
|
||||||
{
|
{
|
||||||
"remoteBuilds_remote_${nixVersion}" = runNixOSTestFor "x86_64-linux" {
|
"remoteBuilds_remote_${nixVersion}" = runNixOSTest {
|
||||||
name = "remoteBuilds_remote_${nixVersion}";
|
name = "remoteBuilds_remote_${nixVersion}";
|
||||||
imports = [ ./remote-builds.nix ];
|
imports = [ ./remote-builds.nix ];
|
||||||
builders.config =
|
builders.config =
|
||||||
|
|
@ -118,7 +120,7 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
"remoteBuilds_local_${nixVersion}" = runNixOSTestFor "x86_64-linux" {
|
"remoteBuilds_local_${nixVersion}" = runNixOSTest {
|
||||||
name = "remoteBuilds_local_${nixVersion}";
|
name = "remoteBuilds_local_${nixVersion}";
|
||||||
imports = [ ./remote-builds.nix ];
|
imports = [ ./remote-builds.nix ];
|
||||||
nodes.client =
|
nodes.client =
|
||||||
|
|
@ -128,7 +130,7 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
"remoteBuildsSshNg_remote_${nixVersion}" = runNixOSTestFor "x86_64-linux" {
|
"remoteBuildsSshNg_remote_${nixVersion}" = runNixOSTest {
|
||||||
name = "remoteBuildsSshNg_remote_${nixVersion}";
|
name = "remoteBuildsSshNg_remote_${nixVersion}";
|
||||||
imports = [ ./remote-builds-ssh-ng.nix ];
|
imports = [ ./remote-builds-ssh-ng.nix ];
|
||||||
builders.config =
|
builders.config =
|
||||||
|
|
@ -140,7 +142,7 @@ in
|
||||||
|
|
||||||
# FIXME: these tests don't work yet
|
# FIXME: these tests don't work yet
|
||||||
|
|
||||||
# "remoteBuildsSshNg_local_${nixVersion}" = runNixOSTestFor "x86_64-linux" {
|
# "remoteBuildsSshNg_local_${nixVersion}" = runNixOSTest {
|
||||||
# name = "remoteBuildsSshNg_local_${nixVersion}";
|
# name = "remoteBuildsSshNg_local_${nixVersion}";
|
||||||
# imports = [ ./remote-builds-ssh-ng.nix ];
|
# imports = [ ./remote-builds-ssh-ng.nix ];
|
||||||
# nodes.client = { lib, pkgs, ... }: {
|
# nodes.client = { lib, pkgs, ... }: {
|
||||||
|
|
@ -151,49 +153,49 @@ in
|
||||||
) otherNixes
|
) otherNixes
|
||||||
// {
|
// {
|
||||||
|
|
||||||
nix-copy-closure = runNixOSTestFor "x86_64-linux" ./nix-copy-closure.nix;
|
nix-copy-closure = runNixOSTest ./nix-copy-closure.nix;
|
||||||
|
|
||||||
nix-copy = runNixOSTestFor "x86_64-linux" ./nix-copy.nix;
|
nix-copy = runNixOSTest ./nix-copy.nix;
|
||||||
|
|
||||||
nix-docker = runNixOSTestFor "x86_64-linux" ./nix-docker.nix;
|
nix-docker = runNixOSTest ./nix-docker.nix;
|
||||||
|
|
||||||
nssPreload = runNixOSTestFor "x86_64-linux" ./nss-preload.nix;
|
nssPreload = runNixOSTest ./nss-preload.nix;
|
||||||
|
|
||||||
githubFlakes = runNixOSTestFor "x86_64-linux" ./github-flakes.nix;
|
githubFlakes = runNixOSTest ./github-flakes.nix;
|
||||||
|
|
||||||
gitSubmodules = runNixOSTestFor "x86_64-linux" ./git-submodules.nix;
|
gitSubmodules = runNixOSTest ./git-submodules.nix;
|
||||||
|
|
||||||
sourcehutFlakes = runNixOSTestFor "x86_64-linux" ./sourcehut-flakes.nix;
|
sourcehutFlakes = runNixOSTest ./sourcehut-flakes.nix;
|
||||||
|
|
||||||
tarballFlakes = runNixOSTestFor "x86_64-linux" ./tarball-flakes.nix;
|
tarballFlakes = runNixOSTest ./tarball-flakes.nix;
|
||||||
|
|
||||||
containers = runNixOSTestFor "x86_64-linux" ./containers/containers.nix;
|
containers = runNixOSTest ./containers/containers.nix;
|
||||||
|
|
||||||
setuid = lib.genAttrs [ "x86_64-linux" ] (system: runNixOSTestFor system ./setuid.nix);
|
setuid = runNixOSTest ./setuid.nix;
|
||||||
|
|
||||||
fetch-git = runNixOSTestFor "x86_64-linux" ./fetch-git;
|
fetch-git = runNixOSTest ./fetch-git;
|
||||||
|
|
||||||
ca-fd-leak = runNixOSTestFor "x86_64-linux" ./ca-fd-leak;
|
ca-fd-leak = runNixOSTest ./ca-fd-leak;
|
||||||
|
|
||||||
gzip-content-encoding = runNixOSTestFor "x86_64-linux" ./gzip-content-encoding.nix;
|
gzip-content-encoding = runNixOSTest ./gzip-content-encoding.nix;
|
||||||
|
|
||||||
functional_user = runNixOSTestFor "x86_64-linux" ./functional/as-user.nix;
|
functional_user = runNixOSTest ./functional/as-user.nix;
|
||||||
|
|
||||||
functional_trusted = runNixOSTestFor "x86_64-linux" ./functional/as-trusted-user.nix;
|
functional_trusted = runNixOSTest ./functional/as-trusted-user.nix;
|
||||||
|
|
||||||
functional_root = runNixOSTestFor "x86_64-linux" ./functional/as-root.nix;
|
functional_root = runNixOSTest ./functional/as-root.nix;
|
||||||
|
|
||||||
functional_symlinked-home = runNixOSTestFor "x86_64-linux" ./functional/symlinked-home.nix;
|
functional_symlinked-home = runNixOSTest ./functional/symlinked-home.nix;
|
||||||
|
|
||||||
user-sandboxing = runNixOSTestFor "x86_64-linux" ./user-sandboxing;
|
user-sandboxing = runNixOSTest ./user-sandboxing;
|
||||||
|
|
||||||
s3-binary-cache-store = runNixOSTestFor "x86_64-linux" ./s3-binary-cache-store.nix;
|
s3-binary-cache-store = runNixOSTest ./s3-binary-cache-store.nix;
|
||||||
|
|
||||||
fsync = runNixOSTestFor "x86_64-linux" ./fsync.nix;
|
fsync = runNixOSTest ./fsync.nix;
|
||||||
|
|
||||||
cgroups = runNixOSTestFor "x86_64-linux" ./cgroups;
|
cgroups = runNixOSTest ./cgroups;
|
||||||
|
|
||||||
fetchurl = runNixOSTestFor "x86_64-linux" ./fetchurl.nix;
|
fetchurl = runNixOSTest ./fetchurl.nix;
|
||||||
|
|
||||||
chrootStore = runNixOSTestFor "x86_64-linux" ./chroot-store.nix;
|
chrootStore = runNixOSTest ./chroot-store.nix;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, ... }:
|
{ lib, nixComponents, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
# FIXME (roberth) reference issue
|
# FIXME (roberth) reference issue
|
||||||
|
|
@ -49,11 +49,11 @@ in
|
||||||
|
|
||||||
cd ~
|
cd ~
|
||||||
|
|
||||||
cp -r ${pkgs.nixComponents2.nix-functional-tests.src} nix
|
cp -r ${nixComponents.nix-functional-tests.src} nix
|
||||||
chmod -R +w nix
|
chmod -R +w nix
|
||||||
|
|
||||||
chmod u+w nix/.version
|
chmod u+w nix/.version
|
||||||
echo ${pkgs.nixComponents2.version} > nix/.version
|
echo ${nixComponents.version} > nix/.version
|
||||||
|
|
||||||
export isTestOnNixOS=1
|
export isTestOnNixOS=1
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue