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

makeDesktopItem: add desktop file validation #75729

Merged
merged 1 commit into from Mar 30, 2020

Conversation

worldofpeace
Copy link
Contributor

@worldofpeace worldofpeace commented Dec 16, 2019

Motivation for this change

This uses desktop-file-validate in desktop-file-utils.
It can be turned off if wanted.

Errant entries according to the specification will now fail the build, and enforce properly created desktop files.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @

This uses desktop-file-validate in desktop-file-utils.
It can be turned off if wanted.
@worldofpeace
Copy link
Contributor Author

It's possible current expressions using makeDesktopItem will fail to build because of this change.

@teto
Copy link
Member

teto commented Dec 16, 2019

I don't have a beefy enough machine but I don't think it would break too much stuff.

@bignaux
Copy link
Contributor

bignaux commented Dec 18, 2019

We could modify the makeDesktopItem() using desktop-file-edit , ie in soulseekqt derivation:

desktop-file-edit \
--set-key Exec --set-value $binary \
--set-key Comment --set-value "${meta.description}" \
--set-key Categories --set-value Network default.desktop 

that way, according to documentation, you won't need to rerun validation.
and a most-wanted , and desktop-file-validate doesn't provides that, is to check if Exec value is valid.
(as in #75819 or #45347). On Arch for example, they use https://github.com/AndyCrowd/fbrokendesktop/blob/master/fbrokendesktop . It would avoid also #68035 if the validation/patching was systematic.

you can also enforce mode with --mode , avoid some desktop files like firefox ,0ad or xterm one to be executable ...

We can unify how desktop files are handles in nixpkgs, desktop-file-utils is often used in nativeBuildInputs of gnome application.

An other case in usage of desktop file directly in nixpkgs, for example openra :

    substitute ${./openra-mod.desktop} $(mkdirp $out/share/applications)/${pname}.desktop \
      --subst-var-by name ${escapeShellArg mod.name} \
      --subst-var-by title ${escapeShellArg mod.title} \
      --subst-var-by description ${escapeShellArg mod.description}

This use the same idea as in soulseekqt, fill the blank with meta properties. This could be an automatic feature with a proper .desktop.in extention.

cc @tilpner : we could offer such desktop mecanism as soulseekqt in appimageTools since all users of desktop software appimage need it and use often ugly method to fix that issue.

@worldofpeace
Copy link
Contributor Author

@bignaux Sounds good, will try this.

@tilpner
Copy link
Member

tilpner commented Dec 18, 2019

@bignaux I don't use .desktop files, so I'm unfamiliar with the ways used to generate them, but I'll try to review a PR to appimageTools if you send one. :)

@bignaux
Copy link
Contributor

bignaux commented Feb 29, 2020

Using this issue as a TODO, i notice we need a unified method to make the icon directories, lot use
such thing, an integrated helper would be welcome :
https://github.com/NixOS/nixpkgs/blob/de0af4a171280f085c6181b7477cefb46cc1ae83/pkgs/applications/networking/p2p/soulseekqt/default.nix#L56-L59

Edit: i forget to say i search for tools to do it well/better, i don't find any, but xdg-desktop-icon was very useless and make nothing interesting imho.

@worldofpeace worldofpeace merged commit dcf6e71 into NixOS:master Mar 30, 2020
@worldofpeace worldofpeace deleted the validate-makeDesktopItem branch March 30, 2020 18:27
@worldofpeace
Copy link
Contributor Author

Merged because I don't think I'll have the time to improve this more.

orivej-nixos pushed a commit that referenced this pull request Mar 30, 2020
Audio;Mixer; puts it near KMix which has Categories=Qt;KDE;AudioVideo;Audio;Mixer;
@ajs124
Copy link
Member

ajs124 commented Mar 31, 2020

This also broke the build of joplin-desktop. I barely know anything about desktop files, so I'm unsure how to fix this.

orivej-nixos pushed a commit that referenced this pull request Mar 31, 2020
"Application" is deprecated, "Other" is invalid, there are no generic
categories, and the Categories fields is optional per the spec.

Fixes the defaults after #75729.
@orivej
Copy link
Contributor

orivej commented Mar 31, 2020

Fixed in 7df8136.

timokau added a commit to timokau/nixpkgs that referenced this pull request Apr 2, 2020
Broken by NixOS#75729 since the desktop
items are only valid after post-processing. There's probably multiple
better ways to do this, but I'm not a calibre maintainer and I just want
to get this unbroken as quickly as possible.
@timokau timokau mentioned this pull request Apr 2, 2020
10 tasks
@timokau
Copy link
Member

timokau commented Apr 2, 2020

This broke calibre: #84095

dtzWill pushed a commit to dtzWill/nixpkgs that referenced this pull request Jun 5, 2020
Audio;Mixer; puts it near KMix which has Categories=Qt;KDE;AudioVideo;Audio;Mixer;

(cherry picked from commit ee5f863)
@piegamesde
Copy link
Member

Was nixpkgs-review ever run on this PR?

piegamesde added a commit to piegamesde/nixpkgs that referenced this pull request Oct 15, 2020
This fixes all packages that are failed `nixpkgs-review` in NixOS#91790.
Packages that were broken prior to that PR were marked as broken.
Packages that failed because of NixOS#75729 were fixed.
grwlf pushed a commit to grwlf/nixpkgs that referenced this pull request Aug 12, 2021
Broken by NixOS#75729 since the desktop
items are only valid after post-processing. There's probably multiple
better ways to do this, but I'm not a calibre maintainer and I just want
to get this unbroken as quickly as possible.
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.

None yet

8 participants