forked from nix-community/home-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xdg-mime type package options (nix-community#5920)
* 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 nix-community#4955, nix-community#5102, nix-community#4682, and possibly nix-community#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.
- Loading branch information
Showing
6 changed files
with
114 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ ... }: { | ||
config = { | ||
xdg.mime.enable = false; | ||
nmt.script = '' | ||
# assert that neither application is run | ||
assertPathNotExists home-path/share/applications/mimeinfo.cache | ||
assertPathNotExists home-path/share/applications/mime | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[MIME Cache] | ||
text/html=mime-test.desktop; | ||
text/xml=mime-test.desktop; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ config, ... }: | ||
let inherit (config.lib.test) mkStubPackage; | ||
in { | ||
config = { | ||
xdg.mime.enable = true; | ||
xdg.mime.sharedMimeInfoPackage = mkStubPackage { | ||
name = "update-mime-database"; | ||
buildScript = '' | ||
mkdir -p $out/bin | ||
echo '#!/bin/sh' > $out/bin/update-mime-database | ||
echo 'mkdir -p $out/share/mime && touch $out/share/mime/mime.cache' >> $out/bin/update-mime-database | ||
chmod +x $out/bin/update-mime-database | ||
''; | ||
}; | ||
xdg.mime.desktopFileUtilsPackage = mkStubPackage { | ||
name = "desktop-file-utils"; | ||
buildScript = '' | ||
mkdir -p $out/bin | ||
echo '#!/bin/sh' > $out/bin/update-desktop-database | ||
echo 'mkdir -p $out/share/applications/ && ln -s ${ | ||
./mime-expected.cache | ||
} $out/share/applications/mimeinfo.cache' >> $out/bin/update-desktop-database | ||
chmod +x $out/bin/update-desktop-database | ||
''; | ||
}; | ||
nmt.script = '' | ||
assertFileExists home-path/share/applications/mimeinfo.cache # Check that update-desktop-database created file | ||
# Check that update-desktop-database file matches expected | ||
assertFileContent \ | ||
home-path/share/applications/mimeinfo.cache \ | ||
${./mime-expected.cache} | ||
assertDirectoryExists home-path/share/mime # Check that update-mime-database created directory | ||
assertFileExists home-path/share/mime/mime.cache # Check that update-mime-database created file | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ ... }: { | ||
config = { | ||
xdg.mime.enable = true; | ||
xdg.desktopEntries = { | ||
mime-test = { # mime info test | ||
name = "mime-test"; | ||
mimeType = [ "text/html" "text/xml" ]; | ||
}; | ||
|
||
}; | ||
|
||
nmt.script = '' | ||
assertFileExists home-path/share/applications/mimeinfo.cache # Check that update-desktop-database created file | ||
# Check that update-desktop-database file matches expected | ||
assertFileContent \ | ||
home-path/share/applications/mimeinfo.cache \ | ||
${./mime-expected.cache} | ||
assertDirectoryExists home-path/share/mime # Check that update-mime-database created directory | ||
assertDirectoryNotEmpty home-path/share/mime # Check that update-mime-database created files | ||
''; | ||
}; | ||
} |