1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01:00

browserpass: add brave support

This commit is contained in:
Yevhen Shymotiuk 2022-03-24 19:35:47 +02:00 committed by Robert Helgesson
parent 0520e387dc
commit d123fca83c
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
2 changed files with 24 additions and 7 deletions

View file

@ -2,7 +2,9 @@
with lib;
let browsers = [ "chrome" "chromium" "firefox" "vivaldi" ];
let
cfg = config.programs.browserpass;
browsers = [ "brave" "chrome" "chromium" "firefox" "vivaldi" ];
in {
options = {
programs.browserpass = {
@ -17,10 +19,22 @@ in {
};
};
config = mkIf config.programs.browserpass.enable {
config = mkIf cfg.enable {
home.file = foldl' (a: b: a // b) { } (concatMap (x:
with pkgs.stdenv;
if x == "chrome" then
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
let
dir = if isDarwin then
"Library/Application Support/Google/Chrome/NativeMessagingHosts"
@ -71,6 +85,6 @@ in {
"${pkgs.browserpass}/lib/browserpass/policies/chromium/com.github.browserpass.native.json";
}]
else
throw "unknown browser ${x}") config.programs.browserpass.browsers);
throw "unknown browser ${x}") cfg.browsers);
};
}

View file

@ -6,11 +6,11 @@ with lib;
config = {
programs.browserpass = {
enable = true;
browsers = [ "chrome" "chromium" "firefox" "vivaldi" ];
browsers = [ "brave" "chrome" "chromium" "firefox" "vivaldi" ];
};
nmt.script = if pkgs.stdenv.hostPlatform.isDarwin then ''
for dir in "Google/Chrome" "Chromium" "Mozilla" "Vivaldi"; do
for dir in "BraveSoftware/Brave-Browser" "Google/Chrome" "Chromium" "Mozilla" "Vivaldi"; do
assertFileExists "home-files/Library/Application Support/$dir/NativeMessagingHosts/com.github.browserpass.native.json"
done
@ -18,8 +18,11 @@ with lib;
assertFileExists "home-files/Library/Application Support/$dir/policies/managed/com.github.browserpass.native.json"
done
'' else ''
for dir in "google-chrome" "chromium" "vivaldi"; do
for dir in "BraveSoftware/Brave-Browser" "google-chrome" "chromium" "vivaldi"; do
assertFileExists "home-files/.config/$dir/NativeMessagingHosts/com.github.browserpass.native.json"
done
for dir in "google-chrome" "chromium" "vivaldi"; do
assertFileExists "home-files/.config/$dir/policies/managed/com.github.browserpass.native.json"
done