From 3681f118f72e53e215a9bdcd453fa06dab81eafe Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Wed, 8 Dec 2021 04:07:28 +0100 Subject: [PATCH] nix-bitcoin.nix: add `defaultText` (automatic) This enables generating module option documentation. This commit was genereated by running the following script inside the repo root dir: def add_default_text(file) src = File.read(file) src2 = src.gsub(/( = mkOption\s+\{[^{]*?)(\n\s+default = )(.*?);$(.*?\})/m) do |str| pre, defaultVar, default, post = Regexp.last_match.captures replacement = if !post.include?('defaultText =') if default =~ /\bpkgs\b/ defaultText = default.lines.length == 1 ? default : "(See source)" "#{pre}#{defaultVar}#{default};#{defaultVar.sub('default', 'defaultText')}#{defaultText.inspect};#{post}" end end replacement or str end File.write(file, src2) if src2 != src end Dir["modules/**/*.nix"].each do |f| next if File.basename(f) == "nix-bitcoin.nix" add_default_text f end --- modules/bitcoind.nix | 2 ++ modules/btcpayserver.nix | 2 ++ modules/clightning-plugins/clboss.nix | 1 + modules/clightning.nix | 1 + modules/lightning-loop.nix | 2 ++ modules/lightning-pool.nix | 2 ++ modules/liquid.nix | 2 ++ modules/lnd-rest-onion-service.nix | 1 + modules/lnd.nix | 2 ++ 9 files changed, 15 insertions(+) diff --git a/modules/bitcoind.nix b/modules/bitcoind.nix index 2d1ea64..f158cce 100644 --- a/modules/bitcoind.nix +++ b/modules/bitcoind.nix @@ -57,6 +57,7 @@ let package = mkOption { type = types.package; default = config.nix-bitcoin.pkgs.bitcoind; + defaultText = "config.nix-bitcoin.pkgs.bitcoind"; description = "The package providing bitcoin binaries."; }; extraConfig = mkOption { @@ -265,6 +266,7 @@ let default = pkgs.writeScriptBin "bitcoin-cli" '' exec ${cfg.package}/bin/bitcoin-cli -datadir='${cfg.dataDir}' "$@" ''; + defaultText = "(See source)"; description = "Binary to connect with the bitcoind instance."; }; tor = nbLib.tor; diff --git a/modules/btcpayserver.nix b/modules/btcpayserver.nix index b1926e1..47b152e 100644 --- a/modules/btcpayserver.nix +++ b/modules/btcpayserver.nix @@ -21,6 +21,7 @@ let config.nix-bitcoin.pkgs.btcpayserver.override { altcoinSupport = true; } else config.nix-bitcoin.pkgs.btcpayserver; + defaultText = "(See source)"; description = "The package providing btcpayserver binaries."; }; dataDir = mkOption { @@ -69,6 +70,7 @@ let package = mkOption { type = types.package; default = config.nix-bitcoin.pkgs.nbxplorer; + defaultText = "config.nix-bitcoin.pkgs.nbxplorer"; description = "The package providing nbxplorer binaries."; }; address = mkOption { diff --git a/modules/clightning-plugins/clboss.nix b/modules/clightning-plugins/clboss.nix index fe48358..970a9cc 100644 --- a/modules/clightning-plugins/clboss.nix +++ b/modules/clightning-plugins/clboss.nix @@ -17,6 +17,7 @@ let cfg = config.services.clightning.plugins.clboss; in package = mkOption { type = types.package; default = config.nix-bitcoin.pkgs.clboss; + defaultText = "config.nix-bitcoin.pkgs.clboss"; description = "The package providing clboss binaries."; }; }; diff --git a/modules/clightning.nix b/modules/clightning.nix index 4e1f3dc..965ae81 100644 --- a/modules/clightning.nix +++ b/modules/clightning.nix @@ -69,6 +69,7 @@ let default = pkgs.writeScriptBin "lightning-cli" '' ${nbPkgs.clightning}/bin/lightning-cli --lightning-dir='${cfg.dataDir}' "$@" ''; + defaultText = "(See source)"; description = "Binary to connect with the clightning instance."; }; getPublicAddressCmd = mkOption { diff --git a/modules/lightning-loop.nix b/modules/lightning-loop.nix index 2d2441a..8d9039b 100644 --- a/modules/lightning-loop.nix +++ b/modules/lightning-loop.nix @@ -27,6 +27,7 @@ let package = mkOption { type = types.package; default = config.nix-bitcoin.pkgs.lightning-loop; + defaultText = "config.nix-bitcoin.pkgs.lightning-loop"; description = "The package providing lightning-loop binaries."; }; dataDir = mkOption { @@ -54,6 +55,7 @@ let --macaroonpath '${cfg.dataDir}/${network}/loop.macaroon' \ --tlscertpath '${secretsDir}/loop-cert' "$@" ''; + defaultText = "(See source)"; description = "Binary to connect with the lightning-loop instance."; }; tor = nbLib.tor; diff --git a/modules/lightning-pool.nix b/modules/lightning-pool.nix index c93aa6a..092a83f 100644 --- a/modules/lightning-pool.nix +++ b/modules/lightning-pool.nix @@ -27,6 +27,7 @@ let package = mkOption { type = types.package; default = config.nix-bitcoin.pkgs.lightning-pool; + defaultText = "config.nix-bitcoin.pkgs.lightning-pool"; description = "The package providing lightning-pool binaries."; }; dataDir = mkOption { @@ -54,6 +55,7 @@ let --network ${network} \ --basedir '${cfg.dataDir}' "$@" ''; + defaultText = "(See source)"; description = "Binary to connect with the lightning-pool instance."; }; tor = nbLib.tor; diff --git a/modules/liquid.nix b/modules/liquid.nix index 6e7e6ad..3e45992 100644 --- a/modules/liquid.nix +++ b/modules/liquid.nix @@ -148,12 +148,14 @@ let default = pkgs.writeScriptBin "elements-cli" '' ${nbPkgs.elementsd}/bin/elements-cli -datadir='${cfg.dataDir}' "$@" ''; + defaultText = "(See source)"; description = "Binary to connect with the liquidd instance."; }; swapCli = mkOption { default = pkgs.writeScriptBin "liquidswap-cli" '' ${nbPkgs.liquid-swap}/bin/liquidswap-cli -c '${cfg.dataDir}/elements.conf' "$@" ''; + defaultText = "(See source)"; description = "Binary for managing liquid swaps."; }; tor = nbLib.tor; diff --git a/modules/lnd-rest-onion-service.nix b/modules/lnd-rest-onion-service.nix index 3d845c1..f2c94d5 100644 --- a/modules/lnd-rest-onion-service.nix +++ b/modules/lnd-rest-onion-service.nix @@ -15,6 +15,7 @@ let package = mkOption { type = types.package; default = config.nix-bitcoin.pkgs.lndconnect; + defaultText = "config.nix-bitcoin.pkgs.lndconnect"; description = "The package providing lndconnect binaries."; }; }; diff --git a/modules/lnd.nix b/modules/lnd.nix index 5d14846..409f1a7 100644 --- a/modules/lnd.nix +++ b/modules/lnd.nix @@ -81,6 +81,7 @@ let package = mkOption { type = types.package; default = config.nix-bitcoin.pkgs.lnd; + defaultText = "config.nix-bitcoin.pkgs.lnd"; description = "The package providing lnd binaries."; }; cli = mkOption { @@ -92,6 +93,7 @@ let --tlscertpath '${cfg.certPath}' \ --macaroonpath '${networkDir}/admin.macaroon' "$@" ''; + defaultText = "(See source)"; description = "Binary to connect with the lnd instance."; }; getPublicAddressCmd = mkOption {