summary refs log tree commit diff
diff options
context:
space:
mode:
authorpennae <github@quasiparticle.net>2021-12-05 22:52:01 +0100
committerpennae <github@quasiparticle.net>2021-12-09 01:42:24 +0100
commit1f960e7571d46bd13dd4b5865f115467e100ef7d (patch)
tree527a13203f7c271462a533a77e38f3732c2fef4f
parent0eaf46a1dc961216016a886818ac2a66c14c74e6 (diff)
downloadnixpkgs-1f960e7571d46bd13dd4b5865f115467e100ef7d.tar
nixpkgs-1f960e7571d46bd13dd4b5865f115467e100ef7d.tar.gz
nixpkgs-1f960e7571d46bd13dd4b5865f115467e100ef7d.tar.bz2
nixpkgs-1f960e7571d46bd13dd4b5865f115467e100ef7d.tar.lz
nixpkgs-1f960e7571d46bd13dd4b5865f115467e100ef7d.tar.xz
nixpkgs-1f960e7571d46bd13dd4b5865f115467e100ef7d.tar.zst
nixpkgs-1f960e7571d46bd13dd4b5865f115467e100ef7d.zip
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
-rw-r--r--nixos/modules/programs/captive-browser.nix26
1 files changed, 14 insertions, 12 deletions
diff --git a/nixos/modules/programs/captive-browser.nix b/nixos/modules/programs/captive-browser.nix
index 0f5d087e8d8..dc054504ea4 100644
--- a/nixos/modules/programs/captive-browser.nix
+++ b/nixos/modules/programs/captive-browser.nix
@@ -3,6 +3,18 @@
 with lib;
 let
   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
 {
   ###### interface
@@ -26,18 +38,8 @@ in
       # the options below are the same as in "captive-browser.toml"
       browser = mkOption {
         type = types.str;
-        default = concatStringsSep " " [
-          ''env XDG_CONFIG_HOME="$PREV_CONFIG_HOME"''
-          ''${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/''
-        ];
+        default = browserDefault pkgs.chromium;
+        defaultText = literalExpression (browserDefault "\${pkgs.chromium}");
         description = ''
           The shell (/bin/sh) command executed once the proxy starts.
           When browser exits, the proxy exits. An extra env var PROXY is available.