Hi, I am not sure how to solve this or even how to search for a solution.
I am using nix and home-manager basically as my package manager instead of apt. This works fine in Ubuntu.
In Kubuntu (installed with apt install kubuntu-desktop) I get an error an error when I try to launch most applications with Krunner or the application launcher, I get an error that the .desktop file is not writable.
I assume this is because KDE tries to add some things to the .desktop file because:
It works fine in Ubuntu (so I guess Gnome does not try to add this)
I can still launch the applications through the terminal and they work fine (except Firefox keeps asking to be made default and I keep saying yes, thinking this might be related)
So my questions are:
is this a known issue?
Is there a way to solve it without using a different launcher?
dalto
June 17, 2020, 6:06pm
2
I am not sure about kubuntu but, generally speaking, kde shouldn’t write to your .desktop files when you launch them from krunner.
Do you have GTK_USE_PORTAL
set globally or for that application? If so, that will cause this behavior. You can just tell firefox to stop checking to work around that.
@dalto thank you for the reply. I wonder why I getting that “.desktop file is not writable” error then I’ll keep searching.
echo $GTK_USE_PORTAL
shows, nothing. So I assume I don’t have it set. I set Firefox as the default browser in kcm and disabled the “always check if I’m the default browser” prompt in Firefox.
drupol
February 3, 2022, 10:06pm
4
Hello,
I tried Nix on Ubuntu and KDE Plasma is unable to use the .desktop
files.
However, I noticed that the only working app is Firefox. The only difference between the Firefox .desktop file and others is that the file is executable. Do you think I should open an issue somewhere?
For others, I do this simple workaround:
cp -L ~/.nix-profile/share/applications/* ~/.local/share/applications/
I am having the same problem and is also lost as to how to solve it
Searching some more, I found some GitHub issue which talks about this problem
opened 07:31PM - 28 Dec 20 UTC
closed 04:07PM - 01 Jan 21 UTC
0.kind: bug
**Describe the bug**
Without making .desktop files executable, KDE/Plasma block… s the running of them for security reasons.
I'm using nixpkgs with Debian+KDE, I used nixpkgs to install 3 packages with .desktop files:
```
$ ll ~/.nix-profile/share/applications/
total 12K
lrwxrwxrwx 1 fishy fishy 96 Dec 31 1969 darktable.desktop -> /nix/store/qcxc00pmfr0qrn9mgml8b48jsbkkjvf4-darktable-3.4.0/share/applications/darktable.desktop
lrwxrwxrwx 1 fishy fishy 97 Dec 31 1969 firefox.desktop -> /nix/store/mfwp4l6gdg783l65nv90yn595wixi8di-firefox-bin-84.0.1/share/applications/firefox.desktop
lrwxrwxrwx 1 fishy fishy 105 Dec 31 1969 thunderbird.desktop -> /nix/store/nw2c4pqn2vkv7dhs4vy0c9611p339agq-thunderbird-bin-78.6.0/share/applications/thunderbird.desktop
```
Among them, only the firefox one is executable:
```
$ ll /nix/store/mfwp4l6gdg783l65nv90yn595wixi8di-firefox-bin-84.0.1/share/applications/firefox.desktop
-r-xr-xr-x 1 fishy fishy 302 Dec 31 1969 /nix/store/mfwp4l6gdg783l65nv90yn595wixi8di-firefox-bin-84.0.1/share/applications/firefox.desktop
```
The other 2 are not:
```
$ ll /nix/store/qcxc00pmfr0qrn9mgml8b48jsbkkjvf4-darktable-3.4.0/share/applications/darktable.desktop
-r--r--r-- 1 fishy fishy 3.2K Dec 31 1969 /nix/store/qcxc00pmfr0qrn9mgml8b48jsbkkjvf4-darktable-3.4.0/share/applications/darktable.desktop
$ ll /nix/store/nw2c4pqn2vkv7dhs4vy0c9611p339agq-thunderbird-bin-78.6.0/share/applications/thunderbird.desktop
-r--r--r-- 1 fishy fishy 333 Dec 31 1969 /nix/store/nw2c4pqn2vkv7dhs4vy0c9611p339agq-thunderbird-bin-78.6.0/share/applications/thunderbird.desktop
```
I have no problem running firefox from KDE's launcher feature (I think that's called KRun), but when I try to run the other 2 KDE would complain (the screenshots are taking darktable as an example):


Searching the error message in KDE code, I found 2 occurrences of them:
https://github.com/KDE/kio/blob/6d98246cb1bdfdb5b39388c069ded589fa2db0b1/src/gui/applicationlauncherjob.cpp#L138-L155
https://github.com/KDE/kdelibs/blob/1c5b25966136b6099665477616fb4d38a98fd7ef/kio/kio/krun.cpp#L963-L978
Looking at the code, my understanding is that because the `Exec` line inside the `.desktop` files are on absolute path:
```
$ grep Exec /nix/store/qcxc00pmfr0qrn9mgml8b48jsbkkjvf4-darktable-3.4.0/share/applications/darktable.desktop
Exec=/nix/store/qcxc00pmfr0qrn9mgml8b48jsbkkjvf4-darktable-3.4.0/bin/darktable %U
TryExec=/nix/store/qcxc00pmfr0qrn9mgml8b48jsbkkjvf4-darktable-3.4.0/bin/darktable
```
KDE's security policy dictates that the `.desktop` file must also be executable or it refuses to run it.
As a result, I think we should make all `.desktop` files executable to improve KDE compatibility.
**To Reproduce**
Steps to reproduce the behavior:
1. ...
2. ...
3. ...
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Additional context**
Add any other context about the problem here.
**Notify maintainers**
<!--
Please @ people who are in the `meta.maintainers` list of the offending package or module.
If in doubt, check `git blame` for whoever last touched something.
-->
**Metadata**
Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the result.
```
$ nix-shell -p nix-info --run "nix-info -m"
- system: `"x86_64-linux"`
- host os: `Linux 5.9.0-5-amd64, Debian GNU/Linux, noversion`
- multi-user?: `no`
- sandbox: `no`
- version: `nix-env (Nix) 2.3.10`
- channels(fishy): `"nixpkgs-21.03pre260073.ad13f0e569c"`
- nixpkgs: `/home/fishy/.nix-defexpr/channels/nixpkgs`
```
Maintainer information:
```yaml
# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
```
opened 04:31AM - 25 Dec 21 UTC
closed 05:30PM - 19 Feb 22 UTC
0.kind: bug
KDE won't run .desktop files that aren't executable, but this usually doesn't ma… tter because it also allows running files owned by root and these are.
https://github.com/KDE/kdelibs/blob/1c5b25966136b6099665477616fb4d38a98fd7ef/kdecore/config/kdesktopfile.cpp#L170-L174
Unfortunately if you are using a buildFHSUserEnv which uses bubblewrap, it will show files owned by root as being owned by nobody.
So if you launch a game inside lutris or steam-run, and then that game runs xdg-open to open a web browser, and the .desktop entry for that browser is not executable but is owned by root KDE will no longer be able to tell it's owned by root and will pop up this error.

Clicking yes can't work as it's in the nix store.

### Steps To Reproduce
Steps to reproduce the behavior:
Use pkgs.makeDesktopItem to make a .desktop file, check its executable bit.
```
$ ls -l /nix/store/dk0rv65i41kzsh991s2cj0v8wkkdg5vs-firefox.desktop/share/applications/firefox.desktop
-r--r--r-- 2 root root 203 Dec 31 1969 /nix/store/dk0rv65i41kzsh991s2cj0v8wkkdg5vs-firefox.desktop/share/applications/firefox.desktop
```
### Expected behavior
$ ls -l /nix/store/dk0rv65i41kzsh991s2cj0v8wkkdg5vs-firefox.desktop/share/applications/firefox.desktop
-r-xr-xr-x 2 root root 203 Dec 31 1969 /nix/store/dk0rv65i41kzsh991s2cj0v8wkkdg5vs-firefox.desktop/share/applications/firefox.desktop
A `#!/usr/bin/env xdg-open` shebang [should probably also be added.](https://unix.stackexchange.com/questions/373239/what-is-the-advantage-of-desktop-files-without-executable-bit-set)
### Notify maintainers
<!--
Please @ people who are in the `meta.maintainers` list of the offending package or module.
If in doubt, check `git blame` for whoever last touched something.
-->
### Metadata
Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the result.
```console
lun@hisame ~ ./rw
$ nix-info -m
- system: `0`
- host os: `Linux 5.15.10, NixOS, 22.05 (Quokka)`
- multi-user?: `no`
- sandbox: `yes`
- version: `nix-env (Nix) 2.6.0pre20211217_6e6e998`
- channels(root): `"nixos-22.05pre336298.bc5d68306b4"`
- nixpkgs: `0`
```
opened 11:40AM - 31 Jan 24 UTC
bug
triage
### Are you following the right branch?
- [X] My Nixpkgs and Home Manager versi… ons are in sync
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Issue description
When writing the following HM nix code (running on a Linux Mint w/Cinnamon) `kitty` shows up in the start-menu (as expected).
However, when clicking on the kitty start-menu item (whose icon is not found btw), the Cinnamon code editor (gedit?) opens up with the bash script generated by nixpkgs's `wrapProgram`, instead of opening Kitty.
```nix
{config, lib, ...}: {
targets.genericLinux.enable = true;
programs.kitty.enable = true;
xdg.desktopEntries.kitty = let
kitty = config.programs.kitty.package;
in {
name = "Kitty";
type = "Application";
genericName = "Terminal Emulator";
comment = "Fast, feature-rich, GPU based terminal";
icon = "kitty";
exec = lib.getExe kitty;
categories = ["X-Desktop" "X-System"];
settings = {
TryExec = lib.getExe kitty;
X-Version = lib.getVersion kitty;
};
};
}
```
### Maintainer CC
@ncfavier @rycee @Scrumplex
### System information
```markdown
x10an14@laptop ❯ : nix run nixpkgs#nix-info -- -m
- system: `"x86_64-linux"`
- host os: `Linux 5.15.0-92-generic, Linux Mint, 21.3 (Virginia), nobuild`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.16.1`
- channels(root): `"nixpkgs"`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
```
```
NixOS:master
← x10an14:make-desktop-files-executable
opened 11:58PM - 03 Feb 24 UTC
## Description of changes
Use case; some desktop compositors (KDE(?), Cinnamon)… require GUI program's .desktop files to be marked as executable files.
See https://github.com/NixOS/nixpkgs/issues/152059 and https://github.com/nix-community/home-manager/issues/4979.
__*CURRENTLY MARKED AS DRAFT SINCE I EXPECT THAT THIS IS NOT IDEAL AS-IS*__
## Things done
- Built on platform(s)
- [ ] x86_64-linux (No idea how to "build" this - some packages found using it seem to work for me (not exhaustive list)
- [ ] aarch64-linux
- [ ] x86_64-darwin
- [ ] aarch64-darwin
- For non-Linux: Is sandboxing enabled in `nix.conf`? (See [Nix manual](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
- [ ] `sandbox = relaxed`
- [ ] `sandbox = true`
- [ ] Tested, as applicable:
- [NixOS test(s)](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
- and/or [package tests](https://nixos.org/manual/nixpkgs/unstable/#sec-package-tests)
- or, for functions and "core" functionality, tests in [lib/tests](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or [pkgs/test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test)
- made sure NixOS tests are [linked](https://nixos.org/manual/nixpkgs/unstable/#ssec-nixos-tests-linking) to the relevant packages
- [ ] 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](https://github.com/Mic92/nixpkgs-review#usage)
- This did not work, but neither did it on parent commit #286108...
- [ ] Tested basic functionality of all binary files (usually in `./result/bin/`)
- [24.05 Release Notes](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2405.section.md) (or backporting [23.05](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2305.section.md) and [23.11](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2311.section.md) 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](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
<!--
To help with the large amounts of pull requests, we would appreciate your
reviews of other pull requests, especially simple package updates. Just leave a
comment describing what you have tested in the relevant package/service.
Reviewing helps to reduce the average time-to-merge for everyone.
Thanks a lot if you do!
List of open PRs: https://github.com/NixOS/nixpkgs/pulls
Reviewing guidelines: https://nixos.org/manual/nixpkgs/unstable/#chap-reviewing-contributions
-->
---
Add a :+1: [reaction] to [pull requests you find important].
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc
I still did not find a solution my current workaround is to run this one-liner when I encounter the error
find ~/.nix-profile/share/applications/ -iname '*.desktop' | xargs -n 1 readlink | xargs chmod +x
I have, however, found that this problem doesn’t exist on a pure NixOS with KDE Plasma desktop environment.