Skip to content

multiple by-name directories - #206

Open
quantenzitrone wants to merge 8 commits into
NixOS:mainfrom
quantenzitrone:multi-by-name
Open

quantenzitrone wants to merge 8 commits into
NixOS:mainfrom
quantenzitrone:multi-by-name

Conversation

@quantenzitrone

@quantenzitrone quantenzitrone commented Mar 14, 2026 •

Copy link
Copy Markdown

Basically a new attempt at #31, but instead of adapting #180, i start from scratch because i wasn't able to rebase it.

The pr is supposed to be reviewed commit-by-commit.
There are 4 big relatively self-contained steps for this:

  1. refactoring const BASE_SUBPATH to function arguments
  2. making the attribute path to the checked packages (previously assumed to be [ ]) configurable
  3. adding a config file format to make the previous 2 changes actually applicable
  4. tests

cargo check --all-targets, cargo clippy --all-targets and cargo test should be happy after every commit.

I have test fork test branches of nixpkgs:

When vetting init with base base it succeeds.

When vetting fishPlugins-by-name with base init it fails because all the fish plugins don't use strictDeps and structuredAttrs.

When vetting fishPlugins wth base init it succeeds, because checks for non-by-name attributes are skipped for new package sets.

When vetting fishPlugins-by-name with base fishPlugins it succeeds.

Closes #180

@quantenzitrone
quantenzitrone force-pushed the multi-by-name branch 2 times, most recently from 6b0c568 to beb7817 Compare March 15, 2026 03:58
@quantenzitrone

This comment was marked as outdated.

@quantenzitrone
quantenzitrone force-pushed the multi-by-name branch 4 times, most recently from f9bea1e to 179e56c Compare September 29, 2026 20:03
@quantenzitrone
quantenzitrone force-pushed the multi-by-name branch 3 times, most recently from 2815e2b to 1969d8c Compare November 13, 2026 21:48
@quantenzitrone
quantenzitrone force-pushed the multi-by-name branch 8 times, most recently from bafbeff to 6a6ab6c Compare November 25, 2026 05:53
@quantenzitrone

quantenzitrone commented Nov 25, 2026 •

Copy link
Copy Markdown
Author

This is mostly done now, some things are still up for debate (especially how the config file should be done).

edit: moved the nixpkgs test branches to the pr description

@quantenzitrone quantenzitrone changed the title [WIP] multiple by-name directories multiple by-name directories Nov 25, 2026
@quantenzitrone
quantenzitrone marked this pull request as ready for review November 25, 2026 07:47
@quantenzitrone
quantenzitrone requested a review from a team as a code owner November 25, 2026 07:47
@mdaniels5757

Copy link
Copy Markdown
Member

I believe I've fixed the issue you mentioned in d97ae0f.

- Attribute `new1` is a new top-level package using `callPackage ... { /* ... */ }`.
- Attribute `fooPackages.new1` is a new package using `callPackage ... { /* ... */ }`.
Please define it in pkgs/sets/fooPackages/by-name/ne/new1/package.nix instead.
See `pkgs/by-name/README.md` for more details.

@mdaniels5757 mdaniels5757 Nov 25, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we be referencing pkgs/sets/fooPackages/by-name/README.md or similar instead? (Do/should we guarantee it exists?)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The workaround for a new non-by-name package would be the same, so i think its fine to refer to the pkgs/by-name README for now. Tho this could be changed later once stuff is in nixpkgs.

Comment thread .github/xrefcheck.yaml Resolved
@quantenzitrone
quantenzitrone force-pushed the multi-by-name branch 3 times, most recently from 204d8a6 to 580bf7f Compare November 26, 2026 00:34
Comment thread src/main.rs
Comment on lines +215 to 232
// ignore certain problems for new package sets
if new_package_sets
.iter()
.any(|x| x.attr_path == pkgset.attr_path)
{
other_package_result = other_package_result.map(|package_result_inner| {
package_result_inner
.into_iter()
.filter(|(_full_attr_path, package)| {
// skip checks for packages that don't use by-name
matches!(
package.uses_by_name,
ratchet::RatchetState::Tight | ratchet::RatchetState::NonApplicable
)
})
.collect()
});
}

@quantenzitrone quantenzitrone Nov 26, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I believe I've fixed the issue you mentioned in d97ae0f.

I fixed the issue in a different way: i just skip some checks for new package sets.
It's quite a lot simpler than what you (or your clanker) came up with.
I only saw your comment after I already finished implementing my changes.

What do you think?

@quantenzitrone quantenzitrone Nov 26, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

ok my current version breaks for aliases
kinda makes sense, aliases are never in by-name, thus RatchetState::Tight RatchetState::NonApplicable for uses_by_name

edit: fixed and added to test

@quantenzitrone
quantenzitrone force-pushed the multi-by-name branch 2 times, most recently from b7ce4d9 to 1a060d6 Compare November 26, 2026 00:51
There is not much more to what the commit message summary says.
This commit changes the function signatures and doc comments
throughout the codebase (where applicable) to include the subpath in
nixpkgs where the by-name directory resides.

This is the first step of making it possible to use multiple by-name
directories.
Simple rename of a function argument to avoid confusion with the argument
introduced in the next commit.
This replaces a lot of `attribute_name` or `package_name` function
arguments with `full_attr_path` and it adds `attr_path` to some
functions throughout the codebase.
- `attr_path` is the attribute path to the package set, so excluding
  the package name.
- `full_attr_path` is the attribute path to the package, so including
  the package name. Thus `full_attr_path` should never be empty.

This is the second step of making it possible to use multiple by-name
directories.

TODO: remove some commented out debugging code once the pr is ready for merge
The config file format is very simple for now: An attribute set with
`package_sets` as its only key, which is just a list of configs for a
by-name dir with its file path and attr path.

If there is no config file, a basic config with `pkgs/by-name` as a
top level package set is used to have the same behaviour as before
this PR.

When a new package set is added to the config file, all checks on
packages that don't use the by-name structure are ignored.
Because otherwise it would be really hard to migrate a package set.
Checks on packages in the by-name directory and basic checks e.g. that
the sharding structure is correct are still done.

This also adds NPV-180 which checks the parsability of the config file,
aswell as several tests for that NPV.

This also adds several tests that change which package sets are tracked
and validate the behaviour when adding or removing a package set.

Changes to consider:
- Make the config file a nix file and eval it to json before parsing it with
  serde. This would make it possble to dynamically configure directories based
  on patterns.
  e.g. all pkgs/sets/*/by-name are checked under the respective directory name
  attr path
- Different default config path (maybe with a . in front).
- A way to configure the config file path via command line options.

This is the third step of making it possible to use multiple by-name
directories.
This adds a non top-level by-name directory to every existing test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants