fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . xdg . mime ; 8 9in { 10options = { 11xdg . mime . enable = mkOption { 12type = types . bool ; 13default = pkgs . stdenv . hostPlatform . isLinux ; 14defaultText = 15literalExpression "true if host platform is Linux, false otherwise" ; 16description = '' 17Whether to install programs and files to support the 18XDG Shared MIME-info specification and XDG MIME Applications 19specification at 20<https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html> 21and 22<https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-latest.html>, 23respectively. 24'' ; 25}; 26}; 27 28config = mkIf config . xdg . mime . enable { 29assertions = 30[ ( hm . assertions . assertPlatform "xdg.mime" pkgs platforms . linux ) ]; 31 32home . packages = [ 33# Explicitly install package to provide basic mime types. 34pkgs . shared-mime-info 35 36# Make sure the target directories will be real directories. 37( pkgs . runCommandLocal "dummy-xdg-mime-dirs1" { } '' 38mkdir -p $ out /share/{applications,mime/packages} 39'' ) 40( pkgs . runCommandLocal "dummy-xdg-mime-dirs2" { } '' 41mkdir -p $ out /share/{applications,mime/packages} 42'' ) 43]; 44 45home . extraProfileCommands = '' 46if [[ -w $out/share/mime && -w $out/share/mime/packages && -d $out/share/mime/packages ]]; then 47XDG_DATA_DIRS=$out/share \ 48PKGSYSTEM_ENABLE_FSYNC=0 \ 49${ pkgs . buildPackages . shared-mime-info } /bin/update-mime-database \ 50-V $out/share/mime > /dev/null 51fi 52 53if [[ -w $out/share/applications ]]; then 54${ pkgs . buildPackages . desktop-file-utils } /bin/update-desktop-database \ 55$out/share/applications 56fi 57'' ; 58}; 59 60}