From 13e2e19158bcd2b4d53e452d82f62817194100ef Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Wed, 15 Aug 2018 09:55:35 +0100 Subject: xdg: add modules for supporting various XDG specs --- nixos/modules/config/system-path.nix | 17 ++++---------- nixos/modules/config/xdg/autostart.nix | 22 ++++++++++++++++++ nixos/modules/config/xdg/icons.nix | 27 ++++++++++++++++++++++ nixos/modules/config/xdg/menus.nix | 25 ++++++++++++++++++++ nixos/modules/config/xdg/mime.nix | 26 +++++++++++++++++++++ nixos/modules/module-list.nix | 4 ++++ nixos/modules/programs/environment.nix | 1 - nixos/modules/services/networking/xrdp.nix | 10 +++++--- .../x11/desktop-managers/enlightenment.nix | 9 ++++++-- .../services/x11/desktop-managers/lumina.nix | 3 +-- .../services/x11/desktop-managers/plasma5.nix | 5 +++- .../modules/services/x11/desktop-managers/xfce.nix | 5 ---- nixos/modules/services/x11/xserver.nix | 8 +++++-- 13 files changed, 133 insertions(+), 29 deletions(-) create mode 100644 nixos/modules/config/xdg/autostart.nix create mode 100644 nixos/modules/config/xdg/icons.nix create mode 100644 nixos/modules/config/xdg/menus.nix create mode 100644 nixos/modules/config/xdg/mime.nix (limited to 'nixos') diff --git a/nixos/modules/config/system-path.nix b/nixos/modules/config/system-path.nix index 36115166501..a07a40e86bd 100644 --- a/nixos/modules/config/system-path.nix +++ b/nixos/modules/config/system-path.nix @@ -107,12 +107,7 @@ in "/etc/gtk-3.0" "/lib" # FIXME: remove and update debug-info.nix "/sbin" - "/share/applications" - "/share/desktop-directories" "/share/emacs" - "/share/icons" - "/share/menus" - "/share/mime" "/share/nano" "/share/org" "/share/themes" @@ -132,10 +127,6 @@ in # outputs TODO: note that the tools will often not be linked by default postBuild = '' - 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 $out/bin/gtk-update-icon-cache $out/share/icons/hicolor fi @@ -144,16 +135,16 @@ in $out/bin/glib-compile-schemas $out/share/glib-2.0/schemas fi - if [ -x $out/bin/update-desktop-database -a -w $out/share/applications ]; then - $out/bin/update-desktop-database $out/share/applications - fi - if [ -x $out/bin/install-info -a -w $out/share/info ]; then shopt -s nullglob for i in $out/share/info/*.info $out/share/info/*.info.gz; do $out/bin/install-info $i $out/share/info/dir done fi + '' ++ optionalString config.xdg.mime.enable '' + 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 ''; }; diff --git a/nixos/modules/config/xdg/autostart.nix b/nixos/modules/config/xdg/autostart.nix new file mode 100644 index 00000000000..0ee94fed818 --- /dev/null +++ b/nixos/modules/config/xdg/autostart.nix @@ -0,0 +1,22 @@ +{ config, lib, ... }: + +with lib; +{ + options = { + xdg.autostart.enable = mkOption { + type = types.bool; + default = true; + description = '' + Whether to install files to support the + XDG Autostart specification. + ''; + }; + }; + + config = mkIf config.xdg.autostart.enable { + environment.pathsToLink = [ + "/etc/xdg/autostart" + ]; + }; + +} diff --git a/nixos/modules/config/xdg/icons.nix b/nixos/modules/config/xdg/icons.nix new file mode 100644 index 00000000000..8268a3771a0 --- /dev/null +++ b/nixos/modules/config/xdg/icons.nix @@ -0,0 +1,27 @@ +{ config, lib, ... }: + +with lib; +{ + options = { + xdg.icons.enable = mkOption { + type = types.bool; + default = true; + description = '' + Whether to install files to support the + XDG Icon Theme specification. + ''; + }; + }; + + config = mkIf config.xdg.icons.enable { + environment.pathsToLink = [ + "/share/icons" + "/share/pixmaps" + ]; + + environment.profileRelativeEnvVars = { + XCURSOR_PATH = [ "/share/icons" ]; + }; + }; + +} diff --git a/nixos/modules/config/xdg/menus.nix b/nixos/modules/config/xdg/menus.nix new file mode 100644 index 00000000000..c172692df5d --- /dev/null +++ b/nixos/modules/config/xdg/menus.nix @@ -0,0 +1,25 @@ +{ config, lib, ... }: + +with lib; +{ + options = { + xdg.menus.enable = mkOption { + type = types.bool; + default = true; + description = '' + Whether to install files to support the + XDG Desktop Menu specification. + ''; + }; + }; + + config = mkIf config.xdg.menus.enable { + environment.pathsToLink = [ + "/share/applications" + "/share/desktop-directories" + "/etc/xdg/menus" + "/etc/xdg/menus/applications-merged" + ]; + }; + +} diff --git a/nixos/modules/config/xdg/mime.nix b/nixos/modules/config/xdg/mime.nix new file mode 100644 index 00000000000..db3e7c6d4c5 --- /dev/null +++ b/nixos/modules/config/xdg/mime.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: + +with lib; +{ + options = { + xdg.mime.enable = mkOption { + type = types.bool; + default = true; + description = '' + Whether to install files to support the + XDG Shared MIME-info specification and the + XDG MIME Applications specification. + ''; + }; + }; + + config = mkIf config.xdg.mime.enable { + environment.pathsToLink = [ "/share/mime" ]; + + environment.systemPackages = [ + # this package also installs some useful data, as well as its utilities + pkgs.shared-mime-info + ]; + }; + +} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 73173dd4e24..5bb5f4f6145 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -7,6 +7,10 @@ ./config/fonts/fontdir.nix ./config/fonts/fonts.nix ./config/fonts/ghostscript.nix + ./config/xdg/autostart.nix + ./config/xdg/icons.nix + ./config/xdg/menus.nix + ./config/xdg/mime.nix ./config/gnu.nix ./config/i18n.nix ./config/iproute2.nix diff --git a/nixos/modules/programs/environment.nix b/nixos/modules/programs/environment.nix index 3bac8d98990..3c6d356ef99 100644 --- a/nixos/modules/programs/environment.nix +++ b/nixos/modules/programs/environment.nix @@ -40,7 +40,6 @@ in GTK_PATH = [ "/lib/gtk-2.0" "/lib/gtk-3.0" ]; XDG_CONFIG_DIRS = [ "/etc/xdg" ]; XDG_DATA_DIRS = [ "/share" ]; - XCURSOR_PATH = [ "/share/icons" ]; MOZ_PLUGIN_PATH = [ "/lib/mozilla/plugins" ]; LIBEXEC_PATH = [ "/lib/libexec" ]; }; diff --git a/nixos/modules/services/networking/xrdp.nix b/nixos/modules/services/networking/xrdp.nix index 0e882873b4b..61f22a366a0 100644 --- a/nixos/modules/services/networking/xrdp.nix +++ b/nixos/modules/services/networking/xrdp.nix @@ -93,10 +93,14 @@ in config = mkIf cfg.enable { - # copied from # xrdp can run X11 program even if "services.xserver.enable = false" - environment.pathsToLink = - [ "/etc/xdg" "/share/xdg" "/share/applications" "/share/icons" "/share/pixmaps" ]; + xdg = { + autostart.enable = true; + menus.enable = true; + mime.enable = true; + icons.enable = true; + }; + fonts.enableDefaultFonts = mkDefault true; systemd = { diff --git a/nixos/modules/services/x11/desktop-managers/enlightenment.nix b/nixos/modules/services/x11/desktop-managers/enlightenment.nix index da3287aaea6..6fa3ec3b925 100644 --- a/nixos/modules/services/x11/desktop-managers/enlightenment.nix +++ b/nixos/modules/services/x11/desktop-managers/enlightenment.nix @@ -33,12 +33,17 @@ in pkgs.xorg.xauth # used by kdesu pkgs.gtk2 # To get GTK+'s themes. pkgs.tango-icon-theme - pkgs.shared-mime-info + pkgs.gnome2.gnomeicontheme pkgs.xorg.xcursorthemes ]; - environment.pathsToLink = [ "/etc/enlightenment" "/etc/xdg" "/share/enlightenment" "/share/elementary" "/share/applications" "/share/locale" "/share/icons" "/share/themes" "/share/mime" "/share/desktop-directories" ]; + environment.pathsToLink = [ + "/etc/enlightenment" + "/share/enlightenment" + "/share/elementary" + "/share/locale" + ]; services.xserver.desktopManager.session = [ { name = "Enlightenment"; diff --git a/nixos/modules/services/x11/desktop-managers/lumina.nix b/nixos/modules/services/x11/desktop-managers/lumina.nix index 5fe84cfb82e..43fed2572b5 100644 --- a/nixos/modules/services/x11/desktop-managers/lumina.nix +++ b/nixos/modules/services/x11/desktop-managers/lumina.nix @@ -41,9 +41,8 @@ in # Link some extra directories in /run/current-system/software/share environment.pathsToLink = [ - "/share/desktop-directories" - "/share/icons" "/share/lumina" + # FIXME: modules should link subdirs of `/share` rather than relying on this "/share" ]; diff --git a/nixos/modules/services/x11/desktop-managers/plasma5.nix b/nixos/modules/services/x11/desktop-managers/plasma5.nix index 83d1957a646..d1cb962f6ff 100644 --- a/nixos/modules/services/x11/desktop-managers/plasma5.nix +++ b/nixos/modules/services/x11/desktop-managers/plasma5.nix @@ -174,7 +174,10 @@ in ++ lib.optional config.services.colord.enable colord-kde ++ lib.optionals config.services.samba.enable [ kdenetwork-filesharing pkgs.samba ]; - environment.pathsToLink = [ "/share" ]; + environment.pathsToLink = [ + # FIXME: modules should link subdirs of `/share` rather than relying on this + "/share" + ]; environment.etc = singleton { source = xcfg.xkbDir; diff --git a/nixos/modules/services/x11/desktop-managers/xfce.nix b/nixos/modules/services/x11/desktop-managers/xfce.nix index ae155470419..75b9a76e192 100644 --- a/nixos/modules/services/x11/desktop-managers/xfce.nix +++ b/nixos/modules/services/x11/desktop-managers/xfce.nix @@ -59,9 +59,6 @@ in tango-icon-theme xfce4-icon-theme - desktop-file-utils - shared-mime-info - # Needed by Xfce's xinitrc script # TODO: replace with command -v which @@ -100,8 +97,6 @@ in environment.pathsToLink = [ "/share/xfce4" "/share/themes" - "/share/mime" - "/share/desktop-directories" "/share/gtksourceview-2.0" ]; diff --git a/nixos/modules/services/x11/xserver.nix b/nixos/modules/services/x11/xserver.nix index b45e510f6b8..0237dd6f560 100644 --- a/nixos/modules/services/x11/xserver.nix +++ b/nixos/modules/services/x11/xserver.nix @@ -616,8 +616,12 @@ in ] ++ optional (elem "virtualbox" cfg.videoDrivers) xorg.xrefresh; - environment.pathsToLink = - [ "/etc/xdg" "/share/xdg" "/share/applications" "/share/icons" "/share/pixmaps" ]; + xdg = { + autostart.enable = true; + menus.enable = true; + mime.enable = true; + icons.enable = true; + }; # The default max inotify watches is 8192. # Nowadays most apps require a good number of inotify watches, -- cgit 1.4.1 From 1b11fdd0df2254a762a16d04e603ba99e42169c0 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Wed, 15 Aug 2018 10:59:44 +0100 Subject: system-path: allow other modules to provide setup fragments --- nixos/modules/config/system-path.nix | 19 ++++++++----------- nixos/modules/config/xdg/mime.nix | 10 ++++++++++ nixos/modules/misc/documentation.nix | 8 ++++++++ 3 files changed, 26 insertions(+), 11 deletions(-) (limited to 'nixos') diff --git a/nixos/modules/config/system-path.nix b/nixos/modules/config/system-path.nix index a07a40e86bd..6d17ca316e0 100644 --- a/nixos/modules/config/system-path.nix +++ b/nixos/modules/config/system-path.nix @@ -81,6 +81,12 @@ in description = "List of additional package outputs to be symlinked into /run/current-system/sw."; }; + 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. The environment being built can be accessed at $out."; + }; + }; system = { @@ -134,17 +140,8 @@ in if [ -x $out/bin/glib-compile-schemas -a -w $out/share/glib-2.0/schemas ]; then $out/bin/glib-compile-schemas $out/share/glib-2.0/schemas fi - - if [ -x $out/bin/install-info -a -w $out/share/info ]; then - shopt -s nullglob - for i in $out/share/info/*.info $out/share/info/*.info.gz; do - $out/bin/install-info $i $out/share/info/dir - done - fi - '' ++ optionalString config.xdg.mime.enable '' - 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 + + ${config.environment.extraSetup} ''; }; diff --git a/nixos/modules/config/xdg/mime.nix b/nixos/modules/config/xdg/mime.nix index db3e7c6d4c5..f1b672234a3 100644 --- a/nixos/modules/config/xdg/mime.nix +++ b/nixos/modules/config/xdg/mime.nix @@ -21,6 +21,16 @@ with lib; # this package also installs some useful data, as well as its utilities pkgs.shared-mime-info ]; + + environment.extraSetup = '' + if [ -w $out/share/mime ]; then + XDG_DATA_DIRS=$out/share ${pkgs.shared-mime-info}/bin/update-mime-database -V $out/share/mime > /dev/null + fi + + if [ -w $out/share/applications ]; then + ${pkgs.desktop-file-utils}/bin/update-desktop-database $out/share/applications + fi + ''; }; } diff --git a/nixos/modules/misc/documentation.nix b/nixos/modules/misc/documentation.nix index b482a5a6752..e6ccda5d7f4 100644 --- a/nixos/modules/misc/documentation.nix +++ b/nixos/modules/misc/documentation.nix @@ -82,6 +82,14 @@ let cfg = config.documentation; in environment.systemPackages = [ pkgs.texinfoInteractive ]; environment.pathsToLink = [ "/share/info" ]; environment.extraOutputsToInstall = [ "info" ] ++ optional cfg.dev.enable "devinfo"; + environment.extraSetup = '' + if [ -w $out/share/info ]; then + shopt -s nullglob + for i in $out/share/info/*.info $out/share/info/*.info.gz; do + ${pkgs.texinfo}/bin/install-info $i $out/share/info/dir + done + fi + ''; }) (mkIf cfg.doc.enable { -- cgit 1.4.1 From 854ebed7893b53d4991ec0839da3697baee41501 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Mon, 20 Aug 2018 09:23:11 +0100 Subject: system-path: fix default option value --- nixos/modules/config/system-path.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nixos') diff --git a/nixos/modules/config/system-path.nix b/nixos/modules/config/system-path.nix index 6d17ca316e0..ffb437491f6 100644 --- a/nixos/modules/config/system-path.nix +++ b/nixos/modules/config/system-path.nix @@ -83,7 +83,7 @@ in extraSetup = mkOption { type = types.lines; - default = [ ]; + 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. The environment being built can be accessed at $out."; }; -- cgit 1.4.1