Do nix-env update .desktop files ?

315 views
Skip to first unread message

Benoit-Pierre DEMAINE

unread,
Oct 24, 2017, 12:23:22 PM10/24/17
to nix-devel
Hello. Beginner in NIX.

I am using E17, and menus want fixed names for .desktop. Usually, I create files in /home/dhp/.local/share/applications/Doublehp .

I see that nix-env have created some .desktops after installing google-chrome, but the names look like they will break after some update; or their content may become invalid.

Names of binaries are stabilised via links:

$ which google-chrome-stable
/home/dhp/.nix-profile/bin/google-chrome-stable

But .desktop don't seem stable at all:

$ ls -lha ~/.local/share/applications/c* ~/.local/share/applications/g*
-rw------- 1 dhp dhp 395 2017-10-24 14:48 /home/dhp/.local/share/applications/chrome-aohghmighlieiainnegkcijnfilokake-Default.desktop
-rw------- 1 dhp dhp 403 2017-10-24 14:48 /home/dhp/.local/share/applications/chrome-apdfllckaahabafndbhieahigkjlhalf-Default.desktop
-rw------- 1 dhp dhp 398 2017-10-24 14:48 /home/dhp/.local/share/applications/chrome-blpcfgokakmgnkcojhhkbfbldkacnbeo-Default.desktop
-rw------- 1 dhp dhp 396 2017-10-24 14:48 /home/dhp/.local/share/applications/chrome-pjkljhegncpnkpknbcohdijeoejaedia-Default.desktop
-rw-r--r-- 1 dhp dhp 242 2010-12-28 06:11 /home/dhp/.local/share/applications/chromium.desktop
-rw-r--r-- 1 dhp dhp 336 2008-12-23 22:00 /home/dhp/.local/share/applications/gmpc.desktop

$ cat /home/dhp/.local/share/applications/chrome-blpcfgokakmgnkcojhhkbfbldkacnbeo-Default.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=YouTube
Exec=/nix/store/zdca4s257d6vj4chjjcqzsbgvw8s9di3-google-chrome-61.0.3163.100/share/google/chrome/google-chrome --profile-directory=Default --app-id=blpcfgokakmgnkcojhhkbfbldkacnbeo
Icon=chrome-blpcfgokakmgnkcojhhkbfbldkacnbeo-Default
NoDisplay=true
StartupWMClass=crx_blpcfgokakmgnkcojhhkbfbldkacnbeo

1: i fear the .desktop file could be removed later

2: the exec line seems correct

3: my biggest concern is about the icon: Icon=chrome-blpcfgokakmgnkcojhhkbfbldkacnbeo-Default really looks like something that *will* break very fast.

I have not found any constant link that would point to a stable .desktop file, or icon.

And I am not going to update my E17 settings after each NIX-chrome update to fix this.

Thanks.

Layus

unread,
Oct 24, 2017, 4:12:12 PM10/24/17
to Benoit-Pierre DEMAINE, nix-devel
Hello Benoit-Pierre,

I have tried to understand what your are describing.

I have installed google-chome (you may consider using chromium instead)
$ nix-env -iA nixos.google-chrome

$ which google-chrome-stable
/home/layus/.nix-profile/bin/google-chrome-stable

$ readlinks google-chrome-stable      # readlinks is a custom script of mine.
/home/layus/.nix-profile/bin/google-chrome-stable
/nix/var/nix/profiles/per-user/layus/profile/bin/google-chrome-stable
/nix/var/nix/profiles/per-user/layus/profile-794-link/bin/google-chrome-stable
/nix/store/4b2v7psr4p6fm7vpq0qxv794nydd19vg-user-environment/bin/google-chrome-stable
/nix/store/xb3lsc0s2sqa3pavxbar7bbbx3hzz88b-google-chrome-61.0.3163.79/bin/google-chrome-stable

