xdg-desktop-entries: adjust to API changes
The `makeDesktopItem` function changed in a backwards incompatible way
in
0c713dbed4
This commit updates the module accordingly.
Fixes #2767
This commit is contained in:
parent
ea85f4b1fd
commit
e58a7cb13d
|
@ -4,6 +4,10 @@ with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
desktopEntry = {
|
desktopEntry = {
|
||||||
|
imports = [
|
||||||
|
(mkRemovedOptionModule [ "extraConfig" ]
|
||||||
|
"The `extraConfig` option of `xdg.desktopEntries` has been removed following a change in Nixpkgs.")
|
||||||
|
];
|
||||||
options = {
|
options = {
|
||||||
# Since this module uses the nixpkgs/pkgs/build-support/make-desktopitem function,
|
# Since this module uses the nixpkgs/pkgs/build-support/make-desktopitem function,
|
||||||
# our options and defaults follow its parameters, with the following exceptions:
|
# our options and defaults follow its parameters, with the following exceptions:
|
||||||
|
@ -13,13 +17,9 @@ let
|
||||||
# `name` on makeDesktopItem is controlled by this module's key in the attrset.
|
# `name` on makeDesktopItem is controlled by this module's key in the attrset.
|
||||||
# This is the file's filename excluding ".desktop".
|
# This is the file's filename excluding ".desktop".
|
||||||
|
|
||||||
# `extraEntries` on makeDesktopItem is controlled by `extraConfig`,
|
# `extraConfig` on makeDesktopItem is controlled by `settings`,
|
||||||
# and `extraDesktopEntries` by `settings`,
|
|
||||||
# to match what's commonly used by other home manager modules.
|
# to match what's commonly used by other home manager modules.
|
||||||
|
|
||||||
# `mimeType` and `categories` on makeDesktopItem ask for a string in the format "one;two;three;",
|
|
||||||
# for usability's sake we ask for a list of strings.
|
|
||||||
|
|
||||||
# Descriptions are taken from the desktop entry spec:
|
# Descriptions are taken from the desktop entry spec:
|
||||||
# https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys
|
# https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ let
|
||||||
|
|
||||||
exec = mkOption {
|
exec = mkOption {
|
||||||
description = "Program to execute, possibly with arguments.";
|
description = "Program to execute, possibly with arguments.";
|
||||||
type = types.str;
|
type = types.nullOr types.str;
|
||||||
};
|
};
|
||||||
|
|
||||||
icon = mkOption {
|
icon = mkOption {
|
||||||
|
@ -103,15 +103,6 @@ let
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = mkOption {
|
|
||||||
description = ''
|
|
||||||
Extra configuration. Will be appended to the end of the file and
|
|
||||||
may thus contain extra sections.
|
|
||||||
'';
|
|
||||||
type = types.lines;
|
|
||||||
default = "";
|
|
||||||
};
|
|
||||||
|
|
||||||
settings = mkOption {
|
settings = mkOption {
|
||||||
type = types.attrsOf types.string;
|
type = types.attrsOf types.string;
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -132,11 +123,19 @@ let
|
||||||
description = "Whether to validate the generated desktop file.";
|
description = "Whether to validate the generated desktop file.";
|
||||||
default = true;
|
default = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Required for the assertions
|
||||||
|
# TODO: Remove me once `mkRemovedOptionModule` works correctly with submodules
|
||||||
|
assertions = mkOption {
|
||||||
|
type = types.listOf types.unspecified;
|
||||||
|
default = [ ];
|
||||||
|
visible = false;
|
||||||
|
internal = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#formatting helpers
|
#formatting helpers
|
||||||
ifNotNull = a: a': if a == null then null else a';
|
|
||||||
semicolonList = list:
|
semicolonList = list:
|
||||||
(concatStringsSep ";" list) + ";"; # requires trailing semicolon
|
(concatStringsSep ";" list) + ";"; # requires trailing semicolon
|
||||||
|
|
||||||
|
@ -148,11 +147,9 @@ let
|
||||||
type exec icon comment terminal genericName startupNotify noDisplay
|
type exec icon comment terminal genericName startupNotify noDisplay
|
||||||
prefersNonDefaultGPU;
|
prefersNonDefaultGPU;
|
||||||
desktopName = config.name;
|
desktopName = config.name;
|
||||||
mimeType = ifNotNull config.mimeType (semicolonList config.mimeType);
|
mimeTypes = optionals (config.mimeType != null) config.mimeType;
|
||||||
categories =
|
categories = optionals (config.categories != null) config.categories;
|
||||||
ifNotNull config.categories (semicolonList config.categories);
|
extraConfig = config.settings;
|
||||||
extraEntries = config.extraConfig;
|
|
||||||
extraDesktopEntries = config.settings;
|
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
meta.maintainers = [ hm.maintainers.cwyc ];
|
meta.maintainers = [ hm.maintainers.cwyc ];
|
||||||
|
@ -182,7 +179,7 @@ in {
|
||||||
config = mkIf (config.xdg.desktopEntries != { }) {
|
config = mkIf (config.xdg.desktopEntries != { }) {
|
||||||
assertions = [
|
assertions = [
|
||||||
(hm.assertions.assertPlatform "xdg.desktopEntries" pkgs platforms.linux)
|
(hm.assertions.assertPlatform "xdg.desktopEntries" pkgs platforms.linux)
|
||||||
];
|
] ++ flatten (catAttrs "assertions" (attrValues config.xdg.desktopEntries));
|
||||||
|
|
||||||
home.packages = (map hiPrio # we need hiPrio to override existing entries
|
home.packages = (map hiPrio # we need hiPrio to override existing entries
|
||||||
(attrsets.mapAttrsToList makeFile config.xdg.desktopEntries));
|
(attrsets.mapAttrsToList makeFile config.xdg.desktopEntries));
|
||||||
|
|
|
@ -48,6 +48,13 @@ with lib;
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
|
test.asserts.assertions.expected =
|
||||||
|
let currentFile = toString ./desktop-entries.nix;
|
||||||
|
in [''
|
||||||
|
The option definition `extraConfig' in `${currentFile}' no longer has any effect; please remove it.
|
||||||
|
The `extraConfig` option of `xdg.desktopEntries` has been removed following a change in Nixpkgs.
|
||||||
|
''];
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists home-path/share/applications/full.desktop
|
assertFileExists home-path/share/applications/full.desktop
|
||||||
assertFileExists home-path/share/applications/min.desktop
|
assertFileExists home-path/share/applications/min.desktop
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Categories=Network;WebBrowser;
|
Categories=Network;WebBrowser
|
||||||
Comment=My Application
|
Comment=My Application
|
||||||
DBusActivatable=false
|
DBusActivatable=false
|
||||||
Exec=test --option
|
Exec=test --option
|
||||||
GenericName=Web Browser
|
GenericName=Web Browser
|
||||||
Icon=test
|
Icon=test
|
||||||
Keywords=calc;math
|
Keywords=calc;math
|
||||||
MimeType=text/html;text/xml;
|
MimeType=text/html;text/xml
|
||||||
Name=Test
|
Name=Test
|
||||||
NoDisplay=false
|
NoDisplay=false
|
||||||
PrefersNonDefaultGPU=false
|
PrefersNonDefaultGPU=false
|
||||||
StartupNotify=false
|
StartupNotify=false
|
||||||
Terminal=true
|
Terminal=true
|
||||||
Type=Application
|
Type=Application
|
||||||
[X-ExtraSection]
|
Version=1.4
|
||||||
Exec=foo -o
|
|
||||||
|
|
||||||
|
|
|
@ -3,3 +3,4 @@ Exec=test --option
|
||||||
Name=Test
|
Name=Test
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Type=Application
|
Type=Application
|
||||||
|
Version=1.4
|
||||||
|
|
Loading…
Reference in a new issue