2017-06-30 22:45:09 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
browsers = [
|
|
|
|
"chrome"
|
|
|
|
"chromium"
|
|
|
|
"firefox"
|
|
|
|
"vivaldi"
|
|
|
|
];
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
programs.browserpass = {
|
|
|
|
enable = mkEnableOption "the browserpass extension host application";
|
|
|
|
|
|
|
|
browsers = mkOption {
|
|
|
|
type = types.listOf (types.enum browsers);
|
|
|
|
default = browsers;
|
|
|
|
example = [ "firefox" ];
|
|
|
|
description = "Which browsers to install browserpass for";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf config.programs.browserpass.enable {
|
|
|
|
home.file = builtins.concatLists (with pkgs.stdenv; map (x:
|
|
|
|
if x == "chrome" then
|
|
|
|
let dir = if isDarwin
|
|
|
|
then "Library/Application Support/Google/Chrome/NativeMessagingHosts"
|
|
|
|
else ".config/google-chrome/NativeMessagingHosts";
|
|
|
|
in [
|
|
|
|
{
|
2019-04-14 04:52:10 +02:00
|
|
|
target = "${dir}/com.github.browserpass.native.json";
|
2019-05-31 20:12:46 +02:00
|
|
|
source = "${pkgs.browserpass}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json";
|
2017-06-30 22:45:09 +02:00
|
|
|
}
|
|
|
|
{
|
2019-04-14 04:52:10 +02:00
|
|
|
target = "${dir}/../policies/managed/com.github.browserpass.native.json";
|
2019-05-31 20:12:46 +02:00
|
|
|
source = "${pkgs.browserpass}/lib/browserpass/policies/chromium/com.github.browserpass.native.json";
|
2017-06-30 22:45:09 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
else if x == "chromium" then
|
|
|
|
let dir = if isDarwin
|
|
|
|
then "Library/Application Support/Chromium/NativeMessagingHosts"
|
|
|
|
else ".config/chromium/NativeMessagingHosts";
|
|
|
|
in [
|
|
|
|
{
|
2019-04-14 04:52:10 +02:00
|
|
|
target = "${dir}/com.github.browserpass.native.json";
|
2019-05-31 20:12:46 +02:00
|
|
|
source = "${pkgs.browserpass}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json";
|
2017-06-30 22:45:09 +02:00
|
|
|
}
|
|
|
|
{
|
2019-04-14 04:52:10 +02:00
|
|
|
target = "${dir}/../policies/managed/com.github.browserpass.native.json";
|
2019-05-31 20:12:46 +02:00
|
|
|
source = "${pkgs.browserpass}/lib/browserpass/policies/chromium/com.github.browserpass.native.json";
|
2017-06-30 22:45:09 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
else if x == "firefox" then
|
|
|
|
[ {
|
|
|
|
target = (if isDarwin
|
|
|
|
then "Library/Application Support/Mozilla/NativeMessagingHosts"
|
|
|
|
else ".mozilla/native-messaging-hosts")
|
2019-04-14 04:52:10 +02:00
|
|
|
+ "/com.github.browserpass.native.json";
|
2019-05-31 20:12:46 +02:00
|
|
|
source = "${pkgs.browserpass}/lib/browserpass/hosts/firefox/com.github.browserpass.native.json";
|
2017-06-30 22:45:09 +02:00
|
|
|
} ]
|
|
|
|
else if x == "vivaldi" then
|
|
|
|
let dir = if isDarwin
|
|
|
|
then "Library/Application Support/Vivaldi/NativeMessagingHosts"
|
|
|
|
else ".config/vivaldi/NativeMessagingHosts";
|
|
|
|
in [
|
|
|
|
{
|
2019-04-14 04:52:10 +02:00
|
|
|
target = "${dir}/com.github.browserpass.native.json";
|
2019-05-31 20:12:46 +02:00
|
|
|
source = "${pkgs.browserpass}/lib/browserpass/hosts/chromium/com.github.browserpass.native.json";
|
2017-06-30 22:45:09 +02:00
|
|
|
}
|
|
|
|
{
|
2019-04-14 04:52:10 +02:00
|
|
|
target = "${dir}/../policies/managed/com.github.browserpass.native.json";
|
2019-05-31 20:12:46 +02:00
|
|
|
source = "${pkgs.browserpass}/lib/browserpass/policies/chromium/com.github.browserpass.native.json";
|
2017-06-30 22:45:09 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
else throw "unknown browser ${x}") config.programs.browserpass.browsers);
|
|
|
|
};
|
|
|
|
}
|