Skip to content

Commit

Permalink
try ofborg eval
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 committed Nov 1, 2024
1 parent 9f8dd89 commit 8b991d2
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 11 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/eval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [x86_64-linux, aarch64-linux, aarch64-darwin, x86_64-darwin]
system: [x86_64-linux, aarch64-linux, aarch64-darwin, x86_64-darwin]
steps:
- name: Set up Git
run: |
Expand Down Expand Up @@ -73,8 +73,16 @@ jobs:
- uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 # v30
if: env.is_pr == 'true'

- name: Enable swap
if: env.is_pr == 'true'
run: |
sudo fallocate -l 10G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
- name: Check eval
if: env.is_pr == 'true'
run: |
cd nixpkgs
./ci/eval-nixpkgs.sh --system "$system"
./ci/eval-nixpkgs.sh --system "{{matrix.system}}
19 changes: 10 additions & 9 deletions ci/eval-nixpkgs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
set -euxo pipefail

system="x86_64-linux"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
NIXPKGS_PATH="$(readlink -f $SCRIPT_DIR/..)"

parseArgs() {
while [[ $# -gt 0 ]]; do
Expand All @@ -25,14 +27,13 @@ main() {
trap 'rm -rf "$tmpdir"' EXIT
(
set +e
nix-env -f . \
-qa \* \
--meta \
--xml \
--drv-path \
--show-trace \
--eval-system "$system" \
> "$tmpdir/store-path"
nix-env \
--arg "supportedSystems" "[\"$system\"]" \
-qaP --no-name \
--out-path \
--arg checkMeta true \
--argstr path "$NIXPKGS_PATH" \
-f "$SCRIPT_DIR/outpaths.nix" > "$tmpdir/paths"
echo $? > "$tmpdir/exit-code"
) &
pid=$!
Expand All @@ -43,4 +44,4 @@ main() {
exit "$(cat "$tmpdir/exit-code")"
}

main
main "$@"
72 changes: 72 additions & 0 deletions ci/outpaths.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env nix-shell
# When using as a callable script, passing `--argstr path some/path` overrides $PWD.
#!nix-shell -p nix -i "nix-env -qaP --no-name --out-path --arg checkMeta true --argstr path $PWD -f"
{
checkMeta,
path ? ./..,
supportedSystems ? [
"aarch64-linux"
"aarch64-darwin"
"x86_64-linux"
"x86_64-darwin"
],
}:
let
lib = import (path + "/lib");
hydraJobs =
import (path + "/pkgs/top-level/release.nix")
# Compromise: accuracy vs. resources needed for evaluation.
{
inherit supportedSystems;

nixpkgsArgs = {
config = {
allowAliases = false;
allowBroken = true;
allowUnfree = true;
allowInsecurePredicate = x: true;
checkMeta = checkMeta;

handleEvalIssue =
reason: errormsg:
let
fatalErrors = [
"unknown-meta"
"broken-outputs"
];
in
if builtins.elem reason fatalErrors then abort errormsg else true;

inHydra = true;
};
};
};
recurseIntoAttrs = attrs: attrs // { recurseForDerivations = true; };

# hydraJobs leaves recurseForDerivations as empty attrmaps;
# that would break nix-env and we also need to recurse everywhere.
tweak = lib.mapAttrs (
name: val:
if name == "recurseForDerivations" then
true
else if lib.isAttrs val && val.type or null != "derivation" then
recurseIntoAttrs (tweak val)
else
val
);

# Some of these contain explicit references to platform(s) we want to avoid;
# some even (transitively) depend on ~/.nixpkgs/config.nix (!)
blacklist = [
"tarball"
"metrics"
"manual"
"darwin-tested"
"unstable"
"stdenvBootstrapTools"
"moduleSystem"
"lib-tests" # these just confuse the output
];

in
tweak (builtins.removeAttrs hydraJobs blacklist)

0 comments on commit 8b991d2

Please sign in to comment.