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
copyDesktopItems: add new setup-hook #105151
Conversation
db7db09
to
40072bd
Compare
postInstallHooks+=(copyDesktopItems) | ||
|
||
copyDesktopItems() { | ||
if [ "${dontCopyDesktopItems-}" = 1 ]; then return; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if [ "${dontCopyDesktopItems-}" = 1 ]; then return; fi | |
[[ ${dontCopyDesktopItems-} == 1 ]] && return |
Normally in bash I would write the following but this looks more like sh or dash but you told shellcheck it is bash. I am a bit confused. Would you mind clearing this up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took this syntax directly from another hook. There are many which use the same style, so I copied it:
if [ "${dontMoveLib64-}" = 1 ]; then return; fi |
if [ "${dontMoveSbin-}" = 1 ]; then return; fi |
if [ -n "${dontUpdateAutotoolsGnuConfigScripts-}" ]; then return; fi |
I'm currently unaware if there is any policy about the hook sh/bash syntax, so I tried to stick with the existing hook style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure both are valid bash. Isn't bash a superset of sh anyways?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use [[
.. ]]
it's better behaved. And when in doubt see what shellcheck says hehe (though I think it will instruct on both).
I guess the alternative would be to change all derivations using the old pattern to just copy the files using |
79b0aab
to
1d5b0dd
Compare
1d5b0dd
to
c96befc
Compare
c96befc
to
b65a1ab
Compare
Built minecraft, xonotic-sdl, thunderbird, jd-gui, softmaker-office, goattracker on x86_64-linux and confirmed the .desktop files were included in the output. I rebased with these three changes:
|
Thanks for cleaning this up! The old way has bugged me too. Besides the comment above, can you perhaps find a way to share some code with the old |
Because #103071 broke the build of thunderbird, and this resolves it, I am going to merge this, even though some improvements have been suggested. It would be nice to see those in a follow-up commit. |
@petabyteboy Thanks for fixing this.
There is nothing wrong with This should have never been allowed in the first place. (Question to self: Why are the inputs to As (hopefully) all the bad uses of Documenting the hook in general might be a good idea. |
I agree with that. But I don't think the fact that
Nix choose to implement the |
Did you envision something tike this faee4397a10cf53fbe5f5741c91724623a23b10c? This would allow outputs of |
@B4dM4n OK I guess there are less duplicated than I thought. OK first a question. When would one use I suppose |
Nearly all of the uses of nixpkgs/nixos/modules/misc/documentation.nix Lines 62 to 77 in 9a01e97
Using
This sounds feasable. Changing the default to |
Ah |
Motivation for this change
A change made to the
makeDesktopItem
helper introduced by #105099 broke the build of some packages.These packages used the
desktopItem.buildCommand
string to install their desktop files directly, instead of using thedesktopItem
output:nixpkgs/pkgs/applications/audio/goattracker/default.nix
Line 56 in 05d408e
nixpkgs/pkgs/applications/networking/mailreaders/thunderbird/68.nix
Line 291 in 05d408e
nixpkgs/pkgs/applications/networking/mailreaders/thunderbird/default.nix
Line 286 in 05d408e
nixpkgs/pkgs/applications/office/softmaker/generic.nix
Lines 114 to 116 in 05d408e
nixpkgs/pkgs/games/minecraft/default.nix
Line 114 in 05d408e
nixpkgs/pkgs/games/xonotic/default.nix
Line 154 in 05d408e
nixpkgs/pkgs/tools/misc/jdiskreport/default.nix
Line 41 in 05d408e
nixpkgs/pkgs/tools/security/jd-gui/default.nix
Line 95 in 05d408e
This PR adds the
copyDesktopItems
setup hook, which simplifies the process of adding desktop files to a package. It is invoked as apostInstallHook
and will install the files given to thedesktopItems
attribute into theout
output.Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)CC: @flokli @samueldr