nixos/captive-browser: add defaultText for browser
easiest way to do this is to move the default expression out and abstract over what is substituted into it, using a dependent value for the default and a descriptive value for defaultText
This commit is contained in:
@@ -3,6 +3,18 @@
|
|||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.programs.captive-browser;
|
cfg = config.programs.captive-browser;
|
||||||
|
browserDefault = chromium: concatStringsSep " " [
|
||||||
|
''env XDG_CONFIG_HOME="$PREV_CONFIG_HOME"''
|
||||||
|
''${chromium}/bin/chromium''
|
||||||
|
''--user-data-dir=''${XDG_DATA_HOME:-$HOME/.local/share}/chromium-captive''
|
||||||
|
''--proxy-server="socks5://$PROXY"''
|
||||||
|
''--host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE localhost"''
|
||||||
|
''--no-first-run''
|
||||||
|
''--new-window''
|
||||||
|
''--incognito''
|
||||||
|
''-no-default-browser-check''
|
||||||
|
''http://cache.nixos.org/''
|
||||||
|
];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
###### interface
|
###### interface
|
||||||
@@ -26,18 +38,8 @@ in
|
|||||||
# the options below are the same as in "captive-browser.toml"
|
# the options below are the same as in "captive-browser.toml"
|
||||||
browser = mkOption {
|
browser = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = concatStringsSep " " [
|
default = browserDefault pkgs.chromium;
|
||||||
''env XDG_CONFIG_HOME="$PREV_CONFIG_HOME"''
|
defaultText = literalExpression (browserDefault "\${pkgs.chromium}");
|
||||||
''${pkgs.chromium}/bin/chromium''
|
|
||||||
''--user-data-dir=''${XDG_DATA_HOME:-$HOME/.local/share}/chromium-captive''
|
|
||||||
''--proxy-server="socks5://$PROXY"''
|
|
||||||
''--host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE localhost"''
|
|
||||||
''--no-first-run''
|
|
||||||
''--new-window''
|
|
||||||
''--incognito''
|
|
||||||
''-no-default-browser-check''
|
|
||||||
''http://cache.nixos.org/''
|
|
||||||
];
|
|
||||||
description = ''
|
description = ''
|
||||||
The shell (/bin/sh) command executed once the proxy starts.
|
The shell (/bin/sh) command executed once the proxy starts.
|
||||||
When browser exits, the proxy exits. An extra env var PROXY is available.
|
When browser exits, the proxy exits. An extra env var PROXY is available.
|
||||||
|
|||||||
Reference in New Issue
Block a user