2017-06-30 22:45:09 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
2022-03-24 18:35:47 +01:00
|
|
|
let
|
|
|
|
cfg = config.programs.browserpass;
|
|
|
|
browsers = [ "brave" "chrome" "chromium" "firefox" "vivaldi" ];
|
2017-06-30 22:45:09 +02:00
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
programs.browserpass = {
|
2023-07-01 01:30:13 +02:00
|
|
|
enable =
|
|
|
|
mkEnableOption (lib.mdDoc "the browserpass extension host application");
|
2017-06-30 22:45:09 +02:00
|
|
|
|
|
|
|
browsers = mkOption {
|
|
|
|
type = types.listOf (types.enum browsers);
|
|
|
|
default = browsers;
|
|
|
|
example = [ "firefox" ];
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc "Which browsers to install browserpass for";
|
2017-06-30 22:45:09 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-03-24 18:35:47 +01:00
|
|
|
config = mkIf cfg.enable {
|
2020-02-02 00:39:17 +01:00
|
|
|
home.file = foldl' (a: b: a // b) { } (concatMap (x:
|
|
|
|
with pkgs.stdenv;
|
2022-03-24 18:35:47 +01:00
|
|
|
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.github.browserpass.native.json".source =
|
|
|
|
"${pkgs.browserpass}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json";
|
|
|
|
}]
|
|
|
|
else if x == "chrome" then
|
2020-02-02 00:39:17 +01:00
|
|
|
let
|
|
|
|
dir = if isDarwin then
|
|
|
|
"Library/Application Support/Google/Chrome/NativeMessagingHosts"
|
|
|
|
else
|
|
|
|
".config/google-chrome/NativeMessagingHosts";
|
|
|
|
in [{
|
|
|
|
"${dir}/com.github.browserpass.native.json".source =
|
|
|
|
"${pkgs.browserpass}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json";
|
|
|
|
"${dir}/../policies/managed/com.github.browserpass.native.json".source =
|
|
|
|
"${pkgs.browserpass}/lib/browserpass/policies/chromium/com.github.browserpass.native.json";
|
|
|
|
}]
|
|
|
|
else if x == "chromium" then
|
|
|
|
let
|
|
|
|
dir = if isDarwin then
|
|
|
|
"Library/Application Support/Chromium/NativeMessagingHosts"
|
|
|
|
else
|
|
|
|
".config/chromium/NativeMessagingHosts";
|
|
|
|
in [
|
|
|
|
{
|
|
|
|
"${dir}/com.github.browserpass.native.json".source =
|
|
|
|
"${pkgs.browserpass}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
"${dir}/../policies/managed/com.github.browserpass.native.json".source =
|
|
|
|
"${pkgs.browserpass}/lib/browserpass/policies/chromium/com.github.browserpass.native.json";
|
|
|
|
}
|
|
|
|
]
|
|
|
|
else if x == "firefox" then
|
|
|
|
let
|
|
|
|
dir = if isDarwin then
|
|
|
|
"Library/Application Support/Mozilla/NativeMessagingHosts"
|
|
|
|
else
|
|
|
|
".mozilla/native-messaging-hosts";
|
|
|
|
in [{
|
|
|
|
"${dir}/com.github.browserpass.native.json".source =
|
|
|
|
"${pkgs.browserpass}/lib/browserpass/hosts/firefox/com.github.browserpass.native.json";
|
|
|
|
}]
|
|
|
|
else if x == "vivaldi" then
|
|
|
|
let
|
|
|
|
dir = if isDarwin then
|
|
|
|
"Library/Application Support/Vivaldi/NativeMessagingHosts"
|
|
|
|
else
|
|
|
|
".config/vivaldi/NativeMessagingHosts";
|
|
|
|
in [{
|
|
|
|
"${dir}/com.github.browserpass.native.json".source =
|
|
|
|
"${pkgs.browserpass}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json";
|
|
|
|
"${dir}/../policies/managed/com.github.browserpass.native.json".source =
|
|
|
|
"${pkgs.browserpass}/lib/browserpass/policies/chromium/com.github.browserpass.native.json";
|
|
|
|
}]
|
|
|
|
else
|
2022-03-24 18:35:47 +01:00
|
|
|
throw "unknown browser ${x}") cfg.browsers);
|
2017-06-30 22:45:09 +02:00
|
|
|
};
|
|
|
|
}
|