Skip to content

Commit

Permalink
browserpass: add brave support
Browse files Browse the repository at this point in the history
  • Loading branch information
yshym committed Mar 24, 2022
1 parent ac94041 commit c279145
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
22 changes: 18 additions & 4 deletions modules/programs/browserpass.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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"
Expand Down Expand Up @@ -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);
};
}
9 changes: 6 additions & 3 deletions tests/modules/programs/browserpass/browserpass.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@ 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
for dir in "Google/Chrome" "Chromium" "Vivaldi"; do
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
Expand Down

0 comments on commit c279145

Please sign in to comment.