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;
|
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 =
|
renderSettings =
|
||||||
settings:
|
settings:
|
||||||
lib.concatLines (
|
lib.concatLines (
|
||||||
@@ -130,72 +135,36 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable (
|
config = lib.mkIf cfg.enable {
|
||||||
lib.mkMerge [
|
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||||
{ home.packages = lib.mkIf (cfg.package != null) [ cfg.package ]; }
|
|
||||||
|
|
||||||
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux {
|
home.file = {
|
||||||
xdg.configFile = {
|
"${configDir}/streamlink/config" = lib.mkIf (cfg.settings != { }) {
|
||||||
"streamlink/config" = lib.mkIf (cfg.settings != { }) {
|
text = renderSettings cfg.settings;
|
||||||
text = renderSettings cfg.settings;
|
};
|
||||||
};
|
}
|
||||||
|
// (lib.mapAttrs' (
|
||||||
|
name: value:
|
||||||
|
lib.nameValuePair "${configDir}/streamlink/config.${name}" (
|
||||||
|
lib.mkIf (value.settings != { }) {
|
||||||
|
text = renderSettings value.settings;
|
||||||
}
|
}
|
||||||
// (lib.mapAttrs' (
|
)
|
||||||
name: value:
|
) cfg.plugins)
|
||||||
lib.nameValuePair "streamlink/config.${name}" (
|
// (lib.mapAttrs' (
|
||||||
lib.mkIf (value.settings != { }) {
|
name: value:
|
||||||
text = renderSettings value.settings;
|
lib.nameValuePair "${dataDir}/streamlink/plugins/${name}.py" (
|
||||||
|
lib.mkIf (value.src != null) (
|
||||||
|
if (builtins.isPath value.src) then
|
||||||
|
{
|
||||||
|
source = value.src;
|
||||||
}
|
}
|
||||||
)
|
else
|
||||||
) cfg.plugins);
|
{
|
||||||
|
text = value.src;
|
||||||
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 != { }) {
|
|
||||||
text = renderSettings cfg.settings;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// (lib.mapAttrs' (
|
|
||||||
name: value:
|
|
||||||
lib.nameValuePair "Library/Application Support/streamlink/config.${name}" (
|
|
||||||
lib.mkIf (value.settings != { }) {
|
|
||||||
text = renderSettings value.settings;
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
) cfg.plugins)
|
)
|
||||||
// (lib.mapAttrs' (
|
) cfg.plugins);
|
||||||
name: value:
|
};
|
||||||
lib.nameValuePair "Library/Application Support/streamlink/plugins/${name}.py" (
|
|
||||||
lib.mkIf (value.src != null) (
|
|
||||||
if (builtins.isPath value.src) then
|
|
||||||
{
|
|
||||||
source = value.src;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
text = value.src;
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) cfg.plugins);
|
|
||||||
})
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user