uget: add programs.uget to manage uget/uget-integrator
This commit is contained in:
parent
78125bc681
commit
e5e18d54ec
|
@ -213,6 +213,7 @@ let
|
||||||
./programs/tmux.nix
|
./programs/tmux.nix
|
||||||
./programs/topgrade.nix
|
./programs/topgrade.nix
|
||||||
./programs/translate-shell.nix
|
./programs/translate-shell.nix
|
||||||
|
./programs/uget.nix
|
||||||
./programs/urxvt.nix
|
./programs/urxvt.nix
|
||||||
./programs/vdirsyncer.nix
|
./programs/vdirsyncer.nix
|
||||||
./programs/vim.nix
|
./programs/vim.nix
|
||||||
|
|
127
modules/programs/uget.nix
Normal file
127
modules/programs/uget.nix
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
cfg = config.programs.uget;
|
||||||
|
browsers = [ "brave" "chrome" "chromium" "firefox" "librewolf" "vivaldi" ];
|
||||||
|
|
||||||
|
in {
|
||||||
|
meta.maintainers = [ maintainers.poelzi ];
|
||||||
|
|
||||||
|
options.programs.uget = {
|
||||||
|
enable = mkEnableOption "uget download manager";
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
default = pkgs.uget;
|
||||||
|
defaultText = literalExpression "pkgs.uget";
|
||||||
|
description = "uget package to install.";
|
||||||
|
};
|
||||||
|
|
||||||
|
integrator = {
|
||||||
|
package = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
default = pkgs.uget-integrator;
|
||||||
|
defaultText = literalExpression "pkgs.uget-integrator";
|
||||||
|
description = "uget-integrator package to install.";
|
||||||
|
};
|
||||||
|
|
||||||
|
enable = mkEnableOption "the uget-integrator extension host application";
|
||||||
|
|
||||||
|
browsers = mkOption {
|
||||||
|
type = types.listOf (types.enum browsers);
|
||||||
|
default = browsers;
|
||||||
|
example = [ "firefox" ];
|
||||||
|
description = "Which browsers to install browserpass for";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
home.packages = [ cfg.package ]
|
||||||
|
++ (lib.lists.optional cfg.integrator.enable cfg.integrator.package);
|
||||||
|
|
||||||
|
# home.file = browser-extension.nativeHostFiles cfg.integrator.browsers (
|
||||||
|
# fold (x: y: x // {"${y}" = "${cfg.integrator.package}/lib/mozilla/native-messaging-hosts/com.ugetdm.firefox.json";}));
|
||||||
|
home.file = foldl' (a: b: a // b) { } (concatMap (x:
|
||||||
|
with pkgs.stdenv;
|
||||||
|
if x == "brave" then
|
||||||
|
let
|
||||||
|
dir = if isDarwin then
|
||||||
|
"Library/Application Support/BraveSoftware/Brave-Browser/NativeMessagingHosts"
|
||||||
|
else
|
||||||
|
".config/BraveSoftware/Brave-Browser/NativeMessagingHosts";
|
||||||
|
in [{
|
||||||
|
# Policies are read from `/etc/brave/policies` only
|
||||||
|
# https://github.com/brave/brave-browser/issues/19052
|
||||||
|
"${dir}/com.ugetdm.firefox.json".source =
|
||||||
|
"${pkgs.uget-integrator}/lib/mozilla/native-messaging-hosts/com.ugetdm.firefox.json";
|
||||||
|
}]
|
||||||
|
else if x == "chrome" then
|
||||||
|
let
|
||||||
|
dir = if isDarwin then
|
||||||
|
"Library/Application Support/Google/Chrome/NativeMessagingHosts"
|
||||||
|
else
|
||||||
|
".config/google-chrome/NativeMessagingHosts";
|
||||||
|
in [{
|
||||||
|
"${dir}/com.ugetdm.firefox.json".source =
|
||||||
|
"${pkgs.uget-integrator}/lib/mozilla/native-messaging-hosts/com.ugetdm.firefox.json";
|
||||||
|
"${dir}/../policies/managed/com.ugetdm.firefox.json".source =
|
||||||
|
"${pkgs.uget-integrator}/lib/mozilla/native-messaging-hosts/com.ugetdm.firefox.json";
|
||||||
|
}]
|
||||||
|
else if x == "chromium" then
|
||||||
|
let
|
||||||
|
dir = if isDarwin then
|
||||||
|
"Library/Application Support/Chromium/NativeMessagingHosts"
|
||||||
|
else
|
||||||
|
".config/chromium/NativeMessagingHosts";
|
||||||
|
in [
|
||||||
|
{
|
||||||
|
"${dir}/com.ugetdm.firefox.json".source =
|
||||||
|
"${pkgs.uget-integrator}/lib/mozilla/native-messaging-hosts/com.ugetdm.firefox.json";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"${dir}/../policies/managed/com.ugetdm.firefox.json".source =
|
||||||
|
"${pkgs.uget-integrator}/lib/mozilla/native-messaging-hosts/com.ugetdm.firefox.json";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
else if x == "firefox" then
|
||||||
|
let
|
||||||
|
dir = if isDarwin then
|
||||||
|
"Library/Application Support/Mozilla/NativeMessagingHosts"
|
||||||
|
else
|
||||||
|
".mozilla/native-messaging-hosts";
|
||||||
|
in [{
|
||||||
|
"${dir}/com.ugetdm.firefox.json".source =
|
||||||
|
"${pkgs.uget-integrator}/lib/mozilla/native-messaging-hosts/com.ugetdm.firefox.json";
|
||||||
|
}]
|
||||||
|
else if x == "librewolf" then
|
||||||
|
let
|
||||||
|
dir = if isDarwin then
|
||||||
|
"Library/Application Support/LibreWolf/NativeMessagingHosts"
|
||||||
|
else
|
||||||
|
".librewolf/native-messaging-hosts";
|
||||||
|
in [{
|
||||||
|
"${dir}/com.ugetdm.firefox.json".source =
|
||||||
|
"${pkgs.uget-integrator}/lib/mozilla/native-messaging-hosts/com.ugetdm.firefox.json";
|
||||||
|
}]
|
||||||
|
|
||||||
|
else if x == "vivaldi" then
|
||||||
|
let
|
||||||
|
dir = if isDarwin then
|
||||||
|
"Library/Application Support/Vivaldi/NativeMessagingHosts"
|
||||||
|
else
|
||||||
|
".config/vivaldi/NativeMessagingHosts";
|
||||||
|
in [{
|
||||||
|
"${dir}/com.ugetdm.firefox.json".source =
|
||||||
|
"${pkgs.uget-integrator}/lib/mozilla/native-messaging-hosts/com.ugetdm.firefox.json";
|
||||||
|
"${dir}/../policies/managed/com.ugetdm.firefox.json".source =
|
||||||
|
"${pkgs.uget-integrator}/lib/mozilla/native-messaging-hosts/com.ugetdm.firefox.json";
|
||||||
|
}]
|
||||||
|
else
|
||||||
|
throw "unknown browser ${x}") cfg.integrator.browsers);
|
||||||
|
};
|
||||||
|
}
|
|
@ -144,6 +144,7 @@ import nmt {
|
||||||
./modules/programs/tmux
|
./modules/programs/tmux
|
||||||
./modules/programs/topgrade
|
./modules/programs/topgrade
|
||||||
./modules/programs/translate-shell
|
./modules/programs/translate-shell
|
||||||
|
./modules/programs/uget
|
||||||
./modules/programs/vim-vint
|
./modules/programs/vim-vint
|
||||||
./modules/programs/vscode
|
./modules/programs/vscode
|
||||||
./modules/programs/watson
|
./modules/programs/watson
|
||||||
|
|
1
tests/modules/programs/uget/default.nix
Normal file
1
tests/modules/programs/uget/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ uget = ./uget.nix; }
|
38
tests/modules/programs/uget/uget.nix
Normal file
38
tests/modules/programs/uget/uget.nix
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
programs.uget = {
|
||||||
|
enable = true;
|
||||||
|
integrator = {
|
||||||
|
enable = true;
|
||||||
|
browsers =
|
||||||
|
[ "brave" "chrome" "chromium" "firefox" "librewolf" "vivaldi" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = if pkgs.stdenv.hostPlatform.isDarwin then ''
|
||||||
|
for dir in "BraveSoftware/Brave-Browser" "Google/Chrome" "Chromium" "Mozilla" "LibreWolf" "Vivaldi"; do
|
||||||
|
assertFileExists "home-files/Library/Application Support/$dir/NativeMessagingHosts/com.ugetdm.firefox.json"
|
||||||
|
done
|
||||||
|
|
||||||
|
for dir in "Google/Chrome" "Chromium" "Vivaldi"; do
|
||||||
|
assertFileExists "home-files/Library/Application Support/$dir/policies/managed/com.ugetdm.firefox.json"
|
||||||
|
done
|
||||||
|
'' else ''
|
||||||
|
for dir in "BraveSoftware/Brave-Browser" "google-chrome" "chromium" "vivaldi"; do
|
||||||
|
assertFileExists "home-files/.config/$dir/NativeMessagingHosts/com.ugetdm.firefox.json"
|
||||||
|
done
|
||||||
|
|
||||||
|
for dir in "google-chrome" "chromium" "vivaldi"; do
|
||||||
|
assertFileExists "home-files/.config/$dir/policies/managed/com.ugetdm.firefox.json"
|
||||||
|
done
|
||||||
|
|
||||||
|
for dir in ".mozilla" ".librewolf"; do
|
||||||
|
assertFileExists "home-files/$dir/native-messaging-hosts/com.ugetdm.firefox.json"
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue