mirror of
https://github.com/nix-community/home-manager
synced 2024-12-05 01:19:46 +01:00
038630363e
* xdg-mime: allow overrides to shared-mime-info and desktop-file-utils The `xdg-mime` module now exposes packages to determine what will be run for update-mime-database and update-desktop-database. This allows users to select a different version of these packages if the are incompatible. This should, in combination with an override to the version of `shared-mime-info` (can be found here notalltim/home-manager-config#4), resolve #4955, #5102, #4682, and possibly #4941. The problem seems to stem from a mismatch in the version of `shared-mime-info` with the host. I also switched from using `buildPackages` to `pkgs` to improve cross-compilation compatibility. * xdg-mime: Add tests for xdg-mime module The xdg-mime module was missing tests so I added basic test for all the options and checked the basic behavior. It covers ensuring that the proper files/folders are created and that the package overrides work.
77 lines
2.3 KiB
Nix
77 lines
2.3 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.xdg.mime;
|
|
inherit (lib) getExe getExe';
|
|
|
|
in {
|
|
options = {
|
|
xdg.mime = {
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = pkgs.stdenv.hostPlatform.isLinux;
|
|
defaultText =
|
|
literalExpression "true if host platform is Linux, false otherwise";
|
|
description = ''
|
|
Whether to install programs and files to support the
|
|
XDG Shared MIME-info specification and XDG MIME Applications
|
|
specification at
|
|
<https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html>
|
|
and
|
|
<https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-latest.html>,
|
|
respectively.
|
|
'';
|
|
};
|
|
|
|
sharedMimeInfoPackage = mkOption {
|
|
type = types.package;
|
|
default = pkgs.shared-mime-info;
|
|
defaultText = literalExpression "pkgs.shared-mime-info";
|
|
description = "The package to use when running update-mime-database.";
|
|
};
|
|
|
|
desktopFileUtilsPackage = mkOption {
|
|
type = types.package;
|
|
default = pkgs.desktop-file-utils;
|
|
defaultText = literalExpression "pkgs.desktop-file-utils";
|
|
description =
|
|
"The package to use when running update-desktop-database.";
|
|
};
|
|
};
|
|
};
|
|
config = mkIf cfg.enable {
|
|
assertions =
|
|
[ (hm.assertions.assertPlatform "xdg.mime" pkgs platforms.linux) ];
|
|
|
|
home.packages = [
|
|
# Explicitly install package to provide basic mime types.
|
|
cfg.sharedMimeInfoPackage
|
|
|
|
# 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 && -w $out/share/mime/packages && -d $out/share/mime/packages ]]; then
|
|
XDG_DATA_DIRS=$out/share \
|
|
PKGSYSTEM_ENABLE_FSYNC=0 \
|
|
${getExe cfg.sharedMimeInfoPackage} \
|
|
-V $out/share/mime > /dev/null
|
|
fi
|
|
|
|
if [[ -w $out/share/applications ]]; then
|
|
${getExe' cfg.desktopFileUtilsPackage "update-desktop-database"} \
|
|
$out/share/applications
|
|
fi
|
|
'';
|
|
};
|
|
|
|
}
|