From 9ce251120626575222db54bb8ae2233a101f01f0 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 25 Jan 2022 00:02:48 +0100 Subject: [PATCH] Add regression / performance tests against a fixed revision of Nixpkgs --- flake.lock | 18 +++++++++++++++++- flake.nix | 33 ++++++++++++++------------------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index 861af1c54..61eccb73c 100644 --- a/flake.lock +++ b/flake.lock @@ -31,10 +31,26 @@ "type": "indirect" } }, + "nixpkgs-regression": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "indirect" + } + }, "root": { "inputs": { "lowdown-src": "lowdown-src", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "nixpkgs-regression": "nixpkgs-regression" } } }, diff --git a/flake.nix b/flake.nix index 9bfa36fdf..a6a3d290d 100644 --- a/flake.nix +++ b/flake.nix @@ -2,9 +2,10 @@ description = "The purely functional package manager"; inputs.nixpkgs.url = "nixpkgs/nixos-21.05-small"; + inputs.nixpkgs-regression.url = "nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2"; inputs.lowdown-src = { url = "github:kristapsdz/lowdown"; flake = false; }; - outputs = { self, nixpkgs, lowdown-src }: + outputs = { self, nixpkgs, nixpkgs-regression, lowdown-src }: let @@ -518,29 +519,23 @@ inherit (self) overlay; }); - /* - # Check whether we can still evaluate all of Nixpkgs. + # Make sure that nix-env still produces the exact same result + # on a particular version of Nixpkgs. tests.evalNixpkgs = - import (nixpkgs + "/pkgs/top-level/make-tarball.nix") { - # FIXME: fix pkgs/top-level/make-tarball.nix in NixOS to not require a revCount. - inherit nixpkgs; - pkgs = nixpkgsFor.x86_64-linux; - officialRelease = false; - }; - - # Check whether we can still evaluate NixOS. - tests.evalNixOS = with nixpkgsFor.x86_64-linux; runCommand "eval-nixos" { buildInputs = [ nix ]; } '' - export NIX_STATE_DIR=$TMPDIR - - nix-instantiate ${nixpkgs}/nixos/release-combined.nix -A tested --dry-run \ - --arg nixpkgs '{ outPath = ${nixpkgs}; revCount = 123; shortRev = "abcdefgh"; }' - - touch $out + type -p nix-env + # Note: we're filtering out nixos-install-tools because https://github.com/NixOS/nixpkgs/pull/153594#issuecomment-1020530593. + time nix-env --store dummy:// -f ${nixpkgs-regression} -qaP --drv-path | sort | grep -v nixos-install-tools > packages + [[ $(sha1sum < packages | cut -c1-40) = ff451c521e61e4fe72bdbe2d0ca5d1809affa733 ]] + mkdir $out ''; - */ + + metrics.nixpkgs = import "${nixpkgs-regression}/pkgs/top-level/metrics.nix" { + pkgs = nixpkgsFor.x86_64-linux; + nixpkgs = nixpkgs-regression; + }; installTests = forAllSystems (system: let pkgs = nixpkgsFor.${system}; in