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

nixos-rebuild: cleanup #368364

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

zimbatm
Copy link
Member

@zimbatm zimbatm commented Dec 26, 2024

The script is pretty hairy and needed some cleanup. There is nixos-rebuild-ng, but I think nixos-rebuild will still be around for a bit to make those changes worthwhile.

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/)
  • 25.05 Release Notes (or backporting 24.11 and 25.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.

nixos-rebuild is *not* os-specific. It's possible to call it on macOS
with --target-host for example.

This change brings it closer to nixos-rebuild-ng to make synchronization
easier.
Make it slightly more readable
Simplify the script by only using Bash tests instead of a mixture
of bash [[ ]] and POSIX [ ] tests.

In general, Bash tests are a safer superset as they have less variable
escaping issues (eg: [[ -z $foo ]] is fine).
Copy link
Member

@trueNAHO trueNAHO Dec 26, 2024

Choose a reason for hiding this comment

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

Run if result/bin/nixpkgs-vet --base "$base" .; then
- pkgs/by-name/ni/nixos-rebuild: File package.nix at line 18 contains the path expression "./../../../../nixos/modules/installer/tools/nix-fallback-paths.nix" which may point outside the directory of that package.
  This is undesirable because it creates dependencies between internal paths, making it harder to reorganise Nixpkgs in the future.
  Alternatives include:
  - If you are creating a new version of a package with a common file between versions, consider following the recommendation in https://github.com/NixOS/nixpkgs/tree/master/pkgs/by-name#recommendation-for-new-packages-with-multiple-versions.
  - If the path being referenced could be considered a stable interface with multiple uses, consider exposing it via a `pkgs` attribute, then taking it as a attribute argument in package.nix.
  - If the path being referenced is internal and has multiple uses, consider passing the file as an explicit `callPackage` argument in `pkgs/top-level/all-packages.nix`.
  - If the path being referenced is internal and will need to be modified independently of the original, consider copying it into the pkgs/by-name/ni/nixos-rebuild directory.

This PR introduces the problems listed above. Please fix them before merging, otherwise the base branch would break.
To run locally: ./ci/nixpkgs-vet.sh master https://github.com/NixOS/nixpkgs.git
If you're having trouble, ping @NixOS/nixpkgs-vet
Error: Process completed with exit code 1.

-- https://github.com/NixOS/nixpkgs/actions/runs/12505685594/job/34889420432?pr=368364

Consider replacing

fallback = import ./../../../../nixos/modules/installer/tools/nix-fallback-paths.nix;

with:

  fallback = import "${nixpkgs}/nixos/modules/installer/tools/nix-fallback-paths.nix";

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.

2 participants