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

treewide: inject xdg-open into wrappers as $PATH suffix #181171

Merged
merged 2 commits into from
Aug 19, 2022

Conversation

ehmry
Copy link
Contributor

@ehmry ehmry commented Jul 11, 2022

Description of changes

The xdg-open utility is only ever a runtime dependency and its
dependents only expect that it accept a URI as a command line
argument and do something with it that the user would expect.
For such as a trivial relationship it should be possible for
users to override xdg-open with something else in their PATH.


I don't know anyone that knows what xdg-open does but hasn't also replaced it with a shell script.

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/)
  • 22.11 Release Notes (or backporting 22.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
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/prs-ready-for-review/3032/1072

@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 7, 2022
@LunNova
Copy link
Member

LunNova commented Aug 16, 2022

This is great! It makes a fix for #160923 a lot less intrusive as you can just provide a better xdg-open on the path instead of rebuilding everything.

kira-bruneau
kira-bruneau previously approved these changes Aug 16, 2022
Copy link
Contributor

@kira-bruneau kira-bruneau left a comment

Choose a reason for hiding this comment

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

This looks great! There are some merge conflicts to deal with since this was submitted, but I think it would be ok to merge after that.

@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/should-we-support-encoding-runtime-dependencies-without-requiring-a-specific-implementation/21031/6

@bobby285271 bobby285271 added the 12.approvals: 2 This PR was reviewed and approved by two reputable people label Aug 17, 2022
@SuperSandro2000
Copy link
Member

I think we should accompany this by a contributing guide change to prefix such tools.

@kira-bruneau kira-bruneau dismissed their stale review August 17, 2022 13:40

Merge conflicts need to be resolved & contributing guide should be updated

@kira-bruneau kira-bruneau removed the 12.approvals: 2 This PR was reviewed and approved by two reputable people label Aug 17, 2022
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 18, 2022
@ehmry
Copy link
Contributor Author

ehmry commented Aug 18, 2022

(FWIW, my xdg-open replacement.)

@github-actions github-actions bot added the 8.has: documentation This PR adds or changes documentation label Aug 18, 2022
@ehmry ehmry requested a review from kira-bruneau August 18, 2022 13:31
@LunNova LunNova mentioned this pull request Aug 18, 2022
13 tasks
Copy link
Contributor

@kira-bruneau kira-bruneau left a comment

Choose a reason for hiding this comment

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

I think the docs should be good with @fricklerhandwerk's suggestions. I also noticed though that there are still a few other places where we should suffix xdg-utils:

  • pkgs/applications/audio/bitwig-studio/bitwig-studio1.nix
  • pkgs/applications/audio/bitwig-studio/bitwig-studio3.nix
  • pkgs/applications/misc/avrdudess/default.nix
  • pkgs/applications/misc/fff/default.nix
  • pkgs/applications/networking/browsers/brave/default.nix
  • pkgs/applications/networking/browsers/google-chrome/default.nix
  • pkgs/applications/networking/browsers/offpunk/default.nix
  • pkgs/applications/networking/instant-messengers/armcord/default.nix
  • pkgs/applications/office/jabref/default.nix
  • pkgs/applications/version-management/sparkleshare/default.nix
  • pkgs/tools/admin/aws-sso-cli/default.nix
  • pkgs/tools/bluetooth/blueman/default.nix

Most of these are places where the wrapper is created indirectly through some other variable that includes xdg-utils, but some of them are just new updates to packages since this was started.

@kira-bruneau
Copy link
Contributor

kira-bruneau commented Aug 18, 2022

Also to fit CONTRIBUTING.md, the first commit should be renamed to: treewide: inject xdg-open into wrappers as a suffix to PATH

@ehmry
Copy link
Contributor Author

ehmry commented Aug 18, 2022

I've fixed the packages that @kira-bruneau found.

@LunNova
Copy link
Member

LunNova commented Aug 18, 2022

Steam FHS does this too but it's fine to leave it out of this change as it has some indirection, probably better to be in a separate PR.

@ehmry
Copy link
Contributor Author

ehmry commented Aug 18, 2022

I don't want to touch the FHS or appimage stuff, that should be a different PR.

@ehmry ehmry changed the title Inject xdg-open into wrappers as a suffix to PATH treewide: inject xdg-open into wrappers as $PATH suffix Aug 18, 2022
@LunNova
Copy link
Member

LunNova commented Aug 18, 2022

I'll try to do it for steam.

pkgs/applications/misc/fff/default.nix Outdated Show resolved Hide resolved
@@ -102,7 +102,6 @@ in stdenv.mkDerivation rec {
glxinfo
gnugrep
gnused
xdg-utils
Copy link
Contributor

@kira-bruneau kira-bruneau Aug 19, 2022

Choose a reason for hiding this comment

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

The ./hardcode-dependencies.patch file will have to be updated to account for this change. I can take a look at this since I maintain mangohud.

Copy link
Contributor

@kira-bruneau kira-bruneau Aug 19, 2022

Choose a reason for hiding this comment

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

Hmm wait, yeah the reason I hard-code these dependencies is because the library needs them, and mangohud can be enabled independently from the executable with MANGOHUD=1.

I think for now we should just leave this unchanged, I'll try to figure out a better solution for another PR.

@@ -50,7 +50,7 @@ stdenv.mkDerivation (finalAttrs: {

wrapProgram $out/bin/offpunk \
--set PYTHONPATH "$PYTHONPATH" \
--set PATH ${lib.makeBinPath otherDependencies}
--suffix PATH ${lib.makeBinPath otherDependencies}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should only suffix xdg-utils here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[ less timg xdg-utils xsel ]

pkgs/applications/misc/qdirstat/default.nix Outdated Show resolved Hide resolved
@@ -221,7 +221,7 @@ let

postFixup = ''
for script in "$out"/bin/*; do
wrapProgram "$script" --prefix PATH : "${runtimePath}"
wrapProgram "$script" --suffix PATH : "${runtimePath}"
Copy link
Contributor

@kira-bruneau kira-bruneau Aug 19, 2022

Choose a reason for hiding this comment

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

I don't think we should change this. It seems like runtimePath may include xdg-utils (I can't tell because it's populated by a function argument, runtimeInputs), but we shouldn't be suffixing any other dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The maintainer made this too complicated to begin with.

pkgs/applications/misc/taskwarrior/default.nix Outdated Show resolved Hide resolved
pkgs/applications/terminal-emulators/alacritty/default.nix Outdated Show resolved Hide resolved
ehmry and others added 2 commits August 19, 2022 13:10
The xdg-open utility is only ever a runtime dependency and its
dependents only expect that it accept a URI as a command line
argument and do something with it that the user would expect.
For such as a trivial relationship it should be possible for
users to override xdg-open with something else in their PATH.
@ehmry ehmry merged commit 16eb45c into NixOS:master Aug 19, 2022
@ehmry
Copy link
Contributor Author

ehmry commented Aug 19, 2022

Merged what was reviewed.

@jtrees
Copy link
Contributor

jtrees commented Aug 24, 2022

I used to have the following in my config:

nixpkgs.overlays = [(
  self: super: {
    xdg-utils = super.xdg-utils.override { mimiSupport = true; };
  }
)];

Unfortunately this resulted in having to build Chromium from source whenever there was a new version so I had to remove it again.

Does this PR mean I can add the overlay again without having to re-compile the world on every update?

@fricklerhandwerk
Copy link
Contributor

@jtrees As far as I can see, no. Rebuilding a derivation because of an override is in the nature of nixpkgs; it's not an addition to an existing package, but a new package with different parameters.

@jtrees
Copy link
Contributor

jtrees commented Aug 24, 2022

@jtrees As far as I can see, no. Rebuilding a derivation because of an override is in the nature of nixpkgs; it's not an addition to an existing package, but a new package with different parameters.

Ah shame. I thought I saw that xdg-utils was removed from the Chrome dependencies in this PR. But now I see that it's still an input so that will still trigger the build.

It's literally only used to add it to the PATH though, so it's essentially a runtime dependency. Is there no better way to deal with this kind of scenario in nix?

@ehmry
Copy link
Contributor Author

ehmry commented Aug 24, 2022

@jtrees You do not want to override xdg-utils in an overlay, I think what you want is to add your modified xdg-utils to systemPackages and that will override the Chrome PATH at runtime.

@jtrees
Copy link
Contributor

jtrees commented Aug 24, 2022

@jtrees You do not want to override xdg-utils in an overlay, I think what you want is to add your modified xdg-utils to systemPackages and that will override the Chrome PATH at runtime.

Ah, that makes sense! I'll try it. Thanks.

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.

8 participants