Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,7 @@ jobs:
- uses: serokell/xrefcheck-action@v1
with: # Invalid symlinks for testing purposes.
xrefcheck-args: >
--ignore tests/symlink-invalid/main/pkgs/by-name/fo/foo/foo
--ignore tests/multiple-failures/main/pkgs/by-name/A/fo@/foo
--ignore tests/top-level/symlink-invalid/main/pkgs/by-name/fo/foo/foo
--ignore tests/top-level/multiple-failures/main/pkgs/by-name/A/fo@/foo
--ignore tests/tcl/multiple-failures/main/pkgs/development/tcl-modules/by-name/A/fo@/foo
--ignore tests/tcl/symlink-invalid/main/pkgs/development/tcl-modules/by-name/fo/foo/foo
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
target
.direnv
result*
by-name-config-generated.json
168 changes: 168 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ textwrap = "0.16.2"
derive-enum-from-into = "0.2.1"
derive-new = "0.7.0"
derive_more = { version = "2.0.1", features = ["display"] }
readonly = "0.2.13"

[dev-dependencies]
fixtures = "2.4.0"
pretty_assertions = "1.4.1"
temp-env = "0.3.6"
37 changes: 37 additions & 0 deletions by-name-config.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Configure by-name directories in this file.
# Then build with `nix-build -A build` to automatically generate by-name-config-generated.json
# (Or, to generate manually, `nix-instantiate --eval --json --strict by-name-config.nix > by-name-config-generated.json`)
# In the attrsets that make up by_name_dirs:
# * The aliases_path field is optional.
# * The ID field must be short and unique.
# * Exactly one attr_path_regex must be a wildcard ("^[^\\.]*$").
# * All non-wildcard attr_path_regexes must be mutually exclusive.
# * Exactly one unversioned_attr_prefix must be the empty string.
# * All non-wildcard unversioned_attr_prefixes must be mutually exclusive.
{
by_name_dirs = [
{
id = "py";
path = "pkgs/development/python-modules/by-name";
attr_path_regex = "^(python3\\d*Packages|python3\\d*.pkgs)\\..*$";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The biggest issue with how it's done currently closely relates to this here. As far as I understand, the new eval.nix/eval.rs does a recursive Nixpkgs evaluation, lists all resulting attribute paths and then checks which ones match the regex defined here.

This complicates the eval.nix because it needs to handle all the random failing evaluations in Nixpkgs, making it very brittle and slow.

Instead, please change this configuration options to be like suggested in #31:

attr_path = [ "python3Packages" ];

Notably we don't need to check all the different version sets like python311Packages, etc., because the only reason we need to evaluate anything at all is for the eval-time checks and ratchet checks. Since all the python3*Packages sets only differ in very minor ways, checking one of them is good enough. This will be much more efficient and simplify the code a lot.

On the implementation side, the code then only needs to evaluate the attributes directly under that attribute path, just like the eval.nix in the main branch (I'm afraid a lot of your eval.nix changes won't be needed 😅) . I also recommend changing what eval.nix outputs to be more suited to the new functionality, e.g. something like

{
  py = [ [ name value ] ... ];
  main = [ [ name value ] ... ];
  tcl = [ [ name value ] ... ];
}

This should make the diff to what it was fairly small.

unversioned_attr_prefix = "python3Packages";
all_packages_path = "/pkgs/top-level/python-packages.nix";
aliases_path = "/pkgs/top-level/python-aliases.nix";
}
{
id = "tcl";
path = "pkgs/development/tcl-modules/by-name";
attr_path_regex = "^(tcl\\d*Packages)\\..*$";
unversioned_attr_prefix = "tclPackages";
all_packages_path = "/pkgs/top-level/tcl-packages.nix";
}
{
id = "main";
path = "pkgs/by-name";
attr_path_regex = "^[^\\.]*$";
unversioned_attr_prefix = "";
all_packages_path = "/pkgs/top-level/all-packages.nix";
aliases_path = "/pkgs/top-level/aliases.nix";
}
];
}
11 changes: 10 additions & 1 deletion nixpkgs-check.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
runCommand,
nixpkgs-vet,
initNix,
writeText,
nixpkgs,
nix,
nixVersions,
Expand All @@ -20,6 +21,10 @@ let
eval.success && lib.isDerivation eval.value
) attrset;

configFile = writeText "by-name-config-generated.json" (
builtins.toJSON (import ./by-name-config.nix)
);

mkNixpkgsCheck =
name: nix:
runCommand "test-nixpkgs-vet-with-${nix.name}"
Expand All @@ -29,7 +34,10 @@ let
nix
];

env.NIXPKGS_VET_NIX_PACKAGE = lib.getBin nix;
env = {
NIXPKGS_VET_NIX_PACKAGE = lib.getBin nix;
NIXPKGS_VET_CONFIG_FILE = configFile;
};

passthru = {
# Allow running against all other Nix versions.
Expand All @@ -46,6 +54,7 @@ let
${initNix}
# This is what nixpkgs-vet uses
export NIXPKGS_VET_NIX_PACKAGE=${lib.getBin nix}
export NIXPKGS_VET_CONFIG_FILE=${configFile}
${nixpkgs-vet}/bin/.nixpkgs-vet-wrapped --base "${nixpkgs}" "${nixpkgs}"
touch $out
'';
Expand Down
Loading
Loading