Use alejandra formatter / fix warnings

This commit is contained in:
DashieTM 2025-02-15 16:23:22 +01:00
parent c5b1041bbb
commit 693d4e3c70
70 changed files with 1424 additions and 1547 deletions

View file

@ -5,19 +5,14 @@
lib,
options,
...
}:
let
}: let
browserName =
if (builtins.isString config.mods.homePackages.browser) then
config.mods.homePackages.browser
else if
config.mods.homePackages.browser ? meta && config.mods.homePackages.browser.meta ? mainProgram
then
config.mods.homePackages.browser.meta.mainProgram
else
config.mods.homePackages.browser.pname;
in
{
if (builtins.isString config.mods.homePackages.browser)
then config.mods.homePackages.browser
else if config.mods.homePackages.browser ? meta && config.mods.homePackages.browser.meta ? mainProgram
then config.mods.homePackages.browser.meta.mainProgram
else config.mods.homePackages.browser.pname;
in {
options.mods.mime = {
enable = lib.mkOption {
default = true;
@ -32,7 +27,7 @@ in
"jpeg"
"gif"
];
example = [ ];
example = [];
type = with lib.types; listOf str;
description = "Image mime handlers";
};
@ -42,7 +37,7 @@ in
"avi"
"mkv"
];
example = [ ];
example = [];
type = with lib.types; listOf str;
description = "Video mime handlers";
};
@ -53,7 +48,7 @@ in
"wav"
"aac"
];
example = [ ];
example = [];
type = with lib.types; listOf str;
description = "Audio mime handlers";
};
@ -66,7 +61,7 @@ in
"x-extension-xht"
"x-extension-xhtml"
];
example = [ ];
example = [];
type = with lib.types; listOf str;
description = "Browser mime handlers";
};
@ -78,71 +73,71 @@ in
"https"
"unknown"
];
example = [ ];
example = [];
type = with lib.types; listOf str;
description = "Browser X mime handlers";
};
browserApplications = lib.mkOption {
default = [ "${browserName}" ];
example = [ ];
default = ["${browserName}"];
example = [];
type = with lib.types; listOf str;
description = "Applications used for handling browser mime types";
};
imageApplications = lib.mkOption {
default = [ "imv" ];
example = [ ];
default = ["imv"];
example = [];
type = with lib.types; listOf str;
description = "Applications used for handling image mime types";
};
videoApplications = lib.mkOption {
default = [ "mpv" ];
example = [ ];
default = ["mpv"];
example = [];
type = with lib.types; listOf str;
description = "Applications used for handling video mime types";
};
audioApplications = lib.mkOption {
default = [ "io.bassi.Amberol" ];
example = [ ];
default = ["io.bassi.Amberol"];
example = [];
type = with lib.types; listOf str;
description = "Applications used for handling audio mime types";
};
# TODO additional config
};
config = lib.optionalAttrs (options ? home) {
xdg =
let
xdgAssociations =
type: program: list:
builtins.listToAttrs (
map (e: {
name = "${type}/${e}";
value = program;
}) list
);
imageAc = xdgAssociations "image" config.mods.mime.imageApplications config.mods.mime.imageTypes;
videoAc = xdgAssociations "video" config.mods.mime.videoApplications config.mods.mime.videoTypes;
audioAc = xdgAssociations "audio" config.mods.mime.audioApplications config.mods.mime.audioTypes;
browserAc =
(xdgAssociations "application" config.mods.mime.browserApplications config.mods.mime.browserTypes)
// (xdgAssociations "x-scheme-handler" config.mods.mime.browserApplications
config.mods.mime.browserXTypes
);
associations = builtins.mapAttrs (_: v: (map (e: "${e}.desktop") v)) (
# TODO make configurable
{
"application/pdf" = [ "org.pwmt.zathura-pdf-mupdf" ];
"text/html" = config.mods.mime.browserApplications;
"text/plain" = [ "neovide" ];
"x-scheme-handler/chrome" = [ "com.brave.browser" ];
"inode/directory" = [ "yazi" ];
}
// imageAc
// audioAc
// videoAc
// browserAc
xdg = let
xdgAssociations = type: program: list:
builtins.listToAttrs (
map (e: {
name = "${type}/${e}";
value = program;
})
list
);
in
imageAc = xdgAssociations "image" config.mods.mime.imageApplications config.mods.mime.imageTypes;
videoAc = xdgAssociations "video" config.mods.mime.videoApplications config.mods.mime.videoTypes;
audioAc = xdgAssociations "audio" config.mods.mime.audioApplications config.mods.mime.audioTypes;
browserAc =
(xdgAssociations "application" config.mods.mime.browserApplications config.mods.mime.browserTypes)
// (
xdgAssociations "x-scheme-handler" config.mods.mime.browserApplications
config.mods.mime.browserXTypes
);
associations = builtins.mapAttrs (_: v: (map (e: "${e}.desktop") v)) (
# TODO make configurable
{
"application/pdf" = ["org.pwmt.zathura-pdf-mupdf"];
"text/html" = config.mods.mime.browserApplications;
"text/plain" = ["neovide"];
"x-scheme-handler/chrome" = ["com.brave.browser"];
"inode/directory" = ["yazi"];
}
// imageAc
// audioAc
// videoAc
// browserAc
);
in
lib.mkIf config.mods.mime.enable {
enable = true;
cacheHome = config.home.homeDirectory + "/.local/cache";