1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00

xdg-mime-apps: add defaultApplicationPackages option

This option allows a user to inject default applications directly from
a list of specified packages. It was previously possible to do this,
but only through import from derivation.
This commit is contained in:
Robert Helgesson 2025-09-18 12:56:55 +02:00
parent e387519338
commit efcba687d3
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED
4 changed files with 102 additions and 38 deletions

View file

@ -50,6 +50,7 @@ let
inner = self: super: {
inherit (pkgs)
coreutils
crudini
jq
desktop-file-utils
diffutils

View file

@ -1,9 +1,10 @@
[Added Associations]
mimetype1=foo1.desktop;foo2.desktop;foo3.desktop
mimetype2=foo4.desktop
image/jpeg=foo4.desktop
image/png=foo1.desktop;foo2.desktop;foo3.desktop
[Default Applications]
mimetype1=default1.desktop;default2.desktop
image/png=default1.desktop;default2.desktop;test.desktop
image/svg+xml = test.desktop
[Removed Associations]
mimetype1=foo5.desktop
image/png=foo5.desktop

View file

@ -1,33 +1,44 @@
{ pkgs, ... }:
{
config = {
xdg.mimeApps = {
enable = true;
associations = {
added = {
"mimetype1" = [
"foo1.desktop"
"foo2.desktop"
"foo3.desktop"
];
"mimetype2" = "foo4.desktop";
};
removed = {
mimetype1 = "foo5.desktop";
};
};
defaultApplications = {
"mimetype1" = [
"default1.desktop"
"default2.desktop"
xdg.mimeApps = {
enable = true;
associations = {
added = {
"image/png" = [
"foo1.desktop"
"foo2.desktop"
"foo3.desktop"
];
"image/jpeg" = "foo4.desktop";
};
removed = {
"image/png" = "foo5.desktop";
};
};
nmt.script = ''
assertFileExists home-files/.config/mimeapps.list
assertFileContent \
home-files/.config/mimeapps.list \
${./mime-apps-basics-expected.ini}
'';
defaultApplications = {
"image/png" = [
"default1.desktop"
"default2.desktop"
];
};
defaultApplicationPackages = [
(pkgs.makeDesktopItem {
type = "Application";
name = "test";
desktopName = "Test";
mimeTypes = [
"image/png"
"image/svg+xml"
];
})
];
};
nmt.script = ''
assertFileExists home-files/.config/mimeapps.list
assertFileContent \
home-files/.config/mimeapps.list \
${./mime-apps-basics-expected.ini}
'';
}