diff options
Diffstat (limited to 'home-manager/modules/misc')
-rw-r--r-- | home-manager/modules/misc/dconf.nix | 25 | ||||
-rw-r--r-- | home-manager/modules/misc/debug.nix | 26 | ||||
-rw-r--r-- | home-manager/modules/misc/gtk.nix | 146 | ||||
-rw-r--r-- | home-manager/modules/misc/news.nix | 357 | ||||
-rw-r--r-- | home-manager/modules/misc/nixpkgs.nix | 4 | ||||
-rw-r--r-- | home-manager/modules/misc/numlock.nix | 2 | ||||
-rw-r--r-- | home-manager/modules/misc/tmpfiles.nix | 49 | ||||
-rw-r--r-- | home-manager/modules/misc/version.nix | 2 | ||||
-rw-r--r-- | home-manager/modules/misc/vte.nix | 51 | ||||
-rw-r--r-- | home-manager/modules/misc/xdg-mime-apps.nix | 2 | ||||
-rw-r--r-- | home-manager/modules/misc/xdg-mime.nix | 10 | ||||
-rw-r--r-- | home-manager/modules/misc/xdg-user-dirs.nix | 27 | ||||
-rw-r--r-- | home-manager/modules/misc/xdg.nix | 10 |
13 files changed, 589 insertions, 122 deletions
diff --git a/home-manager/modules/misc/dconf.nix b/home-manager/modules/misc/dconf.nix index f5c9bf71456..5fc7748a76b 100644 --- a/home-manager/modules/misc/dconf.nix +++ b/home-manager/modules/misc/dconf.nix @@ -9,22 +9,7 @@ let toDconfIni = generators.toINI { mkKeyValue = mkIniKeyValue; }; mkIniKeyValue = key: value: - let - tweakVal = v: - if isString v then "'${v}'" - else if isList v then tweakList v - else if isBool v then (if v then "true" else "false") - else toString v; - - # Assume empty list is a list of strings, see #769 - tweakList = v: - if v == [] then "@as []" - else "[" + concatMapStringsSep "," tweakVal v + "]"; - - in - "${key}=${tweakVal value}"; - - primitive = with types; either bool (either int (either float str)); + "${key}=${toString (hm.gvariant.mkValue value)}"; in @@ -43,8 +28,7 @@ in }; settings = mkOption { - type = with types; - attrsOf (attrsOf (either primitive (listOf primitive))); + type = with types; attrsOf (attrsOf hm.types.gvariant); default = {}; example = literalExample '' { @@ -53,6 +37,7 @@ in show-thousands = true; base = 10; word-size = 64; + window-position = lib.hm.gvariant.mkTuple [100 100]; }; } ''; @@ -76,9 +61,9 @@ in fi if [[ -v DRY_RUN ]]; then - echo $DCONF_DBUS_RUN_SESSION ${pkgs.gnome3.dconf}/bin/dconf load / "<" ${iniFile} + echo $DCONF_DBUS_RUN_SESSION ${pkgs.dconf}/bin/dconf load / "<" ${iniFile} else - $DCONF_DBUS_RUN_SESSION ${pkgs.gnome3.dconf}/bin/dconf load / < ${iniFile} + $DCONF_DBUS_RUN_SESSION ${pkgs.dconf}/bin/dconf load / < ${iniFile} fi unset DCONF_DBUS_RUN_SESSION diff --git a/home-manager/modules/misc/debug.nix b/home-manager/modules/misc/debug.nix new file mode 100644 index 00000000000..d27d496b423 --- /dev/null +++ b/home-manager/modules/misc/debug.nix @@ -0,0 +1,26 @@ +{ config, pkgs, lib, ... }: + +with lib; + +{ + options.home = { + enableDebugInfo = mkEnableOption "" // { + description = '' + Some Nix-packages provide debug symbols for + <command>gdb</command> in the <literal>debug</literal>-output. + This option ensures that those are automatically fetched from + the binary cache if available and <command>gdb</command> is + configured to find those symbols. + ''; + }; + }; + + config = mkIf config.home.enableDebugInfo { + home.extraOutputsToInstall = [ "debug" ]; + + home.sessionVariables = { + NIX_DEBUG_INFO_DIRS = + "$NIX_DEBUG_INFO_DIRS\${NIX_DEBUG_INFO_DIRS:+:}${config.home.profileDirectory}/lib/debug"; + }; + }; +} diff --git a/home-manager/modules/misc/gtk.nix b/home-manager/modules/misc/gtk.nix index 1222db4ecab..bf25aaaf664 100644 --- a/home-manager/modules/misc/gtk.nix +++ b/home-manager/modules/misc/gtk.nix @@ -11,44 +11,22 @@ let toGtk3Ini = generators.toINI { mkKeyValue = key: value: let - value' = - if isBool value then (if value then "true" else "false") - else toString value; - in - "${key}=${value'}"; + value' = if isBool value then + (if value then "true" else "false") + else + toString value; + in "${key}=${value'}"; }; formatGtk2Option = n: v: let - v' = - if isBool v then (if v then "true" else "false") - else if isString v then "\"${v}\"" - else toString v; - in - "${n} = ${v'}"; - - fontType = types.submodule { - options = { - package = mkOption { - type = types.nullOr types.package; - default = null; - example = literalExample "pkgs.dejavu_fonts"; - description = '' - Package providing the font. This package will be installed - to your profile. If <literal>null</literal> then the font - is assumed to already be available in your profile. - ''; - }; - - name = mkOption { - type = types.str; - example = "DejaVu Sans 8"; - description = '' - The family name and size of the font within the package. - ''; - }; - }; - }; + v' = if isBool v then + (if v then "true" else "false") + else if isString v then + ''"${v}"'' + else + toString v; + in "${n} = ${v'}"; themeType = types.submodule { options = { @@ -71,13 +49,11 @@ let }; }; -in - -{ +in { meta.maintainers = [ maintainers.rycee ]; imports = [ - (mkRemovedOptionModule ["gtk" "gtk3" "waylandSupport"] '' + (mkRemovedOptionModule [ "gtk" "gtk3" "waylandSupport" ] '' This options is not longer needed and can be removed. '') ]; @@ -87,7 +63,7 @@ in enable = mkEnableOption "GTK 2/3 configuration"; font = mkOption { - type = types.nullOr fontType; + type = types.nullOr hm.types.fontType; default = null; description = '' The font to use in GTK+ 2/3 applications. @@ -119,10 +95,20 @@ in }; gtk3 = { + bookmarks = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "file:///home/jane/Documents" ]; + description = "Bookmarks in the sidebar of the GTK file browser"; + }; + extraConfig = mkOption { type = with types; attrsOf (either bool (either int str)); - default = {}; - example = { gtk-cursor-blink = false; gtk-recent-files-limit = 20; }; + default = { }; + example = { + gtk-cursor-blink = false; + gtk-recent-files-limit = 20; + }; description = '' Extra configuration options to add to <filename>~/.config/gtk-3.0/settings.ini</filename>. @@ -141,48 +127,38 @@ in }; }; - config = mkIf cfg.enable ( - let - ini = - optionalAttrs (cfg.font != null) - { gtk-font-name = cfg.font.name; } - // - optionalAttrs (cfg.theme != null) - { gtk-theme-name = cfg.theme.name; } - // - optionalAttrs (cfg.iconTheme != null) - { gtk-icon-theme-name = cfg.iconTheme.name; }; - - dconfIni = - optionalAttrs (cfg.font != null) - { font-name = cfg.font.name; } - // - optionalAttrs (cfg.theme != null) - { gtk-theme = cfg.theme.name; } - // - optionalAttrs (cfg.iconTheme != null) - { icon-theme = cfg.iconTheme.name; }; - - optionalPackage = opt: - optional (opt != null && opt.package != null) opt.package; - in - { - home.packages = - optionalPackage cfg.font - ++ optionalPackage cfg.theme - ++ optionalPackage cfg.iconTheme; - - home.file.".gtkrc-2.0".text = - concatStringsSep "\n" ( - mapAttrsToList formatGtk2Option ini - ) + "\n" + cfg2.extraConfig; - - xdg.configFile."gtk-3.0/settings.ini".text = - toGtk3Ini { Settings = ini // cfg3.extraConfig; }; - - xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss; - - dconf.settings."org/gnome/desktop/interface" = dconfIni; - } - ); + config = mkIf cfg.enable (let + ini = optionalAttrs (cfg.font != null) { gtk-font-name = cfg.font.name; } + // optionalAttrs (cfg.theme != null) { gtk-theme-name = cfg.theme.name; } + // optionalAttrs (cfg.iconTheme != null) { + gtk-icon-theme-name = cfg.iconTheme.name; + }; + + dconfIni = optionalAttrs (cfg.font != null) { font-name = cfg.font.name; } + // optionalAttrs (cfg.theme != null) { gtk-theme = cfg.theme.name; } + // optionalAttrs (cfg.iconTheme != null) { + icon-theme = cfg.iconTheme.name; + }; + + optionalPackage = opt: + optional (opt != null && opt.package != null) opt.package; + in { + home.packages = optionalPackage cfg.font ++ optionalPackage cfg.theme + ++ optionalPackage cfg.iconTheme; + + home.file.".gtkrc-2.0".text = + concatStringsSep "\n" (mapAttrsToList formatGtk2Option ini) + "\n" + + cfg2.extraConfig; + + xdg.configFile."gtk-3.0/settings.ini".text = + toGtk3Ini { Settings = ini // cfg3.extraConfig; }; + + xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss; + + xdg.configFile."gtk-3.0/bookmarks" = mkIf (cfg3.bookmarks != [ ]) { + text = concatStringsSep "\n" cfg3.bookmarks; + }; + + dconf.settings."org/gnome/desktop/interface" = dconfIni; + }); } diff --git a/home-manager/modules/misc/news.nix b/home-manager/modules/misc/news.nix index 6b01617fc55..b031af99685 100644 --- a/home-manager/modules/misc/news.nix +++ b/home-manager/modules/misc/news.nix @@ -452,7 +452,7 @@ in { time = "2017-12-11T17:23:12+00:00"; - condition = config.home.activation ? reloadSystemD; + condition = config.home.activation ? reloadSystemd; message = '' The Boolean option 'systemd.user.startServices' is now available. When enabled the current naive systemd unit @@ -1318,6 +1318,361 @@ in A new module is available: 'programs.neomutt'. ''; } + + { + time = "2020-02-23T10:19:48+00:00"; + message = '' + A new module is available: 'programs.kitty'. + ''; + } + + { + time = "2020-02-26T21:20:55+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'wayland.windowManager.sway' + ''; + } + + { + time = "2020-03-04T18:55:03+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'programs.abook' + ''; + } + + { + time = "2020-03-07T11:43:26+00:00"; + condition = config.programs.fish.enable; + message = '' + The option 'programs.fish.functions' has been reworked in + order to support all available flags, such as + '--description', '--on-event', and more. + ''; + } + + { + time = "2020-03-07T13:11:43+00:00"; + condition = hostPlatform.isLinux; + message = '' + The NixOS module has a new option: 'home-manager.useGlobalPkgs'. + + This enables using the system configuration's 'pkgs' + argument in Home Manager. + + To learn more, see the installation section of the manual + + https://rycee.gitlab.io/home-manager/#sec-install-nixos-module + ''; + } + + { + time = "2020-03-07T14:12:50+00:00"; + message = '' + A new module is available: 'programs.lieer'. + ''; + } + + { + time = "2020-03-07T14:12:50+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.lieer'. + ''; + } + + { + time = "2020-03-15T16:55:28+00:00"; + condition = config.programs.firefox.enable; + message = '' + In anticipation of Firefox dropping support for extension + sideloading[1], we now install extensions directly to + Firefox profiles managed through Home Manager's + + 'programs.firefox.profiles' + + option. + + Unfortunately this will most likely trigger an "Existing + file is in the way" error when activating your configuration + since Firefox keeps a copy of the add-on in the location + Home Manager wants to overwrite. If this is the case, remove + the listed '.xpi' files and try again. + + This change also means that extensions installed through + Home Manager may disappear from unmanaged profiles in future + Firefox releases. + + [1] https://blog.mozilla.org/addons/2019/10/31/firefox-to-discontinue-sideloaded-extensions/ + ''; + } + + { + time = "2020-03-17T21:56:26+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.keynav'. + ''; + } + + { + time = "2020-03-24T22:17:20+00:00"; + condition = config.services.compton.enable; + message = '' + The 'services.compton' module has been deprecated and + instead the new module 'services.picom' should be used. This + is because Nixpkgs no longer packages compton, and instead + packages the (mostly) compatible fork called picom. + + The 'services.compton' and 'services.picom' modules have a + few differences: + + - 'services.picom' has a new 'experimentalBackends' + option. + + - 'vSync' is now a boolean value on 'services.picom', as + opposed to the string in 'services.compton'. + + Migrating to the new picom service is simple - just change + all references to 'services.compton' to 'services.picom', + and adhere to the above changes. + + The deprecated 'services.compton' will eventually be removed + in the future. Please update your configurations to use + 'services.picom' as soon as possible. + ''; + } + + { + time = "2020-04-08T09:33:05+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'targets.genericLinux'. + + When enabled, this module will configure various settings + and environment variables to make Home Manager and programs + installed through Nix work better on GNU/Linux distributions + other than NixOS. + + It should not be enabled if your Home Manager configuration + is deployed on a NixOS host. + ''; + } + + { + time = "2020-04-08T11:51:15+00:00"; + message = '' + A new module is available: 'programs.qutebrowser' + ''; + } + + { + time = "2020-04-09T09:19:38+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.mako' + ''; + } + + { + time = "2020-04-23T19:45:26+00:00"; + message = '' + A new module is available: 'programs.lf' + ''; + } + + { + time = "2020-04-26T13:46:28+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.pulseeffects' + ''; + } + + { + time = "2020-05-03T11:13:07+00:00"; + message = '' + A new module is available: 'programs.i3status' + ''; + } + + { + time = "2020-05-03T11:21:42+00:00"; + message = '' + A new module is available: 'programs.aria2' + ''; + } + + { + time = "2020-05-04T21:19:43+00:00"; + condition = config.programs.git.enable; + message = '' + The Git module now supports the 'delta' syntax highlighter. + + It can be enabled through the option 'programs.git.delta.enable'. + ''; + } + + { + time = "2020-05-12T20:09:54+00:00"; + message = '' + A new module is available: 'programs.dircolors' + ''; + } + + { + time = "2020-05-26T17:13:58+00:00"; + message = '' + A new module is available: 'programs.zoxide' + ''; + } + + { + time = "2020-06-03T17:46:11+00:00"; + condition = config.programs.ssh.enable; + message = '' + The ssh module now supports the 'ServerAliveCountMax' option + both globally through + + programs.ssh.serverAliveCountMax + + and per match blocks + + programs.ssh.matchBlocks.<name>.serverAliveCountMax + ''; + } + + { + time = "2020-06-11T18:06:37+00:00"; + condition = hostPlatform.isLinux && config.services.emacs.enable; + message = '' + The Emacs service now supports systemd socket activation. + + It can be enabled through the option 'services.emacs.socketActivation.enable'. + ''; + } + + { + time = "2020-06-12T17:48:01+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.clipmenu' + ''; + } + + { + time = "2020-06-12T07:08:09+00:00"; + condition = config.programs.bash.enable; + message = '' + A new module is available: 'programs.powerline-go' + ''; + } + + { + time = "2020-06-14T13:30:19+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'service.fluidsynth' + ''; + } + + { + time = "2020-06-17T22:17:52+00:00"; + condition = config.programs.git.enable; + message = '' + Since May 1, 2020 string values in Git configurations are + automatically escaped. If you have any manually escaped characters, + then you may need to restore them to their unescaped form to avoid + double escaping. + + In other words, if you now have something along the lines of + + programs.git.aliases.hello = '''"!echo $'Hello\\nWorld'"'''; + + you must replace it by the unescaped form + + programs.git.aliases.hello = "!echo $'Hello\nWorld'"; + + Apologies for the belated notification! + ''; + } + + { + time = "2020-06-23T20:06:39+00:00"; + message = '' + A new module is available: 'programs.ne' + ''; + } + + { + time = "2020-07-24T15:03:11+00:00"; + message = '' + A new module is available: 'programs.nushell'. + ''; + } + + { + time = "2020-07-25T21:04:59+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.dropbox'. + ''; + } + + { + time = "2020-08-13T22:15:27+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'programs.waybar' + ''; + } + + { + time = "2020-08-14T22:44:20+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.kanshi' + ''; + } + + { + time = "2020-08-25T22:14:01+00:00"; + message = '' + A new module is available: 'programs.mcfly' + ''; + } + + { + time = "2020-09-01T18:38:18+00:00"; + message = '' + A new module is available: 'programs.ncmpcpp' + ''; + } + + { + time = "2020-09-11T10:06:47+00:00"; + condition = hostPlatform.isLinux && config.targets.genericLinux.enable; + message = '' + A new option 'targets.genericLinux.extraXdgDataDirs' is available + to setup the user environment with the OS's data files. + + This is useful for example to get Bash completion for + 'systemctl' which shouldn't be installed through Home Manager. + + This is also useful to have non Home Manager applications + available in menus. + ''; + } + + { + time = "2020-09-09T06:54:59+00:00"; + condition = config.programs.man.enable; + message = '' + A new option 'programs.man.generateCaches' was added to + support the apropos command. + ''; + } ]; }; } diff --git a/home-manager/modules/misc/nixpkgs.nix b/home-manager/modules/misc/nixpkgs.nix index 7b0904a5f20..511dbec10b2 100644 --- a/home-manager/modules/misc/nixpkgs.nix +++ b/home-manager/modules/misc/nixpkgs.nix @@ -1,6 +1,6 @@ # Adapted from Nixpkgs. -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, pkgsPath, ... }: with lib; @@ -49,7 +49,7 @@ let merge = lib.mergeOneOption; }; - _pkgs = import <nixpkgs> ( + _pkgs = import pkgsPath ( filterAttrs (n: v: v != null) config.nixpkgs ); diff --git a/home-manager/modules/misc/numlock.nix b/home-manager/modules/misc/numlock.nix index 199dd317daa..c823f6dbdd2 100644 --- a/home-manager/modules/misc/numlock.nix +++ b/home-manager/modules/misc/numlock.nix @@ -7,6 +7,8 @@ let cfg = config.xsession.numlock; in { + meta.maintainers = [ maintainers.evanjs ]; + options = { xsession.numlock.enable = mkEnableOption "Num Lock"; }; config = mkIf cfg.enable { diff --git a/home-manager/modules/misc/tmpfiles.nix b/home-manager/modules/misc/tmpfiles.nix new file mode 100644 index 00000000000..c46fe2c553a --- /dev/null +++ b/home-manager/modules/misc/tmpfiles.nix @@ -0,0 +1,49 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.systemd.user.tmpfiles; + +in { + meta.maintainers = [ maintainers.dawidsowa ]; + + options.systemd.user.tmpfiles.rules = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "L /home/user/Documents - - - - /mnt/data/Documents" ]; + description = '' + Rules for creating and cleaning up temporary files + automatically. See + <citerefentry> + <refentrytitle>tmpfiles.d</refentrytitle> + <manvolnum>5</manvolnum> + </citerefentry> + for the exact format. + ''; + }; + + config = mkIf (cfg.rules != [ ]) { + xdg = { + dataFile."user-tmpfiles.d/home-manager.conf" = { + text = '' + # This file is created automatically and should not be modified. + # Please change the option ‘systemd.user.tmpfiles.rules’ instead. + ${concatStringsSep "\n" cfg.rules} + ''; + onChange = "${pkgs.systemd}/bin/systemd-tmpfiles --user --create"; + }; + configFile = { + "systemd/user/basic.target.wants/systemd-tmpfiles-setup.service".source = + "${pkgs.systemd}/example/systemd/user/systemd-tmpfiles-setup.service"; + "systemd/user/systemd-tmpfiles-setup.service".source = + "${pkgs.systemd}/example/systemd/user/systemd-tmpfiles-setup.service"; + "systemd/user/timers.target.wants/systemd-tmpfiles-clean.timer".source = + "${pkgs.systemd}/example/systemd/user/systemd-tmpfiles-clean.timer"; + "systemd/user/systemd-tmpfiles-clean.service".source = + "${pkgs.systemd}/example/systemd/user/systemd-tmpfiles-clean.service"; + }; + }; + }; +} diff --git a/home-manager/modules/misc/version.nix b/home-manager/modules/misc/version.nix index 1352aadc614..fbeb3ec539a 100644 --- a/home-manager/modules/misc/version.nix +++ b/home-manager/modules/misc/version.nix @@ -5,7 +5,7 @@ with lib; { options = { home.stateVersion = mkOption { - type = types.enum [ "18.09" "19.03" "19.09" "20.03" ]; + type = types.enum [ "18.09" "19.03" "19.09" "20.03" "20.09" ]; default = "18.09"; description = '' It is occasionally necessary for Home Manager to change diff --git a/home-manager/modules/misc/vte.nix b/home-manager/modules/misc/vte.nix new file mode 100644 index 00000000000..fbe38c0163e --- /dev/null +++ b/home-manager/modules/misc/vte.nix @@ -0,0 +1,51 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + meta.maintainers = [ maintainers.rycee ]; + + options.programs = let + description = '' + Whether to enable integration with terminals using the VTE + library. This will let the terminal track the current working + directory. + ''; + in { + bash.enableVteIntegration = mkEnableOption "" // { inherit description; }; + + zsh.enableVteIntegration = mkEnableOption "" // { inherit description; }; + }; + + config = mkMerge [ + (mkIf config.programs.bash.enableVteIntegration { + # Unfortunately we have to do a little dance here to fix two + # problems with the upstream vte.sh file: + # + # - It does `PROMPT_COMMAND="__vte_prompt_command"` which + # clobbers any previously assigned prompt command. + # + # - Its `__vte_prompt_command` function runs commands that will + # overwrite the exit status of the command the user ran. + programs.bash.initExtra = '' + __HM_PROMPT_COMMAND="''${PROMPT_COMMAND:+''${PROMPT_COMMAND%;};}__hm_vte_prompt_command" + . ${pkgs.vte}/etc/profile.d/vte.sh + if [[ $(type -t __vte_prompt_command) = function ]]; then + __hm_vte_prompt_command() { + local old_exit_status=$? + __vte_prompt_command + return $old_exit_status + } + PROMPT_COMMAND="$__HM_PROMPT_COMMAND" + fi + unset __HM_PROMPT_COMMAND + ''; + }) + + (mkIf config.programs.zsh.enableVteIntegration { + programs.zsh.initExtra = '' + . ${pkgs.vte}/etc/profile.d/vte.sh + ''; + }) + ]; +} diff --git a/home-manager/modules/misc/xdg-mime-apps.nix b/home-manager/modules/misc/xdg-mime-apps.nix index 7ba4083b3c0..81d2ba0fcbe 100644 --- a/home-manager/modules/misc/xdg-mime-apps.nix +++ b/home-manager/modules/misc/xdg-mime-apps.nix @@ -74,7 +74,7 @@ in { config = mkIf cfg.enable { # Deprecated but still used by some applications. - home.file.".local/share/applications/mimeapps.list".source = + xdg.dataFile."applications/mimeapps.list".source = config.xdg.configFile."mimeapps.list".source; xdg.configFile."mimeapps.list".text = diff --git a/home-manager/modules/misc/xdg-mime.nix b/home-manager/modules/misc/xdg-mime.nix index 32006e025ff..5999e1299c9 100644 --- a/home-manager/modules/misc/xdg-mime.nix +++ b/home-manager/modules/misc/xdg-mime.nix @@ -27,10 +27,18 @@ in { home.packages = [ # Explicitly install package to provide basic mime types. pkgs.shared-mime-info + + # Make sure the target directories will be real directories. + (pkgs.runCommandLocal "dummy-xdg-mime-dirs1" { } '' + mkdir -p $out/share/{applications,mime/packages} + '') + (pkgs.runCommandLocal "dummy-xdg-mime-dirs2" { } '' + mkdir -p $out/share/{applications,mime/packages} + '') ]; home.extraProfileCommands = '' - if [[ -w $out/share/mime && -d $out/share/mime/packages ]]; then + if [[ -w $out/share/mime && -w $out/share/mime/packages && -d $out/share/mime/packages ]]; then XDG_DATA_DIRS=$out/share \ PKGSYSTEM_ENABLE_FSYNC=0 \ ${pkgs.buildPackages.shared-mime-info}/bin/update-mime-database \ diff --git a/home-manager/modules/misc/xdg-user-dirs.nix b/home-manager/modules/misc/xdg-user-dirs.nix index da9d3c43ad9..a1db6b115a1 100644 --- a/home-manager/modules/misc/xdg-user-dirs.nix +++ b/home-manager/modules/misc/xdg-user-dirs.nix @@ -89,15 +89,22 @@ in { }; config = mkIf cfg.enable { - xdg.configFile."user-dirs.dirs".text = generators.toKeyValue { } ({ - XDG_DESKTOP_DIR = cfg.desktop; - XDG_DOCUMENTS_DIR = cfg.documents; - XDG_DOWNLOAD_DIR = cfg.download; - XDG_MUSIC_DIR = cfg.music; - XDG_PICTURES_DIR = cfg.pictures; - XDG_PUBLICSHARE_DIR = cfg.publicShare; - XDG_TEMPLATES_DIR = cfg.templates; - XDG_VIDEOS_DIR = cfg.videos; - } // cfg.extraConfig); + xdg.configFile."user-dirs.dirs".text = let + options = { + XDG_DESKTOP_DIR = cfg.desktop; + XDG_DOCUMENTS_DIR = cfg.documents; + XDG_DOWNLOAD_DIR = cfg.download; + XDG_MUSIC_DIR = cfg.music; + XDG_PICTURES_DIR = cfg.pictures; + XDG_PUBLICSHARE_DIR = cfg.publicShare; + XDG_TEMPLATES_DIR = cfg.templates; + XDG_VIDEOS_DIR = cfg.videos; + } // cfg.extraConfig; + + # For some reason, these need to be wrapped with quotes to be valid. + wrapped = mapAttrs (_: value: ''"${value}"'') options; + in generators.toKeyValue { } wrapped; + + xdg.configFile."user-dirs.conf".text = "enabled=False"; }; } diff --git a/home-manager/modules/misc/xdg.nix b/home-manager/modules/misc/xdg.nix index 84ab4ada59a..7420e8e92b3 100644 --- a/home-manager/modules/misc/xdg.nix +++ b/home-manager/modules/misc/xdg.nix @@ -85,12 +85,20 @@ in }; }) - (mkIf (!cfg.enable) { + # Legacy non-deterministic setup. + (mkIf (!cfg.enable && versionOlder config.home.stateVersion "20.09") { xdg.cacheHome = getXdgDir "XDG_CACHE_HOME" defaultCacheHome; xdg.configHome = getXdgDir "XDG_CONFIG_HOME" defaultConfigHome; xdg.dataHome = getXdgDir "XDG_DATA_HOME" defaultDataHome; }) + # "Modern" deterministic setup. + (mkIf (!cfg.enable && versionAtLeast config.home.stateVersion "20.09") { + xdg.cacheHome = mkDefault defaultCacheHome; + xdg.configHome = mkDefault defaultConfigHome; + xdg.dataHome = mkDefault defaultDataHome; + }) + { home.file = mkMerge [ cfg.configFile |