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

refind: make the build reproducible #318499

Merged
merged 1 commit into from
Jun 9, 2024
Merged

Conversation

raboof
Copy link
Member

@raboof raboof commented Jun 9, 2024

Description of changes

Avoid leaking build timestamps into the output.

/cc @AndersonTorres @samueldr @chewblacka

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.

Avoid leaking build timestamps into the output.
Copy link
Contributor

@drupol drupol left a comment

Choose a reason for hiding this comment

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

LGTM!

I guess you used a local patch because using the patch directly from upstream (SF) is not available.

@chewblacka
Copy link
Contributor

chewblacka commented Jun 9, 2024

LGTM

Current Master
Result of nix-build -A refind --check on current master:
error: derivation '/nix/store/nif8vnzh5j65s3hlzjf88ca9af0kfvag-refind-0.14.2.drv' may not be deterministic: output '/nix/store/sq3rgaih1cmkpdj8qwi636q6cjr1yplm-refind-0.14.2' differs

PR 318499
Result of nixpkgs-review pr 318499
1 package built: refind

Result of nix-build -A refind --check
No errors (i.e. build is reproducible).

@raboof
Copy link
Member Author

raboof commented Jun 9, 2024

I guess you used a local patch because using the patch directly from upstream (SF) is not available.

I haven't really checked, but since the MR isn't merged yet that commit is still at risk of being garbage-collected, so this is safer (as per #317314)

@raboof raboof merged commit a7d87b7 into NixOS:master Jun 9, 2024
29 of 30 checks passed
Copy link
Contributor

github-actions bot commented Jun 9, 2024

Successfully created backport PR for release-24.05:

@@ -34,6 +34,9 @@ stdenv.mkDerivation rec {
patches = [
# Removes hardcoded toolchain for aarch64, allowing successful aarch64 builds.
./0001-toolchain.patch
# Avoid leaking the build timestamp
# https://sourceforge.net/p/refind/code/merge-requests/53/
./reproducible.patch
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
./reproducible.patch
./0002-preserve-dates.patch

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, sorry, I had merged already but am happy to follow up.

Is the number prefix really useful? The ordering is already specified by the list of patches, having the ordering in the filenames as well just seems to make things messy when patches are added or removed later. On the other hand, indeed it seems somewhat common: about 500 of the 3700 patches in nixpkgs seem to be numbered that way.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you just need to use git format-patch IIRC.

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean, I can, but I'm not sure I understand the benefit.

(indeed preserve-dates might have been a better name though)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I don't really understand the benefits either.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, so it makes it easier to work with git am and rebase all patches in one go. Good to know - though indeed probably not universally necessary.

Copy link
Member

@samueldr samueldr Jun 9, 2024

Choose a reason for hiding this comment

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

We should prefer git format-patch patches all the time. Not for the filename, but for the additional metadata in its header, and tracking authorship information.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. Could y'all add those recommendations to https://github.com/NixOS/nixpkgs/tree/master/pkgs#patches ?

Copy link
Member

@SuperSandro2000 SuperSandro2000 Jun 9, 2024

Choose a reason for hiding this comment

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

We should prefer git format-patch patches all the time. Not for the filename, but for the additional metadata in its header, and tracking authorship information.

I wouldn't want to write that as a hard requirement. It doesn't work when changes are done on top of a downloaded tarball and we already have most of the metadata like who wrote it, when it was written and there should be a short comment above the patch why we need it. We then would also track frequently changing information like git version.

Also format-patch is meant for sending patches via mail.

Copy link
Member

Choose a reason for hiding this comment

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

My main concern with the numbering and the name is that patches are meant to be applied in sequence. (Sometimes patches can be applied unordered, but sometimes not.)
(Except maybe in Pijul, but I digress.)

Yes, lists in Nix are positional, but since sometimes the patch can be useful outside Nixpkgs - by a question of principle: we pick patches from other distros, and they can pick patches from us - it is a good idea to put an order on the patches.

P.S.: git-format-patch can be used outside git? Sometimes the patch comes from other VCSes...

raboof added a commit to raboof/nixpkgs that referenced this pull request Jun 10, 2024
@raboof raboof mentioned this pull request Jun 10, 2024
13 tasks
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nixos-reproducible-builds-minimal-installation-iso-successfully-independently-rebuilt/34756/9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Minimal ISO runtime
Development

Successfully merging this pull request may close these issues.

None yet

7 participants