Update browsers

This commit is contained in:
DashieTM 2024-09-29 12:48:39 +02:00
parent 10adafe703
commit b72d409a5a
15 changed files with 262 additions and 67 deletions

View file

@ -0,0 +1,23 @@
{
lib,
config,
options,
pkgs,
...
}:
{
options.mods.browser.brave = {
enable = lib.mkOption {
default = false;
example = true;
type = lib.types.bool;
description = "Enables brave";
};
# TODO configure brave
};
config = lib.mkIf config.mods.browser.brave.enable (
lib.optionalAttrs (options ? home.packages) {
home.packages = with pkgs; [ brave ];
}
);
}

View file

@ -0,0 +1,23 @@
{
lib,
config,
options,
pkgs,
...
}:
{
options.mods.browser.chromium = {
enable = lib.mkOption {
default = false;
example = true;
type = lib.types.bool;
description = "Enables chromium";
};
# TODO configure chromium
};
config = lib.mkIf config.mods.browser.chromium.enable (
lib.optionalAttrs (options ? home.packages) {
home.packages = with pkgs; [ chromium ];
}
);
}

View file

@ -0,0 +1,8 @@
{
imports = [
./firefox.nix
./zen.nix
./chromium.nix
./brave.nix
];
}

View file

@ -6,10 +6,10 @@
...
}:
{
options.mods.firefox = {
options.mods.browser.firefox = {
enable = lib.mkOption {
default = true;
example = false;
default = false;
example = true;
type = lib.types.bool;
description = "Enables firefox";
};
@ -62,22 +62,45 @@
type = with lib.types; listOf package;
description = "Firefox extensions (from nur)";
};
profiles = lib.mkOption {
default = [
{
name = "${config.conf.username}";
value = {
isDefault = true;
id = 0;
extensions = config.mods.browser.firefox.extensions;
};
}
{
name = "special";
value = {
isDefault = false;
id = 1;
extensions = config.mods.browser.firefox.extensions;
};
}
];
example = [
{
name = "custom";
value = {
isDefault = true;
id = 0;
extensions = config.mods.browser.firefox.extensions;
};
}
];
type = with lib.types; listOf (attrsOf anything);
description = "Firefox extensions (from nur)";
};
};
config = lib.mkIf config.mods.firefox.enable (
config = lib.mkIf config.mods.browser.firefox.enable (
lib.optionalAttrs (options ? programs.firefox.profiles) {
programs.firefox = {
enable = true;
policies = config.mods.firefox.configuration;
profiles.${config.conf.username} = {
isDefault = true;
id = 0;
extensions = config.mods.firefox.extensions;
};
profiles."special" = {
isDefault = false;
id = 1;
extensions = config.mods.firefox.extensions;
};
policies = config.mods.browser.firefox.configuration;
profiles = builtins.listToAttrs config.mods.browser.firefox.profiles;
};
}
);

View file

@ -0,0 +1,35 @@
{
lib,
config,
options,
system,
inputs,
...
}:
{
options.mods.browser.zen = {
enable = lib.mkOption {
default = false;
example = true;
type = lib.types.bool;
description = "Enables the zen browser";
};
optimization = lib.mkOption {
default = "specific";
example = "generic";
type =
with lib.types;
(enum [
"specific"
"generic"
]);
description = "Enables the zen browser";
};
# TODO configure zen
};
config = lib.mkIf config.mods.browser.zen.enable (
lib.optionalAttrs (options ? home.packages) {
home.packages = [ inputs.zen-browser.packages."${system}".${config.mods.browser.zen.optimization} ];
}
);
}

View file

@ -3,9 +3,9 @@
./acpid.nix
./basePackages.nix
./bluetooth.nix
./browser
./coding.nix
./drives.nix
./firefox.nix
./fish.nix
./flatpak.nix
./gaming.nix

View file

@ -3,6 +3,7 @@
options,
config,
pkgs,
inputs,
...
}:
{
@ -68,11 +69,17 @@
type = with lib.types; nullOr package;
description = "The email client";
};
additionalBrowser = lib.mkOption {
default = pkgs.brave;
example = null;
type = with lib.types; nullOr package;
description = "Additional browser -> second to firefox, the only installed browser if firefox is disabled";
browser = lib.mkOption {
default = inputs.zen-browser.packages.${pkgs.system}.specific;
example = "firefox";
type =
with lib.types;
nullOr (
either (enum [
"firefox"
]) package
);
description = "The browser (the enum variants have preconfigured modules)";
};
};
config = lib.optionalAttrs (options ? home.packages) {
@ -87,8 +94,9 @@
(lib.mkIf (!isNull config.mods.homePackages.matrixClient) config.mods.homePackages.matrixClient)
(lib.mkIf (!isNull config.mods.homePackages.mailClient) config.mods.homePackages.mailClient)
(lib.mkIf (
!isNull config.mods.homePackages.additionalBrowser
) config.mods.homePackages.additionalBrowser)
# NOTE: This should be package, but nix doesn't have that....
builtins.isAttrs config.mods.homePackages.browser && !isNull config.mods.homePackages.browser
) config.mods.homePackages.browser)
adw-gtk3
bat
brightnessctl
@ -129,10 +137,19 @@
};
};
programs =
if config.mods.homePackages.useDefaultPackages then
config.mods.homePackages.specialPrograms
else
config.mods.homePackages.specialPrograms;
config.mods.homePackages.specialPrograms
// (
if config.mods.homePackages.browser == "firefox" then
{
firefox = {
enable = true;
policies = config.mods.browser.firefox.configuration;
profiles = builtins.listToAttrs config.mods.browser.firefox.profiles;
};
}
else
{ }
);
services =
if config.mods.homePackages.useDefaultPackages then
config.mods.homePackages.specialServices

