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

applyPatches: skip creating additional drv when no patches #236370

Merged
merged 1 commit into from
Jan 13, 2024

Conversation

amarshall
Copy link
Member

@amarshall amarshall commented Jun 6, 2023

Description of changes

If there are no patches or postPatch, then this will just do work to make something equivalent to src. Instead, just return src in that case.

There are a few instances in nixpkgs where the patches to applyPatches is dynamic, and may be empty, so this optimizes those. It also removes the want to remove applyPatches as an optimization just because the patches are empty when it may semantically make sense to keep it (because e.g. patches to mkDerivation doesn’t work as expected).

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • 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/)
  • 23.11 Release Notes (or backporting 23.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.

@amarshall amarshall mentioned this pull request Jun 6, 2023
12 tasks
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Jun 7, 2023
@amarshall amarshall force-pushed the applypatches-nopatches branch 2 times, most recently from 5c65778 to c591958 Compare June 9, 2023 22:02
@@ -48,7 +48,7 @@ let
desktop-native = rustPlatform.buildRustPackage {
pname = "bitwarden-desktop-native";
inherit src version;
sourceRoot = "source-patched/apps/desktop/desktop_native";
sourceRoot = "${src.name}/apps/desktop/desktop_native";
Copy link
Member

Choose a reason for hiding this comment

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

Having to change this is probably a disadvantage.

Copy link
Member Author

@amarshall amarshall Jun 15, 2023

Choose a reason for hiding this comment

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

I actually think this is better because it doesn’t couple to the implementation of name in src. FWIW there are already 80+ instances matching the regex sourceRoot = .*src\.name in Nix files in nixpkgs, and this was the only instance of source-patched in all of nixpkgs.

Copy link
Member

Choose a reason for hiding this comment

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

I think the main problem I have with this PR is the unintended name change when no patches are supplied

Copy link
Member Author

@amarshall amarshall Jul 11, 2023

Choose a reason for hiding this comment

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

Could you elaborate a bit on the concern? Is it that it may cause unforseen breakage upon merge? Confuse future users? Something else?

Tbh, I would be for a tree-wide (plus doc) change from sourceRoot = "source/…"sourceRoot = "${src.name}/…" because, tbh, I was flummoxed for a while upon initially using applyPatches why the sourceRoot wasn’t working anymore. If it had always been used ${src.name} instead of source it would have just worked. Alternatively could change the name in applyPatches… I don’t really have a strong opinion either way.

Copy link
Member

Choose a reason for hiding this comment

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

Is it that it may cause unforseen breakage upon merge? Confuse future users?

yes and yes


I don't, please ask in nixos-dev on matrix

Copy link
Member Author

Choose a reason for hiding this comment

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

So looks like sourceRoot = "${src.name}…" is now the preferred way #245388

@SuperSandro2000
Copy link
Member

Can you also check mastodon and proxysql?

@ofborg build mastodon proxysql

@amarshall amarshall force-pushed the applypatches-nopatches branch from c591958 to cfa559c Compare June 22, 2023 02:55
@amarshall
Copy link
Member Author

amarshall commented Jun 22, 2023

@SuperSandro2000 I rebased off latest master, resolved conflicts, built mastodon and proxysql successfully (locally, ofborg seemed to never build them, sat queued forever), and compared them both with diffoscope vs. master builds and the only differences were store path hashes.

@ofborg ofborg bot requested a review from Kiwi June 22, 2023 03:14
@ofborg ofborg bot added the 11.by: package-maintainer This PR was created by the maintainer of the package it changes label Jun 22, 2023
@amarshall amarshall force-pushed the applypatches-nopatches branch from cfa559c to 0d3c6d3 Compare July 11, 2023 22:01
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 10.rebuild-darwin: 1 and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin labels Jul 11, 2023
@amarshall amarshall force-pushed the applypatches-nopatches branch from 0d3c6d3 to 9e392b0 Compare August 6, 2023 16:30
Copy link
Member

@oxij oxij left a comment

Choose a reason for hiding this comment

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

I also noticed this and wanted to remove it in bitwarden, so this would be nice.

@amarshall amarshall removed the 11.by: package-maintainer This PR was created by the maintainer of the package it changes label Aug 28, 2023
@wegank wegank added the 12.approvals: 2 This PR was reviewed and approved by two reputable people label Sep 7, 2023
@amarshall amarshall force-pushed the applypatches-nopatches branch from 9e392b0 to 4c9371a Compare December 16, 2023 13:54
@RaitoBezarius
Copy link
Member

@amarshall Apparently, there's some conflicts (?).

If there are no `patches` or `postPatch`, then this will just do work to
make something equivalent to `src`. Instead, just return `src` in that
case.
@amarshall
Copy link
Member Author

@RaitoBezarius rebased and resolved conflicts—was trivial formatting. Also:

  • Verified build of random pkgs that use applyPatches (mastodon,proxysql,zammad)
  • Confirmed using applyPatches with patches = [ ] on hello results in identical drv and no rebuild
  • Minor formatting change
  • Added back explanatory comment that was requested in an earlier review and I think got lost during a previous conflict resolution

@amarshall amarshall force-pushed the applypatches-nopatches branch from 4c9371a to 52c2735 Compare January 12, 2024 20:50
@RaitoBezarius RaitoBezarius merged commit 41aa423 into NixOS:master Jan 13, 2024
18 checks passed
@amarshall amarshall deleted the applypatches-nopatches branch April 7, 2024 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants