From 04f91b59575ede2b230c3f563cc163c6014275e0 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sun, 10 Jan 2021 21:41:33 +0100 Subject: feat(users/Profpatsch): add script for randomly evaling nixpkgs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Running this after a codified refactor acts as a good smoke test, if a big subset of packages is broken or any central packages are broken, this should find them quite quickly, thanks to randomness™. Just let it run for a few minutes and check the errors that pop up. Change-Id: I1505dd31ca25b29254474a15cd6cb71d9743038a Reviewed-on: https://cl.tvl.fyi/c/depot/+/2346 Tested-by: BuildkiteCI Reviewed-by: Profpatsch Reviewed-by: lukegb --- users/Profpatsch/lib.nix | 2 +- users/Profpatsch/nixpkgs-rewriter/default.nix | 39 +++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 6 deletions(-) (limited to 'users/Profpatsch') diff --git a/users/Profpatsch/lib.nix b/users/Profpatsch/lib.nix index 8120a01d5b..69e6f73e40 100644 --- a/users/Profpatsch/lib.nix +++ b/users/Profpatsch/lib.nix @@ -12,7 +12,7 @@ let ]; eprintf = depot.nix.writeExecline "eprintf" {} [ - "fdmove" "-c" "1" "2" bins.printf "%s" "$@" + "fdmove" "-c" "1" "2" bins.printf "$@" ]; in { diff --git a/users/Profpatsch/nixpkgs-rewriter/default.nix b/users/Profpatsch/nixpkgs-rewriter/default.nix index ab86ff3209..286530b03f 100644 --- a/users/Profpatsch/nixpkgs-rewriter/default.nix +++ b/users/Profpatsch/nixpkgs-rewriter/default.nix @@ -8,6 +8,12 @@ let eprintf ; + bins = depot.nix.getBins pkgs.coreutils [ "head" "shuf" ] + // depot.nix.getBins pkgs.jq [ "jq" ] + // depot.nix.getBins pkgs.findutils [ "xargs" ] + // depot.nix.getBins pkgs.gnused [ "sed" ] + ; + export-json-object = pkgs.writers.writePython3 "export-json-object" {} '' import json import sys @@ -35,9 +41,9 @@ let "importas" "-ui" "file" "fileName" "importas" "-ui" "from" "fromLine" "importas" "-ui" "to" "toLine" - "if" [ eprintf "\${from}-\${to}" ] + "if" [ eprintf "%s-%s\n" "$from" "$to" ] (debugExec "adding lib") - "sed" + bins.sed "-e" "\${from},\${to} \${1}" "-i" "$file" ]; @@ -68,17 +74,40 @@ let ) do echo "replacing stdenv.lib meta in $file" >&2 - sed -e '/${metaString}/ s/stdenv.lib/lib/' \ + ${bins.sed} -e '/${metaString}/ s/stdenv.lib/lib/' \ -i "$file" ${add-lib-if-necessary} "$file" done ''; + instantiate-nixpkgs-randomly = writeExecline "instantiate-nixpkgs-randomly" { readNArgs = 1; } [ + "export" "NIXPKGS_ALLOW_BROKEN" "1" + "export" "NIXPKGS_ALLOW_UNFREE" "1" + "export" "NIXPKGS_ALLOW_INSECURE" "1" + "export" "NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM" "1" + "pipeline" [ + "nix" + "eval" + "--raw" + ''( + let pkgs = import ''${1} {}; + in builtins.toJSON (builtins.attrNames pkgs) + )'' + ] + "pipeline" [ bins.jq "-r" ".[]" ] + "pipeline" [ bins.shuf ] + "pipeline" [ bins.head "-n" "1000" ] + bins.xargs "-I" "{}" "-n1" + "if" [ eprintf "instantiating %s\n" "{}" ] + "nix-instantiate" "$1" "-A" "{}" + ]; + in { + inherit + instantiate-nixpkgs-randomly # requires hnix, which we don’t want in tvl for now # uncomment manually if you want to use it. - # inherit # meta-stdenv-lib # replace-stdenv-lib - # ; + ; } -- cgit 1.4.1