Add zen extension config and fix zen policy config

This commit is contained in:
DashieTM 2025-03-14 23:10:08 +01:00
parent 58c42ed7d8
commit 4f04b5d683
11 changed files with 647 additions and 144 deletions

View file

@ -271,4 +271,5 @@ For package lists, please check the individual modules, as the lists can be long
- [Catppuccin](https://github.com/catppuccin) for base16 colors and zen-browser css
- [Danth](https://github.com/danth) for providing a base for the nix docs
- [chermnyx](https://github.com/chermnyx) for providing a base for zen configuration
- [voronind-com](https://github.com/voronind-com) for providing the darkreader configuration
- [Nix-Artwork](https://github.com/NixOS/nixos-artwork/tree/master/logo) for the Nix/NixOS logo (Tim Cuthbertson (@timbertson))

154
flake.lock generated
View file

@ -942,7 +942,7 @@
"home-manager_2": {
"inputs": {
"nixpkgs": [
"nixpkgs"
"unstable"
]
},
"locked": {
@ -1265,7 +1265,7 @@
"crane": "crane",
"naersk": "naersk",
"nixpkgs": [
"nixpkgs"
"unstable"
],
"rust-overlay": "rust-overlay"
},
@ -1435,13 +1435,13 @@
"locked": {
"lastModified": 1741379970,
"narHash": "sha256-Wh7esNh7G24qYleLvgOSY/7HlDUzWaL/n4qzlBePpiw=",
"owner": "NixOs",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "36fd87baa9083f34f7f5027900b62ee6d09b1f2f",
"type": "github"
},
"original": {
"owner": "NixOs",
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
@ -1449,15 +1449,15 @@
},
"nixpkgs_11": {
"locked": {
"lastModified": 1741379970,
"narHash": "sha256-Wh7esNh7G24qYleLvgOSY/7HlDUzWaL/n4qzlBePpiw=",
"owner": "nixos",
"lastModified": 1716137900,
"narHash": "sha256-sowPU+tLQv8GlqtVtsXioTKeaQvlMz/pefcdwg8MvfM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "36fd87baa9083f34f7f5027900b62ee6d09b1f2f",
"rev": "6c0b7a92c30122196a761b440ac0d46d3d9954f1",
"type": "github"
},
"original": {
"owner": "nixos",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
@ -1481,37 +1481,21 @@
},
"nixpkgs_13": {
"locked": {
"lastModified": 1716137900,
"narHash": "sha256-sowPU+tLQv8GlqtVtsXioTKeaQvlMz/pefcdwg8MvfM=",
"lastModified": 1706487304,
"narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6c0b7a92c30122196a761b440ac0d46d3d9954f1",
"rev": "90f456026d284c22b3e3497be980b2e47d0b28ac",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_14": {
"locked": {
"lastModified": 1706487304,
"narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "90f456026d284c22b3e3497be980b2e47d0b28ac",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_15": {
"locked": {
"lastModified": 1716137900,
"narHash": "sha256-sowPU+tLQv8GlqtVtsXioTKeaQvlMz/pefcdwg8MvfM=",
@ -1527,7 +1511,7 @@
"type": "github"
}
},
"nixpkgs_16": {
"nixpkgs_15": {
"locked": {
"lastModified": 1706487304,
"narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=",
@ -1543,7 +1527,7 @@
"type": "github"
}
},
"nixpkgs_17": {
"nixpkgs_16": {
"locked": {
"lastModified": 1723637854,
"narHash": "sha256-med8+5DSWa2UnOqtdICndjDAEjxr5D7zaIiK4pn0Q7c=",
@ -1559,7 +1543,7 @@
"type": "github"
}
},
"nixpkgs_18": {
"nixpkgs_17": {
"locked": {
"lastModified": 1716137900,
"narHash": "sha256-sowPU+tLQv8GlqtVtsXioTKeaQvlMz/pefcdwg8MvfM=",
@ -1575,7 +1559,7 @@
"type": "github"
}
},
"nixpkgs_19": {
"nixpkgs_18": {
"locked": {
"lastModified": 1706487304,
"narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=",
@ -1591,6 +1575,22 @@
"type": "github"
}
},
"nixpkgs_19": {
"locked": {
"lastModified": 1739446958,
"narHash": "sha256-+/bYK3DbPxMIvSL4zArkMX0LQvS7rzBKXnDXLfKyRVc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2ff53fe64443980e139eaa286017f53f88336dd0",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1741379970,
@ -1608,22 +1608,6 @@
}
},
"nixpkgs_20": {
"locked": {
"lastModified": 1739446958,
"narHash": "sha256-+/bYK3DbPxMIvSL4zArkMX0LQvS7rzBKXnDXLfKyRVc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2ff53fe64443980e139eaa286017f53f88336dd0",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_21": {
"locked": {
"lastModified": 1736320768,
"narHash": "sha256-nIYdTAiKIGnFNugbomgBJR+Xv5F1ZQU+HfaBqJKroC0=",
@ -1639,7 +1623,7 @@
"type": "github"
}
},
"nixpkgs_22": {
"nixpkgs_21": {
"locked": {
"lastModified": 1716948383,
"narHash": "sha256-SzDKxseEcHR5KzPXLwsemyTR/kaM9whxeiJohbL04rs=",
@ -1655,7 +1639,7 @@
"type": "github"
}
},
"nixpkgs_23": {
"nixpkgs_22": {
"locked": {
"lastModified": 1706487304,
"narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=",
@ -1671,7 +1655,7 @@
"type": "github"
}
},
"nixpkgs_24": {
"nixpkgs_23": {
"locked": {
"lastModified": 1731763621,
"narHash": "sha256-ddcX4lQL0X05AYkrkV2LMFgGdRvgap7Ho8kgon3iWZk=",
@ -1687,7 +1671,7 @@
"type": "github"
}
},
"nixpkgs_25": {
"nixpkgs_24": {
"locked": {
"lastModified": 1740367490,
"narHash": "sha256-WGaHVAjcrv+Cun7zPlI41SerRtfknGQap281+AakSAw=",
@ -1703,13 +1687,13 @@
"type": "github"
}
},
"nixpkgs_26": {
"nixpkgs_25": {
"locked": {
"lastModified": 1741379970,
"narHash": "sha256-Wh7esNh7G24qYleLvgOSY/7HlDUzWaL/n4qzlBePpiw=",
"lastModified": 1741513245,
"narHash": "sha256-7rTAMNTY1xoBwz0h7ZMtEcd8LELk9R5TzBPoHuhNSCk=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "36fd87baa9083f34f7f5027900b62ee6d09b1f2f",
"rev": "e3e32b642a31e6714ec1b712de8c91a3352ce7e1",
"type": "github"
},
"original": {
@ -1852,7 +1836,7 @@
"nur": {
"inputs": {
"flake-parts": "flake-parts_6",
"nixpkgs": "nixpkgs_11",
"nixpkgs": "nixpkgs_10",
"treefmt-nix": "treefmt-nix"
},
"locked": {
@ -1919,7 +1903,7 @@
"oxicalc": {
"inputs": {
"flake-parts": "flake-parts_7",
"nixpkgs": "nixpkgs_12"
"nixpkgs": "nixpkgs_11"
},
"locked": {
"lastModified": 1733264508,
@ -1938,7 +1922,7 @@
"oxidash": {
"inputs": {
"flake-parts": "flake-parts_8",
"nixpkgs": "nixpkgs_13",
"nixpkgs": "nixpkgs_12",
"rust-overlay": "rust-overlay_2"
},
"locked": {
@ -1958,7 +1942,7 @@
"oxinoti": {
"inputs": {
"flake-parts": "flake-parts_9",
"nixpkgs": "nixpkgs_15",
"nixpkgs": "nixpkgs_14",
"rust-overlay": "rust-overlay_3"
},
"locked": {
@ -1978,7 +1962,7 @@
"oxipaste": {
"inputs": {
"flake-parts": "flake-parts_10",
"nixpkgs": "nixpkgs_17"
"nixpkgs": "nixpkgs_16"
},
"locked": {
"lastModified": 1737624143,
@ -1997,7 +1981,7 @@
"oxishut": {
"inputs": {
"flake-parts": "flake-parts_11",
"nixpkgs": "nixpkgs_18",
"nixpkgs": "nixpkgs_17",
"rust-overlay": "rust-overlay_4"
},
"locked": {
@ -2040,7 +2024,7 @@
"reset": {
"inputs": {
"flake-parts": "flake-parts_12",
"nixpkgs": "nixpkgs_20",
"nixpkgs": "nixpkgs_19",
"rust-overlay": "rust-overlay_5"
},
"locked": {
@ -2060,7 +2044,7 @@
"reset-plugins": {
"inputs": {
"flake-parts": "flake-parts_13",
"nixpkgs": "nixpkgs_22",
"nixpkgs": "nixpkgs_21",
"rust-overlay": "rust-overlay_6"
},
"locked": {
@ -2090,7 +2074,6 @@
"hyprland": "hyprland",
"ironbar": "ironbar",
"nix-flatpak": "nix-flatpak",
"nixpkgs": "nixpkgs_10",
"nur": "nur",
"oxicalc": "oxicalc",
"oxidash": "oxidash",
@ -2102,6 +2085,7 @@
"sops-nix": "sops-nix",
"stable": "stable",
"stylix": "stylix",
"unstable": "unstable",
"zen-browser": "zen-browser"
}
},
@ -2163,7 +2147,7 @@
"rust-overlay_2": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_14"
"nixpkgs": "nixpkgs_13"
},
"locked": {
"lastModified": 1716171463,
@ -2182,7 +2166,7 @@
"rust-overlay_3": {
"inputs": {
"flake-utils": "flake-utils_3",
"nixpkgs": "nixpkgs_16"
"nixpkgs": "nixpkgs_15"
},
"locked": {
"lastModified": 1716171463,
@ -2201,7 +2185,7 @@
"rust-overlay_4": {
"inputs": {
"flake-utils": "flake-utils_4",
"nixpkgs": "nixpkgs_19"
"nixpkgs": "nixpkgs_18"
},
"locked": {
"lastModified": 1716171463,
@ -2219,7 +2203,7 @@
},
"rust-overlay_5": {
"inputs": {
"nixpkgs": "nixpkgs_21"
"nixpkgs": "nixpkgs_20"
},
"locked": {
"lastModified": 1739586408,
@ -2238,7 +2222,7 @@
"rust-overlay_6": {
"inputs": {
"flake-utils": "flake-utils_5",
"nixpkgs": "nixpkgs_23"
"nixpkgs": "nixpkgs_22"
},
"locked": {
"lastModified": 1717035469,
@ -2256,7 +2240,7 @@
},
"sops-nix": {
"inputs": {
"nixpkgs": "nixpkgs_24"
"nixpkgs": "nixpkgs_23"
},
"locked": {
"lastModified": 1741043164,
@ -2300,7 +2284,7 @@
"git-hooks": "git-hooks",
"gnome-shell": "gnome-shell",
"home-manager": "home-manager_3",
"nixpkgs": "nixpkgs_25",
"nixpkgs": "nixpkgs_24",
"nur": "nur_2",
"systems": "systems_9",
"tinted-foot": "tinted-foot",
@ -2583,6 +2567,22 @@
"type": "github"
}
},
"unstable": {
"locked": {
"lastModified": 1741851582,
"narHash": "sha256-cPfs8qMccim2RBgtKGF+x9IBCduRvd/N5F4nYpU0TVE=",
"owner": "NixOs",
"repo": "nixpkgs",
"rev": "6607cf789e541e7873d40d3a8f7815ea92204f32",
"type": "github"
},
"original": {
"owner": "NixOs",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"xdph": {
"inputs": {
"hyprland-protocols": [
@ -2626,14 +2626,14 @@
},
"zen-browser": {
"inputs": {
"nixpkgs": "nixpkgs_26"
"nixpkgs": "nixpkgs_25"
},
"locked": {
"lastModified": 1741493092,
"narHash": "sha256-jShBVqU8K5rN8xtsq2JDgq+KInRw3pDbp8SViMIz5pE=",
"lastModified": 1741838758,
"narHash": "sha256-nGTC/y9e+1+QIVCzIbiSpPiXM2HfS8YwIDCp52CcOQ4=",
"owner": "youwen5",
"repo": "zen-browser-flake",
"rev": "117945c4162d78f2cc7ad578cf44edbbf1ee33fb",
"rev": "03a7fc89bc48344aed00e01b409c1d6ffc4c52ce",
"type": "github"
},
"original": {

View file

@ -2,7 +2,7 @@
description = "DashNix";
inputs = {
nixpkgs.url = "github:NixOs/nixpkgs/nixos-unstable";
unstable.url = "github:NixOs/nixpkgs/nixos-unstable";
stable.url = "github:NixOs/nixpkgs/nixos-24.11";
nur.url = "github:nix-community/NUR";
@ -12,7 +12,7 @@
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs.follows = "unstable";
};
sops-nix.url = "github:Mic92/sops-nix";
@ -26,7 +26,7 @@
ironbar = {
url = "github:JakeStanger/ironbar";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs.follows = "unstable";
};
zen-browser.url = "github:youwen5/zen-browser-flake";
@ -84,7 +84,7 @@
inputs.chaoticNyx.overlays.default
];
};
pkgs = import inputs.nixpkgs {
unstable = import inputs.unstable {
system = currentSystem;
config = {
allowUnsupportedSystem = true;
@ -103,21 +103,22 @@
inherit
self
inputs
pkgs
unstable
stable
;
system = currentSystem;
lib = inputs.nixpkgs.lib;
lib = inputs.unstable.lib;
};
docs = import ./docs {
inherit inputs pkgs stable;
inherit inputs;
pkgs = unstable;
system = currentSystem;
lib = inputs.nixpkgs.lib;
lib = inputs.unstable.lib;
build_systems = dashNixLib.build_systems;
};
dashNixInputs = inputs;
stablePkgs = stable;
unstablePkgs = pkgs;
unstablePkgs = unstable;
modules = ./modules;
iso = dashNixLib.buildIso.config.system.build.isoImage;
};

View file

@ -11,6 +11,8 @@
root,
alternativePkgs,
system,
stable,
unstable,
...
}: {
xdg = {
@ -24,7 +26,7 @@
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit inputs root additionalInputs alternativePkgs system;
inherit inputs root additionalInputs alternativePkgs system stable unstable;
};
users.${config.conf.username} = {

View file

@ -1,7 +1,7 @@
{
inputs,
lib,
pkgs,
unstable,
self,
stable,
system,
@ -87,15 +87,17 @@
additionalHomeConfig
system
root
stable
unstable
;
pkgs = lib.mkForce (
if overridePkgs
then stable
else pkgs
else unstable
);
alternativePkgs =
if overridePkgs
then pkgs
then unstable
else stable;
hostName = name;
homeMods = mods.home;
@ -103,7 +105,7 @@
additionalInputs = additionalInputs;
};
in
inputs.nixpkgs.lib.nixosSystem {
inputs.unstable.lib.nixosSystem {
modules =
[
{_module.args = args;}
@ -111,8 +113,8 @@
]
++ mods.nixos
++ additionalMods.nixos
++ inputs.nixpkgs.lib.optional (builtins.pathExists additionalNixosConfig) additionalNixosConfig
++ inputs.nixpkgs.lib.optional (builtins.pathExists mod) mod;
++ inputs.unstable.lib.optional (builtins.pathExists additionalNixosConfig) additionalNixosConfig
++ inputs.unstable.lib.optional (builtins.pathExists mod) mod;
};
})
(
@ -127,9 +129,9 @@
)
);
buildIso = inputs.nixpkgs.lib.nixosSystem {
buildIso = inputs.unstable.lib.nixosSystem {
specialArgs = {
inherit self inputs pkgs;
inherit self inputs unstable;
};
modules = [
../iso/configuration.nix

View file

@ -0,0 +1,456 @@
diff --git a/src/background/user-storage.ts b/src/background/user-storage.ts
index 54612fb3b1f6..298e5032fc94 100644
--- a/src/background/user-storage.ts
+++ b/src/background/user-storage.ts
@@ -5,7 +5,7 @@ import {PromiseBarrier} from '../utils/promise-barrier';
import {isURLMatched} from '../utils/url';
import {validateSettings} from '../utils/validation';
-import {readSyncStorage, readLocalStorage, writeSyncStorage, writeLocalStorage, removeSyncStorage, removeLocalStorage} from './utils/extension-api';
+import {readManagedStorage, readSyncStorage, readLocalStorage, writeSyncStorage, writeLocalStorage, removeSyncStorage, removeLocalStorage} from './utils/extension-api';
import {logWarn} from './utils/log';
@@ -78,12 +78,7 @@ export default class UserStorage {
return settings;
}
- private static async loadSettingsFromStorage(): Promise<UserSettings> {
- if (UserStorage.loadBarrier) {
- return await UserStorage.loadBarrier.entry();
- }
- UserStorage.loadBarrier = new PromiseBarrier();
-
+ private static async loadSettingsFromStorageWithoutManaged(): Promise<UserSettings> {
let local = await readLocalStorage(DEFAULT_SETTINGS);
if (local.schemeVersion < 2) {
@@ -113,10 +108,8 @@ export default class UserStorage {
if (local.syncSettings == null) {
local.syncSettings = DEFAULT_SETTINGS.syncSettings;
}
+
if (!local.syncSettings) {
- UserStorage.migrateAutomationSettings(local);
- UserStorage.fillDefaults(local);
- UserStorage.loadBarrier.resolve(local);
return local;
}
@@ -126,18 +119,34 @@ export default class UserStorage {
local.syncSettings = false;
UserStorage.set({syncSettings: false});
UserStorage.saveSyncSetting(false);
- UserStorage.loadBarrier.resolve(local);
return local;
}
const {errors: syncCfgErrors} = validateSettings($sync);
syncCfgErrors.forEach((err) => logWarn(err));
+ return $sync;
+ }
+
+ private static async loadSettingsFromStorage(): Promise<UserSettings> {
+ if (UserStorage.loadBarrier) {
+ return await UserStorage.loadBarrier.entry();
+ }
+ UserStorage.loadBarrier = new PromiseBarrier();
- UserStorage.migrateAutomationSettings($sync);
- UserStorage.fillDefaults($sync);
+ let settings = await UserStorage.loadSettingsFromStorageWithoutManaged();
- UserStorage.loadBarrier.resolve($sync);
- return $sync;
+ const managed = await readManagedStorage(settings);
+ const {errors: managedCfgErrors} = validateSettings(managed);
+ if (managedCfgErrors.length === 0) {
+ settings = managed;
+ } else {
+ managedCfgErrors.forEach((err) => logWarn(err));
+ }
+
+ UserStorage.migrateAutomationSettings(settings);
+ UserStorage.fillDefaults(settings);
+ UserStorage.loadBarrier.resolve(settings);
+ return settings;
}
static async saveSettings(): Promise<void> {
diff --git a/src/background/utils/extension-api.ts b/src/background/utils/extension-api.ts
index 6d18fc0919df..6812ac2e4224 100644
--- a/src/background/utils/extension-api.ts
+++ b/src/background/utils/extension-api.ts
@@ -97,6 +97,19 @@ export async function readLocalStorage<T extends {[key: string]: any}>(defaults:
});
}
+export async function readManagedStorage<T extends {[key: string]: any}>(defaults: T): Promise<T> {
+ return new Promise<T>((resolve) => {
+ chrome.storage.managed.get(defaults, (managed: T) => {
+ if (chrome.runtime.lastError) {
+ console.error(chrome.runtime.lastError.message);
+ resolve(defaults);
+ return;
+ }
+ resolve(managed);
+ });
+ });
+}
+
function prepareSyncStorage<T extends {[key: string]: any}>(values: T): {[key: string]: any} {
for (const key in values) {
const value = values[key];
diff --git a/src/managed-storage.json b/src/managed-storage.json
new file mode 100644
index 000000000000..e394d0f1ff60
--- /dev/null
+++ b/src/managed-storage.json
@@ -0,0 +1,304 @@
+{
+
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "type": "object",
+ "properties": {
+ "schemeVersion": {
+ "type": "integer"
+ },
+ "enabled": {
+ "type": "boolean"
+ },
+ "fetchNews": {
+ "type": "boolean"
+ },
+ "theme": {
+ "$ref": "Theme"
+ },
+ "presets": {
+ "type": "array",
+ "items": {
+ "$ref": "ThemePreset"
+ }
+ },
+ "customThemes": {
+ "type": "array",
+ "items": {
+ "$ref": "CustomSiteConfig"
+ }
+ },
+ "enabledByDefault": {
+ "type": "boolean"
+ },
+ "enabledFor": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "minLength": 1
+ }
+ },
+ "disabledFor": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "minLength": 1
+ }
+ },
+ "changeBrowserTheme": {
+ "type": "boolean"
+ },
+ "syncSettings": {
+ "type": "boolean"
+ },
+ "syncSitesFixes": {
+ "type": "boolean"
+ },
+ "automation": {
+ "$ref": "Automation"
+ },
+ "time": {
+ "$ref": "TimeSettings"
+ },
+ "location": {
+ "$ref": "LocationSettings"
+ },
+ "previewNewDesign": {
+ "type": "boolean"
+ },
+ "previewNewestDesign": {
+ "type": "boolean"
+ },
+ "enableForPDF": {
+ "type": "boolean"
+ },
+ "enableForProtectedPages": {
+ "type": "boolean"
+ },
+ "enableContextMenus": {
+ "type": "boolean"
+ },
+ "detectDarkTheme": {
+ "type": "boolean"
+ },
+ // Chrome's JSON schema format is weird and doesn't support `definitions` property and thus `#/definitions` references
+ // https://datatracker.ietf.org/doc/html/draft-zyp-json-schema-03
+ // This "property" mimics it
+ "definitions": {
+ "type": "object",
+ "properties": {
+ "Theme": {
+ "id": "Theme",
+ "type": "object",
+ "properties": {
+ "mode": {
+ "$ref": "FilterMode"
+ },
+ "brightness": {
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 200
+ },
+ "contrast": {
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 200
+ },
+ "grayscale": {
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 100
+ },
+ "sepia": {
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 100
+ },
+ "useFont": {
+ "type": "boolean"
+ },
+ "fontFamily": {
+ "type": "string",
+ "minLength": 1
+ },
+ "textStroke": {
+ "type": "number"
+ },
+ "engine": {
+ "type": "string",
+ "enum": [
+ "cssFilter",
+ "svgFilter",
+ "staticTheme",
+ "dynamicTheme"
+ ]
+ },
+ "stylesheet": {
+ "type": "string"
+ },
+ "darkSchemeBackgroundColor": {
+ "$ref": "HexColor"
+ },
+ "darkSchemeTextColor": {
+ "$ref": "HexColor"
+ },
+ "lightSchemeBackgroundColor": {
+ "$ref": "HexColor"
+ },
+ "lightSchemeTextColor": {
+ "$ref": "HexColor"
+ },
+ "scrollbarColor": {
+ "$ref": "HexColorOrAuto"
+ },
+ "selectionColor": {
+ "$ref": "HexColorOrAuto"
+ },
+ "styleSystemControls": {
+ "type": "boolean"
+ },
+ "lightColorScheme": {
+ "type": "string",
+ "minLength": 1
+ },
+ "darkColorScheme": {
+ "type": "string",
+ "minLength": 1
+ },
+ "immediateModify": {
+ "type": "boolean"
+ }
+ }
+ },
+ "HexColor": {
+ "id": "HexColor",
+ "type": "string",
+ "pattern": "^[0-9a-f]{6}$"
+ },
+ "HexColorOrAuto": {
+ "id": "HexColorOrAuto",
+ "type": "string",
+ "pattern": "^([0-9a-f]{6}|auto)$"
+ },
+ "FilterMode": {
+ "id": "FilterMode",
+ "type": "integer",
+ "enum": [
+ 0,
+ 1
+ ]
+ },
+ "ThemePreset": {
+ "id": "ThemePreset",
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "minLength": 1
+ },
+ "name": {
+ "type": "string",
+ "minLength": 1
+ },
+ "urls": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "minLength": 1
+ }
+ },
+ "theme": {
+ "$ref": "Theme"
+ }
+ },
+ "required": [
+ "id",
+ "name",
+ "urls",
+ "theme"
+ ]
+ },
+ "CustomSiteConfig": {
+ "id": "CustomSiteConfig",
+ "type": "object",
+ "properties": {
+ "url": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "minLength": 1
+ }
+ },
+ "theme": {
+ "$ref": "Theme"
+ },
+ "builtin": {
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "url",
+ "theme"
+ ]
+ },
+ "Automation": {
+ "id": "Automation",
+ "type": "object",
+ "properties": {
+ "enabled": {
+ "type": "boolean"
+ },
+ "mode": {
+ "$ref": "AutomationMode"
+ },
+ "behavior": {
+ "type": "string",
+ "enum": [
+ "OnOff",
+ "Scheme"
+ ]
+ }
+ }
+ },
+ "AutomationMode": {
+ "id": "AutomationMode",
+ "type": "string",
+ "enum": [
+ "",
+ "time",
+ "system",
+ "location"
+ ]
+ },
+ "TimeSettings": {
+ "id": "TimeSettings",
+ "type": "object",
+ "properties": {
+ "activation": {
+ "$ref": "Time"
+ },
+ "deactivation": {
+ "$ref": "Time"
+ }
+ }
+ },
+ "Time": {
+ "id": "Time",
+ "type": "string",
+ "pattern": "^((0?[0-9])|(1[0-9])|(2[0-3])):([0-5][0-9])$"
+ },
+ "LocationSettings": {
+ "id": "LocationSettings",
+ "type": "object",
+ "properties": {
+ "latitude": {
+ "type": "number"
+ },
+ "longitude": {
+ "type": "number"
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tasks/bundle-manifest.js b/tasks/bundle-manifest.js
index ae29531e67b7..f4058a129f52 100644
--- a/tasks/bundle-manifest.js
+++ b/tasks/bundle-manifest.js
@@ -4,6 +4,7 @@ import {PLATFORM} from './platform.js';
import * as reload from './reload.js';
import {createTask} from './task.js';
import {readJSON, writeJSON} from './utils.js';
+import {copyFile} from 'node:fs/promises';
async function patchManifest(platform, debug, watch, test) {
const manifest = await readJSON(absolutePath('src/manifest.json'));
@@ -16,6 +17,11 @@ async function patchManifest(platform, debug, watch, test) {
if (platform === PLATFORM.CHROMIUM_MV3) {
patched.browser_action = undefined;
}
+ if (platform === PLATFORM.CHROMIUM_MV2 || platform === PLATFORM.CHROMIUM_MV3) {
+ patched.storage = {
+ managed_schema: 'managed-storage.json',
+ };
+ }
if (debug) {
patched.version = '1';
patched.description = `Debug build, platform: ${platform}, watch: ${watch ? 'yes' : 'no'}.`;
@@ -42,6 +48,9 @@ async function manifests({platforms, debug, watch, test}) {
const manifest = await patchManifest(platform, debug, watch, test);
const destDir = getDestDir({debug, platform});
await writeJSON(`${destDir}/manifest.json`, manifest);
+ if (platform === PLATFORM.CHROMIUM_MV2 || platform === PLATFORM.CHROMIUM_MV3) {
+ await copyFile(absolutePath('src/managed-storage.json'), `${destDir}/managed-storage.json`);
+ }
}
}
@@ -49,7 +58,7 @@ const bundleManifestTask = createTask(
'bundle-manifest',
manifests,
).addWatcher(
- ['src/manifest*.json'],
+ ['src/manifest*.json', 'src/managed-storage.json'],
async (changedFiles, _, buildPlatforms) => {
const chrome = changedFiles.some((file) => file.endsWith('manifest.json'));
const platforms = {};

View file

@ -0,0 +1,23 @@
# credits to Voronind for darkreader config https://github.com/voronind-com/nix/blob/main/home/program/firefox/default.nix
{
lib,
stable,
...
}:
stable.buildNpmPackage rec {
version = "4.9.99";
pname = "dark-reader";
npmDepsHash = "sha256-m41HkwgbeRRmxJALQFJl/grYjjIqFOc47ltaesob1FA=";
env.ESBUILD_BINARY_PATH = lib.getExe stable.esbuild;
patches = [./darkeader.patch];
src = stable.fetchFromGitHub {
hash = "sha256-K375/4qOyE1Tp/T5V5uCGcNd1IVVbT1Pjdnq/8oRHj0=";
owner = "darkreader";
repo = "darkreader";
rev = "v${version}";
};
installPhase = ''
mkdir -p $out
cp build/release/darkreader-firefox.xpi $out/latest.xpi
'';
}

View file

@ -9,8 +9,8 @@ in {
"zen-browser"
];
name = "Zen Browser";
wrappedPackageName = "zen-browser-unwrapped";
unwrappedPackageName = "zen-browser";
wrappedPackageName = "zen";
unwrappedPackageName = "zen-unwrapped";
visible = true;
platforms = {
linux = {

View file

@ -1,11 +1,25 @@
# credits to Voronind for darkreader config https://github.com/voronind-com/nix/blob/main/home/program/firefox/default.nix
{
lib,
config,
options,
inputs,
stable,
system,
pkgs,
...
}: {
}: let
# at time of using this here, stylix might not be evaluated yet
# hence ensure it is by using base16 mkSchemeAttrs
base16 = pkgs.callPackage inputs.base16.lib {};
scheme = base16.mkSchemeAttrs config.stylix.base16Scheme;
mkExtension = id: install_url: {
${id} = {
inherit install_url;
installation_mode = "normal_installed";
};
};
in {
options.mods.browser.zen = {
enable = lib.mkOption {
default = false;
@ -13,6 +27,37 @@
type = lib.types.bool;
description = "Enables the zen browser";
};
extensions = lib.mkOption {
default = [
(mkExtension "uBlock0@raymondhill.net" "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi")
(mkExtension "{a6c4a591-f1b2-4f03-b3ff-767e5bedf4e7}" "https://addons.mozilla.org/firefox/downloads/latest/user-agent-string-switcher/latest.xpi")
(mkExtension "{d7742d87-e61d-4b78-b8a1-b469842139fa}" "https://addons.mozilla.org/firefox/downloads/latest/vimium-ff/latest.xpi")
(mkExtension "firefox@ghostery.com" "https://addons.mozilla.org/firefox/downloads/latest/ghostery/latest.xpi")
(mkExtension "CanvasBlocker@kkapsner.de" "https://addons.mozilla.org/firefox/downloads/latest/canvasblocker/latest.xpi")
(mkExtension "jid1-KKzOGWgsW3Ao4Q@jetpack" "https://addons.mozilla.org/firefox/downloads/latest/i-dont-care-about-cookies/latest.xpi")
(mkExtension "keepassxc-browser@keepassxc.org" "https://addons.mozilla.org/firefox/downloads/latest/keepassxc-browser/latest.xpi")
(mkExtension "@react-devtools" "https://addons.mozilla.org/firefox/downloads/latest/react-devtools/latest.xpi")
(mkExtension "extension@redux.devtools" "https://addons.mozilla.org/firefox/downloads/latest/reduxdevtools/latest.xpi")
(mkExtension "private-relay@firefox.com" "https://addons.mozilla.org/firefox/downloads/latest/private-relay/latest.xpi")
(mkExtension "addon@darkreader.org" "file://${pkgs.callPackage ./darkreader.nix {inherit lib stable;}}/latest.xpi")
];
example = [];
type = with lib.types; listOf anything;
description = ''
List of extensions via attrsets:
```nix
# id
# figure out the id via:
# nix run github:tupakkatapa/mozid -- 'https://addons.mozilla.org/en/firefox/addon/ublock-origin'
"uBlock0@raymondhill.net" = {
# install url
install_url = "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi";
# method https://mozilla.github.io/policy-templates/#extensionsettings
installation_mode = "force_installed";
};
```
'';
};
configuration = lib.mkOption {
default = {
EnableTrackingProtection = {
@ -22,15 +67,10 @@
Fingerprinting = true;
};
DisablePocket = true;
DisplayBookmarksToolbar = "never";
DisplayMenuBar = "default-off";
CaptivePortal = false;
DisableFirefoxStudies = true;
DisableTelemetry = true;
DisableFirefoxAccounts = false;
NoDefaultBookmarks = true;
OfferToSaveLogins = false;
OfferToSaveLoginsDefault = false;
PasswordManagerEnabled = false;
FirefoxHome = {
Search = true;
@ -43,27 +83,22 @@
ExtensionRecommendations = false;
SkipOnboarding = true;
};
"3rdparty".Extensions = {
"addon@darkreader.org" = {
theme = {
darkSchemeBackgroundColor = "#${scheme.base00}";
darkSchemeTextColor = "#${scheme.base05}";
};
previewNewDesign = true;
};
};
};
example = {};
type = with lib.types; attrsOf anything;
description = "Zen policy configuration. See https://mozilla.github.io/policy-templates for more information.";
};
profiles = lib.mkOption {
default = let
extensions = [
pkgs.nur.repos.rycee.firefox-addons.darkreader
pkgs.nur.repos.rycee.firefox-addons.ublock-origin
pkgs.nur.repos.rycee.firefox-addons.ghostery
pkgs.nur.repos.rycee.firefox-addons.canvasblocker
pkgs.nur.repos.rycee.firefox-addons.i-dont-care-about-cookies
pkgs.nur.repos.rycee.firefox-addons.keepassxc-browser
pkgs.nur.repos.rycee.firefox-addons.vimium
pkgs.nur.repos.rycee.firefox-addons.react-devtools
pkgs.nur.repos.rycee.firefox-addons.reduxdevtools
pkgs.nur.repos.rycee.firefox-addons.user-agent-string-switcher
pkgs.nur.repos.rycee.firefox-addons.private-relay
];
in [
default = [
{
name = "${config.conf.username}";
value = {
@ -76,7 +111,6 @@
zen.theme.accent-color = "#b4bbff";
extensions.autoDisableScopes = 0;
};
extensions.packages = extensions;
isDefault = true;
id = 0;
};
@ -93,7 +127,6 @@
zen.theme.accent-color = "#b4bbff";
extensions.autoDisableScopes = 0;
};
extensions.packages = extensions;
isDefault = false;
id = 1;
};
@ -122,25 +155,15 @@
enable = true;
package =
pkgs.wrapFirefox
(inputs.zen-browser.packages.${pkgs.system}.default.overrideAttrs (prevAttrs: {
passthru =
prevAttrs.passthru
or {}
// {
applicationName = "Zen Browser";
binaryName = "zen";
ffmpegSupport = true;
gssSupport = true;
gtk3 = pkgs.gtk3;
};
}))
inputs.zen-browser.packages.${system}.zen-browser-unwrapped
{
icon = "zen-beta";
wmClass = "zen";
hasMozSystemDirPatch = false;
pname = "zen-browser";
extraPolicies =
config.mods.browser.zen.configuration
// {
ExtensionSettings = builtins.foldl' (acc: ext: acc // ext) {} config.mods.browser.zen.extensions;
};
};
policies = config.mods.browser.zen.configuration;
profiles = builtins.listToAttrs config.mods.browser.zen.profiles;
};
}

View file

@ -129,7 +129,7 @@
defaultDiskId = lib.mkOption {
default = "TODO";
example = "/dev/nvme0n1";
type = lib.types.string;
type = lib.types.str;
description = "The name, ID, UUID or similar for the default drive.";
};
rootAmount = lib.mkOption {

View file

@ -3,6 +3,7 @@
options,
config,
pkgs,
inputs,
...
}: let
# TODO remove when chromium works again
@ -147,24 +148,18 @@ in {
then {
firefox = {
enable = true;
policies = config.mods.browser.firefox.configuration;
profiles = builtins.listToAttrs config.mods.browser.firefox.profiles;
};
}
else if config.mods.homePackages.browser == "zen"
then {
zen-browser = {
enable = true;
policies = config.mods.browser.zen.configuration;
profiles = builtins.listToAttrs config.mods.browser.zen.profiles;
};
}
else if config.mods.homePackages.browser == "librewolf"
then {
librewolf-dashnix = {
enable = true;
policies = config.mods.browser.librewolf.configuration;
profiles = builtins.listToAttrs config.mods.browser.librewolf.profiles;
};
}
else {}