modules/browsers: add final-package for each browser

This commit is contained in:
Dmitriy Pleshevskiy 2024-10-09 21:52:12 +03:00
parent 5dc3fc10ca
commit 482349b94d
Signed by: pleshevskiy
GPG key ID: 17041163DA10A9A2
8 changed files with 48 additions and 21 deletions

View file

@ -31,7 +31,6 @@
package = pkgs.unstable.ollama; package = pkgs.unstable.ollama;
}; };
local.programs.browsers.tor-browser.enable = true;
local.programs.communication = { local.programs.communication = {
telegram = { telegram = {

View file

@ -7,12 +7,9 @@
./users ./users
]; ];
# local.yubikey.enable = true;
################################################################################ ################################################################################
# Programs # Programs
################################################################################ ################################################################################
local.programs.browsers.tor-browser.enable = true;
################################################################################ ################################################################################
# Services # Services

View file

@ -35,7 +35,11 @@
################################################################################ ################################################################################
local.programs.pass.enable = lib.mkDefault true; local.programs.pass.enable = lib.mkDefault true;
local.programs.browsers.librewolf.enable = lib.mkDefault true; local.programs.browsers = {
librewolf.enable = lib.mkDefault true;
tor-browser.enable = lib.mkDefault true;
ungoogled-chromium.enable = lib.mkDefault true;
};
security.sudo.extraRules = [{ security.sudo.extraRules = [{
commands = [ commands = [

View file

@ -4,9 +4,10 @@ let
cfg = config.local.programs.browsers; cfg = config.local.programs.browsers;
contPackages = contPackages =
lib.optional cfg.tor-browser.enable cfg.tor-browser.package lib.optional cfg.tor-browser.enable cfg.tor-browser.finalPackage
++ lib.optional cfg.librewolf.enable cfg.librewolf.package ++ lib.optional cfg.librewolf.enable cfg.librewolf.finalPackage
++ lib.optional cfg.mullvad-browser.enable cfg.mullvad-browser.package; ++ lib.optional cfg.mullvad-browser.enable cfg.mullvad-browser.finalPackage
++ lib.optional cfg.ungoogled-chromium.enable cfg.ungoogled-chromium.package;
hostPackages = lib.flip map contPackages (p: hostPackages = lib.flip map contPackages (p:
let let
@ -34,6 +35,7 @@ in
./tor-browser.nix ./tor-browser.nix
./mullvad-browser.nix ./mullvad-browser.nix
./librewolf.nix ./librewolf.nix
./ungoogled-chromium.nix
]; ];
config = lib.mkIf isEnable { config = lib.mkIf isEnable {

View file

@ -1,24 +1,27 @@
{ pkgs, lib, inputs, ... }: { config, pkgs, lib, inputs, ... }:
let let
# isPassEnabled = config.local.programs.pass.enable; cfg = config.local.programs.browsers.librewolf;
policiesJson = pkgs.callPackage ./policies.nix { policiesJson = pkgs.callPackage ./policies.nix {
firefoxAddons = inputs.firefox-addons.packages."${pkgs.system}"; firefoxAddons = inputs.firefox-addons.packages."${pkgs.system}";
# withPassffAddon = isPassEnabled;
withRedirectorAddon = true; withRedirectorAddon = true;
withSidebarTabsAddon = true; withSidebarTabsAddon = true;
withAllSearchEngines = true; withAllSearchEngines = true;
}; };
librewolf' = with pkgs.unstable; librewolf.override { finalLibrewolf = cfg.package.override {
extraPoliciesFiles = librewolf.unwrapped.extraPoliciesFiles ++ [ policiesJson ]; extraPoliciesFiles = cfg.package.unwrapped.extraPoliciesFiles ++ [ policiesJson ];
# nativeMessagingHosts = lib.optional isPassEnabled passff-host;
}; };
in in
{ {
options.local.programs.browsers.librewolf = with lib; { options.local.programs.browsers.librewolf = with lib; {
enable = mkEnableOption "librewolf"; enable = mkEnableOption "librewolf";
package = mkPackageOption pkgs "librewolf" {} // { default = librewolf'; }; package = mkPackageOption pkgs "librewolf" {};
finalPackage = mkOption {
type = types.package;
readOnly = true;
default = finalLibrewolf;
};
}; };
} }

View file

@ -1,6 +1,8 @@
{ pkgs, lib, inputs, ... }: { config, pkgs, lib, inputs, ... }:
let let
cfg = config.local.programs.browsers.mullvad-browser;
policiesJson = pkgs.callPackage ./policies.nix { policiesJson = pkgs.callPackage ./policies.nix {
firefoxAddons = inputs.firefox-addons.packages."${pkgs.system}"; firefoxAddons = inputs.firefox-addons.packages."${pkgs.system}";
withRedirectorAddon = true; withRedirectorAddon = true;
@ -8,7 +10,7 @@ let
withAllSearchEngines = true; withAllSearchEngines = true;
}; };
mullvadBrowser = pkgs.mullvad-browser.overrideAttrs (attrs: { finalMullvadBrowser = cfg.package.overrideAttrs (attrs: {
postInstall = '' postInstall = ''
rm $out/share/mullvad-browser/distribution/policies.json rm $out/share/mullvad-browser/distribution/policies.json
@ -19,6 +21,11 @@ in
{ {
options.local.programs.browsers.mullvad-browser = with lib; { options.local.programs.browsers.mullvad-browser = with lib; {
enable = mkEnableOption "mullvad-browser"; enable = mkEnableOption "mullvad-browser";
package = mkPackageOption pkgs "mullvad-browser" {} // { default = mullvadBrowser; }; package = mkPackageOption pkgs "mullvad-browser" {};
finalPackage = mkOption {
type = types.package;
readOnly = true;
default = finalMullvadBrowser;
};
}; };
} }

View file

@ -1,9 +1,11 @@
{ pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
cfg = config.local.programs.browsers.tor-browser;
policiesJson = pkgs.callPackage ./policies.nix { }; policiesJson = pkgs.callPackage ./policies.nix { };
torBrowser = (pkgs.tor-browser-bundle-bin.override { finalTorBrowser = (cfg.package.override {
mediaSupport = true; mediaSupport = true;
pulseaudioSupport = true; pulseaudioSupport = true;
}).overrideAttrs (attrs: { }).overrideAttrs (attrs: {
@ -16,6 +18,11 @@ in
{ {
options.local.programs.browsers.tor-browser = with lib; { options.local.programs.browsers.tor-browser = with lib; {
enable = mkEnableOption "tor-browser"; enable = mkEnableOption "tor-browser";
package = mkPackageOption pkgs "tor-browser-bundle-bin" {} // { default = torBrowser; }; package = mkPackageOption pkgs "tor-browser-bundle-bin" {};
finalPackage = mkOption {
type = types.package;
readOnly = true;
default = finalTorBrowser;
};
}; };
} }

View file

@ -0,0 +1,8 @@
{ pkgs, lib, ... }:
{
options.local.programs.browsers.ungoogled-chromium = with lib; {
enable = mkEnableOption "ungoogled-chromium";
package = mkPackageOption pkgs "ungoogled-chromium" {};
};
}