feat(desktop/firefox): add synced profile support and move desktop config
This commit is contained in:
parent
7e256c954d
commit
02c356494a
6 changed files with 82 additions and 47 deletions
|
@ -1,12 +1,30 @@
|
|||
{ osConfig, lib, ... }:
|
||||
let
|
||||
inherit (builtins) map listToAttrs;
|
||||
inherit (lib.lists) findFirstIndex;
|
||||
cfg = osConfig.desktop.browser.firefox;
|
||||
profileCfg = id: {
|
||||
inherit id;
|
||||
};
|
||||
profiles = listToAttrs (
|
||||
map (name: {
|
||||
inherit name;
|
||||
# If there are duplicate profile names, findFirstIndex will cause issues.
|
||||
# We sanitize the input in nixosModules.desktop to avoid this.
|
||||
value = profileCfg (findFirstIndex (x: x == name) null cfg.syncedProfiles);
|
||||
}) cfg.syncedProfiles
|
||||
);
|
||||
in
|
||||
{
|
||||
config = lib.mkIf (osConfig.desktop.browser == "firefox") {
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.persistence."/persist/home/rafiq".directories = [ ".mozilla/firefox" ];
|
||||
home.sessionVariables.BROWSER = "firefox";
|
||||
programs.firefox = {
|
||||
enable = true;
|
||||
profiles.rafiq.id = 0;
|
||||
profiles.test.id = 1;
|
||||
inherit profiles;
|
||||
};
|
||||
stylix.targets.firefox = {
|
||||
profileNames = cfg.syncedProfiles;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
25
modules/nixos/desktop/browser/default.nix
Normal file
25
modules/nixos/desktop/browser/default.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{ lib, config, ... }:
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption;
|
||||
inherit (lib.types) listOf str;
|
||||
inherit (lib.lists) allUnique;
|
||||
cfg = config.desktop.browser;
|
||||
in
|
||||
{
|
||||
options.desktop.browser = {
|
||||
firefox = {
|
||||
enable = mkEnableOption "";
|
||||
syncedProfiles = mkOption {
|
||||
type = listOf str;
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config.assertions = [
|
||||
{
|
||||
assertion = allUnique cfg.firefox.syncedProfiles;
|
||||
message = "desktop.browser.firefox.syncedProfiles has duplicate elements.";
|
||||
}
|
||||
];
|
||||
}
|
|
@ -18,7 +18,6 @@
|
|||
};
|
||||
windowManager = lib.pantheon.mkStrOption;
|
||||
lockscreen = lib.pantheon.mkStrOption;
|
||||
browser = lib.pantheon.mkStrOption;
|
||||
terminal = lib.pantheon.mkStrOption;
|
||||
notification-daemon = lib.pantheon.mkStrOption;
|
||||
launcher = lib.pantheon.mkStrOption;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue