Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installShellFiles: rework and add installBin function #332612

Merged
merged 12 commits into from
Aug 29, 2024

Conversation

AndersonTorres
Copy link
Member

@AndersonTorres AndersonTorres commented Aug 6, 2024

Description of changes

nawk for testing purposes

The rationales of this PR are better understood by reading the commit messages, but an executive resume is:

  • migrate to by-name
  • create a test directory instead of a test file
  • new function installBin

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@AndersonTorres
Copy link
Member Author

AndersonTorres commented Aug 6, 2024

@afh I have taken your bump to make a test here. Can you review it?
Edit: forget it, I removed this since it caused a mass-rebuild.

@AndersonTorres AndersonTorres force-pushed the rework-installShellFiles branch 4 times, most recently from 4d20c7e to ab65482 Compare August 24, 2024 13:00
@AndersonTorres AndersonTorres marked this pull request as ready for review August 24, 2024 17:54
@AndersonTorres AndersonTorres force-pushed the rework-installShellFiles branch 2 times, most recently from 381286f to 55d3c48 Compare August 28, 2024 12:08
So that it can be migrated to by-name later.
Rationale: Since RFCs 140 and 146, the old category-based hierarchy is
deprecated and obsolete, and a new approach took place: packages should be as
self-contained as possible.

This paradigm is reflected in many new strict checks that prohibit a package to
refer to files outside its directory tree.

Following this spirit, this commit essentially moves nixpkgs
pkgs/test/default.nix to ./tests/default.nix.

Further, to keep the top-level `tests` attribute, a green alias is kept in the
place of older file.
It makes the maintenance and creation of tests more intuitive: just throw a Nix
package under tests!
- Use FUNCNAME to track the name of function being called
- use long options for install commands
- use nix*Log functions for logging, instead of custom echoes
- remove silent error construction `|| return`
Copy link
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

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

I intend to merge after doing a set of sample builds.

@AndersonTorres
Copy link
Member Author

AndersonTorres commented Aug 29, 2024

@philiptaron you commented about using testEqualContent. However, from what I have seen, it does test singular files, not directory trees. So I prefer to keep it as is.


@infinisil i want to ask your opinion about a specific decision.

As I have written in f72e74d:

Rationale: Since RFCs 140 and 146, the old category-based hierarchy is
deprecated and obsolete, and a new approach took place: packages should be as
self-contained as possible.

This paradigm is reflected in many new strict checks that prohibit a package to
refer to files outside its directory tree.

Following this spirit, this commit essentially moves nixpkgs
pkgs/test/default.nix to ./tests/default.nix.

What do you think? Is this a good approach?

@infinisil
Copy link
Member

What do you think? Is this a good approach?

That looks great to me, nice work!

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

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

This is well done commit history! I very briefly looked through the changes, LGTM!

Comment on lines +10 to +14
passthru = {
tests = lib.packagesFromDirectoryRecursive {
inherit callPackage;
directory = ./tests;
};
Copy link
Member

Choose a reason for hiding this comment

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

This is not worth addressing here, but note that this has a minor problem: Due to packagesFromDirectoryRecursive recursing for directories, a standard nix-build -A installShellFiles.tests wouldn't run any nested ones, because nix-build doesn't recurse more than one level. In my experience, recursive attribute sets give rise to various such oddities, which is why I recommend avoiding them. Cc @philiptaron

Copy link
Contributor

Choose a reason for hiding this comment

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

Good to know! There is likely need then for a simple non-recursive variant for these flat use cases.

@philiptaron philiptaron merged commit 166ba20 into NixOS:staging Aug 29, 2024
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants