mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-11 17:39:37 +08:00
streamlink: deduplicate platform-dependent files
This commit is contained in:
committed by
Austin Horstman
parent
72476602b9
commit
cd74467526
@@ -9,6 +9,11 @@ let
|
||||
|
||||
cfg = config.programs.streamlink;
|
||||
|
||||
configDir =
|
||||
if pkgs.stdenv.hostPlatform.isDarwin then "Library/Application Support" else config.xdg.configHome;
|
||||
dataDir =
|
||||
if pkgs.stdenv.hostPlatform.isDarwin then "Library/Application Support" else config.xdg.dataHome;
|
||||
|
||||
renderSettings =
|
||||
settings:
|
||||
lib.concatLines (
|
||||
@@ -130,51 +135,17 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable (
|
||||
lib.mkMerge [
|
||||
{ home.packages = lib.mkIf (cfg.package != null) [ cfg.package ]; }
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||
|
||||
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux {
|
||||
xdg.configFile = {
|
||||
"streamlink/config" = lib.mkIf (cfg.settings != { }) {
|
||||
text = renderSettings cfg.settings;
|
||||
};
|
||||
}
|
||||
// (lib.mapAttrs' (
|
||||
name: value:
|
||||
lib.nameValuePair "streamlink/config.${name}" (
|
||||
lib.mkIf (value.settings != { }) {
|
||||
text = renderSettings value.settings;
|
||||
}
|
||||
)
|
||||
) cfg.plugins);
|
||||
|
||||
xdg.dataFile = lib.mapAttrs' (
|
||||
name: value:
|
||||
lib.nameValuePair "streamlink/plugins/${name}.py" (
|
||||
lib.mkIf (value.src != null) (
|
||||
if (builtins.isPath value.src) then
|
||||
{
|
||||
source = value.src;
|
||||
}
|
||||
else
|
||||
{
|
||||
text = value.src;
|
||||
}
|
||||
)
|
||||
)
|
||||
) cfg.plugins;
|
||||
})
|
||||
|
||||
(lib.mkIf pkgs.stdenv.hostPlatform.isDarwin {
|
||||
home.file = {
|
||||
"Library/Application Support/streamlink/config" = lib.mkIf (cfg.settings != { }) {
|
||||
"${configDir}/streamlink/config" = lib.mkIf (cfg.settings != { }) {
|
||||
text = renderSettings cfg.settings;
|
||||
};
|
||||
}
|
||||
// (lib.mapAttrs' (
|
||||
name: value:
|
||||
lib.nameValuePair "Library/Application Support/streamlink/config.${name}" (
|
||||
lib.nameValuePair "${configDir}/streamlink/config.${name}" (
|
||||
lib.mkIf (value.settings != { }) {
|
||||
text = renderSettings value.settings;
|
||||
}
|
||||
@@ -182,7 +153,7 @@ in
|
||||
) cfg.plugins)
|
||||
// (lib.mapAttrs' (
|
||||
name: value:
|
||||
lib.nameValuePair "Library/Application Support/streamlink/plugins/${name}.py" (
|
||||
lib.nameValuePair "${dataDir}/streamlink/plugins/${name}.py" (
|
||||
lib.mkIf (value.src != null) (
|
||||
if (builtins.isPath value.src) then
|
||||
{
|
||||
@@ -195,7 +166,5 @@ in
|
||||
)
|
||||
)
|
||||
) cfg.plugins);
|
||||
})
|
||||
]
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user