From 482349b94dae8dae02c463d2b299d36102a7d5fc Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Wed, 9 Oct 2024 21:52:12 +0300 Subject: [PATCH] modules/browsers: add final-package for each browser --- hosts/asus-gl553vd/configuration.nix | 1 - hosts/home/configuration.nix | 3 --- modules/machine.nix | 6 +++++- modules/nixos/programs/browsers/default.nix | 8 +++++--- modules/nixos/programs/browsers/librewolf.nix | 17 ++++++++++------- .../nixos/programs/browsers/mullvad-browser.nix | 13 ++++++++++--- modules/nixos/programs/browsers/tor-browser.nix | 13 ++++++++++--- .../programs/browsers/ungoogled-chromium.nix | 8 ++++++++ 8 files changed, 48 insertions(+), 21 deletions(-) create mode 100644 modules/nixos/programs/browsers/ungoogled-chromium.nix diff --git a/hosts/asus-gl553vd/configuration.nix b/hosts/asus-gl553vd/configuration.nix index 424f3bd..39eb0c5 100644 --- a/hosts/asus-gl553vd/configuration.nix +++ b/hosts/asus-gl553vd/configuration.nix @@ -31,7 +31,6 @@ package = pkgs.unstable.ollama; }; - local.programs.browsers.tor-browser.enable = true; local.programs.communication = { telegram = { diff --git a/hosts/home/configuration.nix b/hosts/home/configuration.nix index 9e4260d..320cbf8 100644 --- a/hosts/home/configuration.nix +++ b/hosts/home/configuration.nix @@ -7,12 +7,9 @@ ./users ]; - # local.yubikey.enable = true; - ################################################################################ # Programs ################################################################################ - local.programs.browsers.tor-browser.enable = true; ################################################################################ # Services diff --git a/modules/machine.nix b/modules/machine.nix index 70d53ce..41924bb 100644 --- a/modules/machine.nix +++ b/modules/machine.nix @@ -35,7 +35,11 @@ ################################################################################ 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 = [{ commands = [ diff --git a/modules/nixos/programs/browsers/default.nix b/modules/nixos/programs/browsers/default.nix index 5fdeae2..f739117 100644 --- a/modules/nixos/programs/browsers/default.nix +++ b/modules/nixos/programs/browsers/default.nix @@ -4,9 +4,10 @@ let cfg = config.local.programs.browsers; contPackages = - lib.optional cfg.tor-browser.enable cfg.tor-browser.package - ++ lib.optional cfg.librewolf.enable cfg.librewolf.package - ++ lib.optional cfg.mullvad-browser.enable cfg.mullvad-browser.package; + lib.optional cfg.tor-browser.enable cfg.tor-browser.finalPackage + ++ lib.optional cfg.librewolf.enable cfg.librewolf.finalPackage + ++ 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: let @@ -34,6 +35,7 @@ in ./tor-browser.nix ./mullvad-browser.nix ./librewolf.nix + ./ungoogled-chromium.nix ]; config = lib.mkIf isEnable { diff --git a/modules/nixos/programs/browsers/librewolf.nix b/modules/nixos/programs/browsers/librewolf.nix index c387be6..d958b8a 100644 --- a/modules/nixos/programs/browsers/librewolf.nix +++ b/modules/nixos/programs/browsers/librewolf.nix @@ -1,24 +1,27 @@ -{ pkgs, lib, inputs, ... }: +{ config, pkgs, lib, inputs, ... }: let - # isPassEnabled = config.local.programs.pass.enable; + cfg = config.local.programs.browsers.librewolf; policiesJson = pkgs.callPackage ./policies.nix { firefoxAddons = inputs.firefox-addons.packages."${pkgs.system}"; - # withPassffAddon = isPassEnabled; withRedirectorAddon = true; withSidebarTabsAddon = true; withAllSearchEngines = true; }; - librewolf' = with pkgs.unstable; librewolf.override { - extraPoliciesFiles = librewolf.unwrapped.extraPoliciesFiles ++ [ policiesJson ]; - # nativeMessagingHosts = lib.optional isPassEnabled passff-host; + finalLibrewolf = cfg.package.override { + extraPoliciesFiles = cfg.package.unwrapped.extraPoliciesFiles ++ [ policiesJson ]; }; in { options.local.programs.browsers.librewolf = with lib; { enable = mkEnableOption "librewolf"; - package = mkPackageOption pkgs "librewolf" {} // { default = librewolf'; }; + package = mkPackageOption pkgs "librewolf" {}; + finalPackage = mkOption { + type = types.package; + readOnly = true; + default = finalLibrewolf; + }; }; } diff --git a/modules/nixos/programs/browsers/mullvad-browser.nix b/modules/nixos/programs/browsers/mullvad-browser.nix index b0d90fe..0be44fd 100644 --- a/modules/nixos/programs/browsers/mullvad-browser.nix +++ b/modules/nixos/programs/browsers/mullvad-browser.nix @@ -1,6 +1,8 @@ -{ pkgs, lib, inputs, ... }: +{ config, pkgs, lib, inputs, ... }: let + cfg = config.local.programs.browsers.mullvad-browser; + policiesJson = pkgs.callPackage ./policies.nix { firefoxAddons = inputs.firefox-addons.packages."${pkgs.system}"; withRedirectorAddon = true; @@ -8,7 +10,7 @@ let withAllSearchEngines = true; }; - mullvadBrowser = pkgs.mullvad-browser.overrideAttrs (attrs: { + finalMullvadBrowser = cfg.package.overrideAttrs (attrs: { postInstall = '' rm $out/share/mullvad-browser/distribution/policies.json @@ -19,6 +21,11 @@ in { options.local.programs.browsers.mullvad-browser = with lib; { 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; + }; }; } diff --git a/modules/nixos/programs/browsers/tor-browser.nix b/modules/nixos/programs/browsers/tor-browser.nix index 6b51184..25cb3c9 100644 --- a/modules/nixos/programs/browsers/tor-browser.nix +++ b/modules/nixos/programs/browsers/tor-browser.nix @@ -1,9 +1,11 @@ -{ pkgs, lib, ... }: +{ config, pkgs, lib, ... }: let + cfg = config.local.programs.browsers.tor-browser; + policiesJson = pkgs.callPackage ./policies.nix { }; - torBrowser = (pkgs.tor-browser-bundle-bin.override { + finalTorBrowser = (cfg.package.override { mediaSupport = true; pulseaudioSupport = true; }).overrideAttrs (attrs: { @@ -16,6 +18,11 @@ in { options.local.programs.browsers.tor-browser = with lib; { 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; + }; }; } diff --git a/modules/nixos/programs/browsers/ungoogled-chromium.nix b/modules/nixos/programs/browsers/ungoogled-chromium.nix new file mode 100644 index 0000000..30c107c --- /dev/null +++ b/modules/nixos/programs/browsers/ungoogled-chromium.nix @@ -0,0 +1,8 @@ +{ pkgs, lib, ... }: + +{ + options.local.programs.browsers.ungoogled-chromium = with lib; { + enable = mkEnableOption "ungoogled-chromium"; + package = mkPackageOption pkgs "ungoogled-chromium" {}; + }; +}