2024-06-03 18:00:48 +03:00
|
|
|
{ lib, nixpkgs, nixpkgsFor, self }:
|
2023-10-06 17:53:01 +03:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
nixos-lib = import (nixpkgs + "/nixos/lib") { };
|
|
|
|
|
|
|
|
# https://nixos.org/manual/nixos/unstable/index.html#sec-calling-nixos-tests
|
2023-12-29 10:15:16 +02:00
|
|
|
runNixOSTestFor = system: test:
|
|
|
|
(nixos-lib.runTest {
|
2024-06-16 17:40:20 +03:00
|
|
|
imports = [
|
|
|
|
test
|
|
|
|
|
|
|
|
# Add the quickBuild attribute to the check packages
|
|
|
|
./quick-build.nix
|
|
|
|
];
|
|
|
|
|
2023-12-29 10:15:16 +02:00
|
|
|
hostPkgs = nixpkgsFor.${system}.native;
|
|
|
|
defaults = {
|
|
|
|
nixpkgs.pkgs = nixpkgsFor.${system}.native;
|
|
|
|
nix.checkAllErrors = false;
|
|
|
|
};
|
|
|
|
_module.args.nixpkgs = nixpkgs;
|
|
|
|
_module.args.system = system;
|
|
|
|
})
|
|
|
|
// {
|
|
|
|
# allow running tests against older nix versions via `nix eval --apply`
|
|
|
|
# Example:
|
|
|
|
# nix build "$(nix eval --raw --impure .#hydraJobs.tests.fetch-git --apply 't: (t.forNix "2.19.2").drvPath')^*"
|
|
|
|
forNix = nixVersion: runNixOSTestFor system {
|
|
|
|
imports = [test];
|
|
|
|
defaults.nixpkgs.overlays = [(curr: prev: {
|
|
|
|
nix = (builtins.getFlake "nix/${nixVersion}").packages.${system}.nix;
|
|
|
|
})];
|
|
|
|
};
|
2023-10-06 17:53:01 +03:00
|
|
|
};
|
|
|
|
|
2024-01-22 19:34:52 +02:00
|
|
|
# Checks that a NixOS configuration does not contain any references to our
|
|
|
|
# locally defined Nix version.
|
|
|
|
checkOverrideNixVersion = { pkgs, lib, ... }: {
|
|
|
|
# pkgs.nix: The new Nix in this repo
|
|
|
|
# We disallow it, to make sure we don't accidentally use it.
|
2024-06-03 17:42:11 +03:00
|
|
|
system.forbiddenDependenciesRegexes = [
|
|
|
|
(lib.strings.escapeRegex "nix-${pkgs.nix.version}")
|
|
|
|
];
|
2024-01-22 19:34:52 +02:00
|
|
|
};
|
|
|
|
|
2024-06-03 18:26:16 +03:00
|
|
|
otherNixes.nix_2_3.setNixPackage = { lib, pkgs, ... }: {
|
|
|
|
imports = [ checkOverrideNixVersion ];
|
|
|
|
nix.package = lib.mkForce pkgs.nixVersions.nix_2_3;
|
2024-01-22 19:34:52 +02:00
|
|
|
};
|
|
|
|
|
2024-06-03 18:26:16 +03:00
|
|
|
otherNixes.nix_2_13.setNixPackage = { lib, pkgs, ... }: {
|
|
|
|
imports = [ checkOverrideNixVersion ];
|
|
|
|
nix.package = lib.mkForce (
|
|
|
|
self.inputs.nixpkgs-23-11.legacyPackages.${pkgs.stdenv.hostPlatform.system}.nixVersions.nix_2_13.overrideAttrs (o: {
|
|
|
|
meta = o.meta // { knownVulnerabilities = []; };
|
|
|
|
})
|
|
|
|
);
|
|
|
|
};
|
2024-01-22 19:34:52 +02:00
|
|
|
|
2024-06-03 18:33:38 +03:00
|
|
|
otherNixes.nix_2_18.setNixPackage = { lib, pkgs, ... }: {
|
|
|
|
imports = [ checkOverrideNixVersion ];
|
|
|
|
nix.package = lib.mkForce pkgs.nixVersions.nix_2_18;
|
|
|
|
};
|
|
|
|
|
2024-06-03 18:26:16 +03:00
|
|
|
in
|
2024-01-22 19:34:52 +02:00
|
|
|
|
2024-06-03 18:26:16 +03:00
|
|
|
{
|
|
|
|
authorization = runNixOSTestFor "x86_64-linux" ./authorization.nix;
|
2024-01-22 19:34:52 +02:00
|
|
|
|
2024-06-03 18:26:16 +03:00
|
|
|
remoteBuilds = runNixOSTestFor "x86_64-linux" ./remote-builds.nix;
|
2024-01-22 19:34:52 +02:00
|
|
|
|
2023-10-31 18:32:09 +02:00
|
|
|
remoteBuildsSshNg = runNixOSTestFor "x86_64-linux" ./remote-builds-ssh-ng.nix;
|
|
|
|
|
2024-06-03 18:26:16 +03:00
|
|
|
}
|
|
|
|
// lib.concatMapAttrs (
|
|
|
|
nixVersion: { setNixPackage, ... }:
|
|
|
|
{
|
|
|
|
"remoteBuilds_remote_${nixVersion}" = runNixOSTestFor "x86_64-linux" {
|
|
|
|
name = "remoteBuilds_remote_${nixVersion}";
|
|
|
|
imports = [ ./remote-builds.nix ];
|
|
|
|
builders.config = { lib, pkgs, ... }: {
|
|
|
|
imports = [ setNixPackage ];
|
|
|
|
};
|
2024-01-22 19:34:52 +02:00
|
|
|
};
|
|
|
|
|
2024-06-03 18:26:16 +03:00
|
|
|
"remoteBuilds_local_${nixVersion}" = runNixOSTestFor "x86_64-linux" {
|
|
|
|
name = "remoteBuilds_local_${nixVersion}";
|
|
|
|
imports = [ ./remote-builds.nix ];
|
|
|
|
nodes.client = { lib, pkgs, ... }: {
|
|
|
|
imports = [ setNixPackage ];
|
|
|
|
};
|
2024-01-22 19:34:52 +02:00
|
|
|
};
|
|
|
|
|
2024-06-03 18:26:16 +03:00
|
|
|
"remoteBuildsSshNg_remote_${nixVersion}" = runNixOSTestFor "x86_64-linux" {
|
|
|
|
name = "remoteBuildsSshNg_remote_${nixVersion}";
|
|
|
|
imports = [ ./remote-builds-ssh-ng.nix ];
|
|
|
|
builders.config = { lib, pkgs, ... }: {
|
|
|
|
imports = [ setNixPackage ];
|
|
|
|
};
|
2024-01-22 19:34:52 +02:00
|
|
|
};
|
|
|
|
|
2024-06-03 18:26:16 +03:00
|
|
|
# FIXME: these tests don't work yet
|
|
|
|
|
|
|
|
# "remoteBuildsSshNg_local_${nixVersion}" = runNixOSTestFor "x86_64-linux" {
|
|
|
|
# name = "remoteBuildsSshNg_local_${nixVersion}";
|
|
|
|
# imports = [ ./remote-builds-ssh-ng.nix ];
|
|
|
|
# nodes.client = { lib, pkgs, ... }: {
|
|
|
|
# imports = [ overridingModule ];
|
|
|
|
# };
|
|
|
|
# };
|
|
|
|
}
|
|
|
|
) otherNixes
|
|
|
|
// {
|
2024-01-22 19:34:52 +02:00
|
|
|
|
2023-10-06 17:53:01 +03:00
|
|
|
nix-copy-closure = runNixOSTestFor "x86_64-linux" ./nix-copy-closure.nix;
|
|
|
|
|
|
|
|
nix-copy = runNixOSTestFor "x86_64-linux" ./nix-copy.nix;
|
|
|
|
|
|
|
|
nssPreload = runNixOSTestFor "x86_64-linux" ./nss-preload.nix;
|
|
|
|
|
|
|
|
githubFlakes = runNixOSTestFor "x86_64-linux" ./github-flakes.nix;
|
|
|
|
|
2024-04-11 15:58:42 +03:00
|
|
|
gitSubmodules = runNixOSTestFor "x86_64-linux" ./git-submodules.nix;
|
|
|
|
|
2023-10-06 17:53:01 +03:00
|
|
|
sourcehutFlakes = runNixOSTestFor "x86_64-linux" ./sourcehut-flakes.nix;
|
|
|
|
|
|
|
|
tarballFlakes = runNixOSTestFor "x86_64-linux" ./tarball-flakes.nix;
|
|
|
|
|
|
|
|
containers = runNixOSTestFor "x86_64-linux" ./containers/containers.nix;
|
|
|
|
|
|
|
|
setuid = lib.genAttrs
|
2024-06-03 19:09:38 +03:00
|
|
|
["x86_64-linux"]
|
2023-10-06 17:53:01 +03:00
|
|
|
(system: runNixOSTestFor system ./setuid.nix);
|
2023-12-29 10:15:16 +02:00
|
|
|
|
|
|
|
fetch-git = runNixOSTestFor "x86_64-linux" ./fetch-git;
|
2024-02-12 22:28:20 +02:00
|
|
|
|
|
|
|
ca-fd-leak = runNixOSTestFor "x86_64-linux" ./ca-fd-leak;
|
2024-03-30 00:29:34 +02:00
|
|
|
|
|
|
|
gzip-content-encoding = runNixOSTestFor "x86_64-linux" ./gzip-content-encoding.nix;
|
2024-06-16 13:13:07 +03:00
|
|
|
|
|
|
|
functional_user = runNixOSTestFor "x86_64-linux" ./functional/as-user.nix;
|
|
|
|
|
|
|
|
functional_trusted = runNixOSTestFor "x86_64-linux" ./functional/as-trusted-user.nix;
|
|
|
|
|
|
|
|
functional_root = runNixOSTestFor "x86_64-linux" ./functional/as-root.nix;
|
|
|
|
|
2023-10-06 17:53:01 +03:00
|
|
|
}
|