mirror of
https://github.com/nix-community/home-manager
synced 2024-11-16 08:09:45 +01:00
36a53d9f26
This process was automated by [my fork of `nix-doc-munge`]. All conversions were automatically checked to produce the same DocBook result when converted back, modulo minor typographical/formatting differences on the acceptable-to-desirable spectrum. To reproduce this commit, run: $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \ nix shell nixpkgs#coreutils \ -c find . -name '*.nix' \ -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \ {} + $ ./format [my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
60 lines
1.8 KiB
Nix
60 lines
1.8 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.xdg.mime;
|
|
|
|
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 = lib.mdDoc ''
|
|
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.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf config.xdg.mime.enable {
|
|
assertions =
|
|
[ (hm.assertions.assertPlatform "xdg.mime" pkgs platforms.linux) ];
|
|
|
|
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 && -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 \
|
|
-V $out/share/mime > /dev/null
|
|
fi
|
|
|
|
if [[ -w $out/share/applications ]]; then
|
|
${pkgs.buildPackages.desktop-file-utils}/bin/update-desktop-database \
|
|
$out/share/applications
|
|
fi
|
|
'';
|
|
};
|
|
|
|
}
|