$ ls -lha ~/.local/share/applications/*.desktop
-rw------- 1 layus users 394 24 oct 21:35 /home/layus/.local/share/applications/chrome-aohghmighlieiainnegkcijnfilokake-Default.desktop
-rw------- 1 layus users 403 24 oct 21:35 /home/layus/.local/share/applications/chrome-apdfllckaahabafndbhieahigkjlhalf-Default.desktop
-rw------- 1 layus users 397 24 oct 21:35 /home/layus/.local/share/applications/chrome-blpcfgokakmgnkcojhhkbfbldkacnbeo-Default.desktop
-rw------- 1 layus users 395 24 oct 21:35 /home/layus/.local/share/applications/chrome-pjkljhegncpnkpknbcohdijeoejaedia-Default.desktop
-rw-r--r-- 1 layus users 246 24 avr  2017 /home/layus/.local/share/applications/userapp-Earlybird-62UQYY.desktop
-rw-r--r-- 1 layus users 179  1 aoû 00:07 /home/layus/.local/share/applications/userapp-transmission-gtk-N1BT3Y.desktop
-rw-r--r-- 1 layus users 205  5 oct 22:46 /home/layus/.local/share/applications/wine-extension-hlp.desktop

I have exctly the same "Extension" names as you. They look deterministic to me, like a hash of the "Extension" itself maybe ?

$  cat /home/layus/.local/share/applications/chrome-aohghmighlieiainnegkcijnfilokake-Default.desktop

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=Docs
Exec=/nix/store/xb3lsc0s2sqa3pavxbar7bbbx3hzz88b-google-chrome-61.0.3163.79/share/google/chrome/google-chrome --profile-directory=Default --app-id=aohghmighlieiainnegkcijnfilokake
Icon=chrome-aohghmighlieiainnegkcijnfilokake-Default
NoDisplay=true
StartupWMClass=crx_aohghmighlieiainnegkcijnfilokake

So, there is something about "aohghmighlieiainnegkcijnfilokake" here, let's look:

$  find $HOME -name "*aohghmighlieiainnegkcijnfilokake*"                                                                     
./.config/google-chrome/Default/Extensions/aohghmighlieiainnegkcijnfilokake
./.gnome/apps/chrome-aohghmighlieiainnegkcijnfilokake-Default.desktop
./.local/share/icons/hicolor/16x16/apps/chrome-aohghmighlieiainnegkcijnfilokake-Default.png
./.local/share/icons/hicolor/128x128/apps/chrome-aohghmighlieiainnegkcijnfilokake-Default.png
./.local/share/applications/chrome-aohghmighlieiainnegkcijnfilokake-Default.desktop

Here is your icon, and all the related stuff.

So, let's be clear
1) Nix / NixOS has nothing to do with these .desktop stuff (they are not links to the store, and nix does not do that kind of messy stuff -- well, most of the time it does not). These are created and managed by google-chrome itself.
2) The .desktop files should be stable enough. I see no reason for google-chrome to rename its "Extensions" all the time. Plus, we have different chrome versions, and the exact same hashes for the "Extension"s
3) The nix store path appears in the .desktop, and should be removed if you want it to work across package updates.

I would recommend to rename these .desktops to something meaningful, like google-chrome-GMail.desktop, and strip the absolute path in front of google-chrome in Exec sections.
(i.e. `Exec=google-chrome --profile-directory=Default --app-id=pjkljhegncpnkpknbcohdijeoejaedia`, the $PATH is used in that case)
If google-chrome appears to rename/rehash its extensions, you will have to find another workaround. I however believe that it is not the case.

Regards,

-- Layus.
--
You received this message because you are subscribed to the Google Groups "nix-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nix-devel+...@googlegroups.com.
To post to this group, send email to nix-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nix-devel/1b6fab8a-b87a-4012-8f72-478701591dc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Roni Choudhury

unread,
Oct 24, 2017, 4:23:28 PM10/24/17
to Layus, Benoit-Pierre DEMAINE, nix-devel
On Tue, Oct 24, 2017 at 4:12 PM Layus <layu...@gmail.com> wrote:
$ readlinks google-chrome-stable      # readlinks is a custom script of mine.
/home/layus/.nix-profile/bin/google-chrome-stable
/nix/var/nix/profiles/per-user/layus/profile/bin/google-chrome-stable
/nix/var/nix/profiles/per-user/layus/profile-794-link/bin/google-chrome-stable
/nix/store/4b2v7psr4p6fm7vpq0qxv794nydd19vg-user-environment/bin/google-chrome-stable
/nix/store/xb3lsc0s2sqa3pavxbar7bbbx3hzz88b-google-chrome-61.0.3163.79/bin/google-chrome-stable

Very nice!

I often do this by hand, but it is a much better idea to have a script :). If convenient, do you mind sharing the script itself? If not, I am sure I can figure out how to reproduce it.

Thanks!

roni

 

Layus

unread,
Oct 24, 2017, 4:57:42 PM10/24/17
to Roni Choudhury, Benoit-Pierre DEMAINE, nix-devel
Hi Roni,

I do not mind sharing the script. It is available on https://sto-lat.no-ip.org/gitweb/?p=dotfiles.git;a=blob;f=.config/nixpkgs/overlays/myconfig/scripts/readlinks/readlinks
For now, it is WTFPL ;-)

You also get a default.nix for free :-)


> If not, I am sure I can figure out how to reproduce it.
I am sure you could, but I found it more tricky to write than expected.
That kind of algorithms only exist in C in the kernel and are generally not implemented anywhere else.

-- Layus.

Roni Choudhury

unread,
Oct 24, 2017, 5:17:09 PM10/24/17
to Layus, Benoit-Pierre DEMAINE, nix-devel
Thanks Layus!

roni
Reply all
Reply to author
Forward
0 new messages