-
-
Notifications
You must be signed in to change notification settings - Fork 14k
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
freedesktop modules: init #45058
freedesktop modules: init #45058
Conversation
it could be also enabled if a display manager is enabled. Afaik it also make sense in the context of window managers like awesome or i3. |
nixos/modules/config/xdg/menus.nix
Outdated
type = types.bool; | ||
default = true; | ||
description = '' | ||
Whether to install files to support the XDG Dekstop Menus specification. |
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.
typo dekstop
@@ -38,9 +38,6 @@ in | |||
QT_PLUGIN_PATH = [ "/lib/qt4/plugins" "/lib/kde4/plugins" ]; | |||
QTWEBKIT_PLUGIN_PATH = [ "/lib/mozilla/plugins/" ]; | |||
GTK_PATH = [ "/lib/gtk-2.0" "/lib/gtk-3.0" ]; | |||
XDG_CONFIG_DIRS = [ "/etc/xdg" ]; |
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.
Where did this go?
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.
Whoops, left over from when I did try having a base-directories module.
nixos/modules/config/system-path.nix
Outdated
@@ -107,12 +107,8 @@ in | |||
"/etc/gtk-3.0" | |||
"/lib" # FIXME: remove and update debug-info.nix | |||
"/sbin" | |||
"/share/applications" | |||
"/share/desktop-directories" | |||
"/share" |
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.
Why this? The rest of the share
subdirectories in pathsToLink
would be pointless then. I think we want to avoid "/share"
(principle of least privilege or something).
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.
Hm, I think I was confused by the need for /etc/xdg
but not /share
- I think you're right that it will do the right thing because we typically include subdirectories of /share
explicitly.
2a69ba0
to
d00f085
Compare
Hm, good point about non-DE environments. |
d00f085
to
1b3b81f
Compare
1b3b81f
to
680bfb5
Compare
Okay, I've removed the settings in the DEs, relying on the xserver module to set the option. |
nixos/modules/config/xdg/mime.nix
Outdated
environment.extraSetup = '' | ||
XDG_DATA_DIRS=$out/share ${pkgs.shared-mime-info}/bin/update-mime-database -V $out/share/mime > /dev/null | ||
|
||
${pkgs.desktop-file-utils}/bin/update-desktop-database $out/share/applications |
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.
This should be probably separate from mime module. After all, the applications dir is also used by desktop-entry-spec and menu-spec.
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.
Yes, but I believe that update-desktop-database
only performs actions relevant to MIME lookup, so I think it belongs here.
nixos/modules/config/xdg/menus.nix
Outdated
config = mkIf config.xdg.menus.enable { | ||
environment.pathsToLink = [ | ||
"/share/applications" | ||
"/share/applications-merged" |
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.
It looks like it should be share/menus/applications-merged
: https://specifications.freedesktop.org/menu-spec/menu-spec-latest.html#paths
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.
Ah yes, good spot.
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.
Fixed.
The original code checked for existence of the directory used for generating the caches, can we make sure that the generators work even with the directory possibly missing? |
@@ -0,0 +1,21 @@ | |||
{ config, lib, pkgs, ... }: |
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.
Unused pkgs
arg
type = types.bool; | ||
default = true; | ||
description = '' | ||
Whether to install files to support the XDG Autostart specification. |
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.
It would be nice to have a link to the specification <link xlink:href="https://specifications.freedesktop.org/autostart-spec/autostart-spec-latest.html">XDG Autostart specification</link>
nixos/modules/config/system-path.nix
Outdated
extraSetup = mkOption { | ||
type = types.lines; | ||
default = [ ]; | ||
description = "Shell fragments to be run after the system environment has been created. This should only be used for things that need to modify the internals of the environment, e.g. generating MIME caches."; |
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.
Maybe mention something about the $out
thing.
if [ -x $out/bin/update-mime-database -a -w $out/share/mime ]; then | ||
XDG_DATA_DIRS=$out/share $out/bin/update-mime-database -V $out/share/mime > /dev/null | ||
fi | ||
|
||
if [ -x $out/bin/gtk-update-icon-cache -a -f $out/share/icons/hicolor/index.theme ]; then |
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.
This should probably be moved to xdg.icons
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.
Hm, I wasn't sure about that - I thought maybe there should be a GTK module that does this?
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.
Right, that looks like GTK thing: https://developer.gnome.org/gtk3/stable/gtk-update-icon-cache.html
We should probably get a module later.
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.
Similarly for the glib schemas.
bde1594
to
e551e1b
Compare
Comments addressed. I put back the test that the target directory be writable in the fragments. I also fixed a mistake with the |
nixos/modules/config/xdg/menus.nix
Outdated
@@ -0,0 +1,25 @@ | |||
{ config, lib, pkgs, ... }: |
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.
Still some unused pkgs
args.
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.
Removed.
Hold off this for a bit while I do some more testing. |
Okay, it turns out that linking At this point, a diff of my system-path built with and without this reveals only the previously missing XDG menu dirs. |
(so I'm fairly confident in this now) |
@@ -0,0 +1,31 @@ | |||
{ config, lib, pkgs, ... }: |
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.
This module might also add shared-mime-info to environment.systemPackages
to be linked into environment to fix bugs like #39493
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.
Aha, good catch. I had thought I could get away with removing them since the use of the binary is now encoded here, but it seems like it also has data to install.
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.
Fixed.
Those applications are broken then. I intend to remove |
Also, similar to |
I think that's a good idea, but I think we can do it as future work.
Sure, but let's do follow-ups. As an aside, it looks like we install a bunch of stuff in |
Yeah, but I would leave it localized in the DE modules that need it, not move it up to xserver.
Sounds good. By the way, do we need to write docs for manual or release notes? |
I don't think we should leave the linking of I don't think we need a doc change, this should only make things work better. However, I forgot to ask: should we consider having the default for some of these modules be not enabled? That would mean that systems without X could get away with e.g. not having icons, which might shrink closures a bit. OTOH, then we would definitely need a release note, since some things might rely on it happening implicitly. |
For example, I noticed this because |
This is the diff between the profiles - as you can see, a lot of stuff goes missing.
|
Moving it up in the chain would make the future granularization harder as more bugs would be obscured until then. I think status quo is good enough for now.
Hmm, $ nix path-info -f . -S shared-mime-info
/nix/store/g89z1wlss6dnhcvajxmn36nbayql80rh-shared-mime-info-1.10 48303016
$ nix path-info -f . -S desktop-file-utils
/nix/store/i6iglvwcq294nyam49h0q04aqzjzqf2c-desktop-file-utils-0.23 39642584 But looks like it is mostly just
I would leave this as is and address this in further PR.
In my experience, most apps compile in the path. Only minority looks up their own data in |
Hm, I was thinking that we would save on closures by not linking |
ca0476f
to
1b11fdd
Compare
I've returned the linking of |
In case it wasn't clear from my comment before: since there's unlikely to be a closure size improvement, I think we should leave these options enabled by default. |
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.
Great job. Looks good to me, though I would still like another set of eyes to check this.
@vcunat could you have a look at the final state of this? |
nixos/modules/config/system-path.nix
Outdated
@@ -81,6 +81,12 @@ in | |||
description = "List of additional package outputs to be symlinked into <filename>/run/current-system/sw</filename>."; | |||
}; | |||
|
|||
extraSetup = mkOption { | |||
type = types.lines; | |||
default = [ ]; |
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.
Nit: I think using an empty string as the default value is strictly more correct.
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.
Fixed, thanks.
ping |
It is still in some reviewers’ queues. Let’s leave it one more week. |
Wasn't intending to be pushy, just thought we'd got pretty close :) |
Don't hang the reviews and merging on this issue, but I'm wondering why the |
Enabling them in |
Ping - I think this would be a reasonable inclusion for 18.09. |
Motivation for this change
Follow-up to/supersedes #44866.
This adds some modules that handle various parts of the XDG specs. This allows us to move some of the logic out of
system-path.nix
, and have a more sensible way to decide whether to update MIME caches.I then added an option to
system-path
to allow extra environment setup commands to be defined by other modules, so the MIME module can also have the setup code in it.Points I'm unsure about
/share
and/etc/xdg
, which might have some value.extraSetup
mechanism forsystem-path
OK? It's a bit ugly that clients use$out
to be the output of another derivation.@jtojnar @vcunat
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)