mirror of
https://github.com/nix-community/home-manager
synced 2024-11-05 10:49:44 +01:00
chromium: add module
This commit is contained in:
parent
f9ac73732b
commit
dd25fbcb4b
3 changed files with 101 additions and 0 deletions
|
@ -750,6 +750,13 @@ in
|
||||||
using this option.
|
using this option.
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
time = "2018-08-19T20:46:09+00:00";
|
||||||
|
message = ''
|
||||||
|
A new modules is available: 'programs.chromium'.
|
||||||
|
'';
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ let
|
||||||
./programs/bash.nix
|
./programs/bash.nix
|
||||||
./programs/beets.nix
|
./programs/beets.nix
|
||||||
./programs/browserpass.nix
|
./programs/browserpass.nix
|
||||||
|
./programs/chromium.nix
|
||||||
./programs/command-not-found/command-not-found.nix
|
./programs/command-not-found/command-not-found.nix
|
||||||
./programs/direnv.nix
|
./programs/direnv.nix
|
||||||
./programs/eclipse.nix
|
./programs/eclipse.nix
|
||||||
|
|
93
modules/programs/chromium.nix
Normal file
93
modules/programs/chromium.nix
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
browserModule = defaultPkg: name: visible:
|
||||||
|
let
|
||||||
|
browser = (builtins.parseDrvName defaultPkg.name).name;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
enable = mkOption {
|
||||||
|
inherit visible;
|
||||||
|
default = false;
|
||||||
|
example = true;
|
||||||
|
description = "Whether to enable ${name}.";
|
||||||
|
type = lib.types.bool;
|
||||||
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
inherit visible;
|
||||||
|
type = types.package;
|
||||||
|
default = defaultPkg;
|
||||||
|
defaultText = "pkgs.${browser}";
|
||||||
|
description = "The ${name} package to use.";
|
||||||
|
};
|
||||||
|
|
||||||
|
extensions = mkOption {
|
||||||
|
inherit visible;
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [];
|
||||||
|
example = literalExample ''
|
||||||
|
[
|
||||||
|
"chlffgpmiacpedhhbkiomidkjlcfhogd" # pushbullet
|
||||||
|
"mbniclmhobmnbdlbpiphghaielnnpgdp" # lightshot
|
||||||
|
"gcbommkclmclpchllfjekcdonpmejbdp" # https everywhere
|
||||||
|
"cjpalhdlnbpafiamejdnhcphjbkeiagm" # ublock origin
|
||||||
|
]
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
List of ${name} extensions to install.
|
||||||
|
To find the extension ID, check its URL on the
|
||||||
|
<link xlink:href="https://chrome.google.com/webstore/category/extensions">Chrome Web Store</link>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
browserConfig = cfg:
|
||||||
|
let
|
||||||
|
|
||||||
|
browser = (builtins.parseDrvName cfg.package).name;
|
||||||
|
|
||||||
|
darwinDirs = {
|
||||||
|
chromium = "Chromium";
|
||||||
|
google-chrome = "Google/Chrome";
|
||||||
|
google-chrome-beta = "Google/Chrome Beta";
|
||||||
|
google-chrome-dev = "Google/Chrome Dev";
|
||||||
|
};
|
||||||
|
|
||||||
|
configDir = if pkgs.stdenv.isDarwin
|
||||||
|
then "Library/Application Support/${getAttr browser darwinDirs}"
|
||||||
|
else "${config.xdg.configHome}/${browser}";
|
||||||
|
|
||||||
|
extensionJson = ext: {
|
||||||
|
target = "${configDir}/External Extensions/${ext}.json";
|
||||||
|
text = builtins.toJSON {
|
||||||
|
external_update_url = "https://clients2.google.com/service/update2/crx";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
mkIf cfg.enable {
|
||||||
|
home.packages = [ cfg.package ];
|
||||||
|
home.file = map extensionJson cfg.extensions;
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
options.programs = {
|
||||||
|
chromium = browserModule pkgs.chromium "Chromium" true;
|
||||||
|
google-chrome = browserModule pkgs.google-chrome "Google Chrome" false;
|
||||||
|
google-chrome-beta = browserModule pkgs.google-chrome-beta "Google Chrome Beta" false;
|
||||||
|
google-chrome-dev = browserModule pkgs.google-chrome-dev "Google Chrome Dev" false;
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkMerge [
|
||||||
|
(browserConfig config.programs.chromium)
|
||||||
|
(browserConfig config.programs.google-chrome)
|
||||||
|
(browserConfig config.programs.google-chrome-beta)
|
||||||
|
(browserConfig config.programs.google-chrome-dev)
|
||||||
|
];
|
||||||
|
}
|
Loading…
Reference in a new issue