compat nixpkgs and change to testing-python.nix

This commit is contained in:
GTrunSec 2021-04-03 22:37:13 -07:00
parent 842c903201
commit 8f0e518bc0
No known key found for this signature in database
GPG key ID: 2368FAFA4ABDD2A0
3 changed files with 36 additions and 9 deletions

17
lib/compat.nix Normal file
View file

@ -0,0 +1,17 @@
let
inherit (builtins)
fetchTarball
fromJSON
readFile
;
lockfile = fromJSON (readFile ../flake.lock);
in
input:
let
locked = lockfile.nodes."${input}".locked;
inherit (locked) rev narHash owner repo;
in
fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
sha256 = narHash;
}

View file

@ -7,7 +7,7 @@ let
toJSONFile = content: builtins.toFile "json" (builtins.toJSON content); toJSONFile = content: builtins.toFile "json" (builtins.toJSON content);
nixosTesting = import "${nixosPath}/lib/testing.nix" { nixosTesting = import "${nixosPath}/lib/testing-python.nix" {
inherit pkgs; inherit pkgs;
system = "x86_64-linux"; system = "x86_64-linux";
}; };

View file

@ -1,5 +1,12 @@
{ pkgs ? import <nixpkgs> {}, nixosPath ? toString <nixpkgs/nixos>, lib ? pkgs.lib let
, e2e ? true, throwError ? true }: fetch = import ./lib/compat.nix;
in
{ pkgs ? import (fetch "nixpkgs") { }
, nixosPath ? toString (fetch "nixpkgs") + "/nixos"
, lib ? pkgs.lib
, e2e ? true
, throwError ? true
}:
with lib; with lib;
@ -23,7 +30,8 @@ let
runK8STests = k8sVersion: import ./tests { runK8STests = k8sVersion: import ./tests {
inherit pkgs lib kubenix k8sVersion e2e throwError nixosPath; inherit pkgs lib kubenix k8sVersion e2e throwError nixosPath;
}; };
in rec { in
rec {
generate.k8s = pkgs.linkFarm "k8s-generated.nix" [ generate.k8s = pkgs.linkFarm "k8s-generated.nix" [
{ {
name = "v1.8.nix"; name = "v1.8.nix";
@ -130,15 +138,17 @@ in rec {
k8s-1_18 = runK8STests "1.18"; k8s-1_18 = runK8STests "1.18";
}; };
test-results = pkgs.recurseIntoAttrs (mapAttrs (_: t: pkgs.recurseIntoAttrs { test-results = pkgs.recurseIntoAttrs (mapAttrs
results = pkgs.recurseIntoAttrs t.results; (_: t: pkgs.recurseIntoAttrs {
result = t.result; results = pkgs.recurseIntoAttrs t.results;
}) tests); result = t.result;
})
tests);
test-check = test-check =
if !(all (test: test.success) (attrValues tests)) if !(all (test: test.success) (attrValues tests))
then throw "tests failed" then throw "tests failed"
else true; else true;
examples = import ./examples {}; examples = import ./examples { };
} }