View file

@ -5,6 +5,17 @@
pkgs,
...
}:
let
browserName =
if (builtins.isString config.mods.homePackages.browser) then
config.mods.homePackages.browser
else if
config.mods.homePackages.browser ? meta && config.mods.homePackages.browser.meta ? mainProgram
then
config.mods.homePackages.browser.meta.mainProgram
else
config.mods.homePackages.browser.pname;
in
{
options.mods = {
hyprland = {
@ -106,7 +117,7 @@
bindm = [
"$mod, mouse:272, movewindow"
"$mod, mouse:273, resizewindow"
"$mod, mouse:273, resizeactive"
];
bind = [
@ -116,8 +127,10 @@
''$mod SUPERSHIFTALT,S,exec,grim -c -g "2560,0 3440x1440" - | wl-copy''
# regular programs
"$mod SUPER,F,exec,firefox"
"$mod SUPERSHIFT,F,exec,firefox -p special"
"$mod SUPER,F,exec,${browserName}"
(lib.mkIf (
browserName == "firefox" || browserName == "zen"
) "$mod SUPERSHIFT,F,exec,${browserName} -p special")
"$mod SUPER,T,exec,kitty -1"
"$mod SUPER,E,exec,nautilus -w"
"$mod SUPER,N,exec,neovide"

View file

@ -6,6 +6,17 @@
options,
...
}:
let
browserName =
if (builtins.isString config.mods.homePackages.browser) then
config.mods.homePackages.browser
else if
config.mods.homePackages.browser ? meta && config.mods.homePackages.browser.meta ? mainProgram
then
config.mods.homePackages.browser.meta.mainProgram
else
config.mods.homePackages.browser.pname;
in
{
options.mods.mime = {
enable = lib.mkOption {
@ -72,7 +83,7 @@
description = "Browser X mime handlers";
};
browserApplications = lib.mkOption {
default = [ "firefox" ];
default = [ "${browserName}" ];
example = [ ];
type = with lib.types; listOf str;
description = "Applications used for handling browser mime types";