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
This commit is contained in:
Erik Arvstedt 2021-12-08 04:07:28 +01:00
parent d24c029435
commit 3681f118f7
No known key found for this signature in database
GPG Key ID: 33312B944DD97846
9 changed files with 15 additions and 0 deletions

View File

@ -57,6 +57,7 @@ let
package = mkOption { package = mkOption {
type = types.package; type = types.package;
default = config.nix-bitcoin.pkgs.bitcoind; default = config.nix-bitcoin.pkgs.bitcoind;
defaultText = "config.nix-bitcoin.pkgs.bitcoind";
description = "The package providing bitcoin binaries."; description = "The package providing bitcoin binaries.";
}; };
extraConfig = mkOption { extraConfig = mkOption {
@ -265,6 +266,7 @@ let
default = pkgs.writeScriptBin "bitcoin-cli" '' default = pkgs.writeScriptBin "bitcoin-cli" ''
exec ${cfg.package}/bin/bitcoin-cli -datadir='${cfg.dataDir}' "$@" exec ${cfg.package}/bin/bitcoin-cli -datadir='${cfg.dataDir}' "$@"
''; '';
defaultText = "(See source)";
description = "Binary to connect with the bitcoind instance."; description = "Binary to connect with the bitcoind instance.";
}; };
tor = nbLib.tor; tor = nbLib.tor;

View File

@ -21,6 +21,7 @@ let
config.nix-bitcoin.pkgs.btcpayserver.override { altcoinSupport = true; } config.nix-bitcoin.pkgs.btcpayserver.override { altcoinSupport = true; }
else else
config.nix-bitcoin.pkgs.btcpayserver; config.nix-bitcoin.pkgs.btcpayserver;
defaultText = "(See source)";
description = "The package providing btcpayserver binaries."; description = "The package providing btcpayserver binaries.";
}; };
dataDir = mkOption { dataDir = mkOption {
@ -69,6 +70,7 @@ let
package = mkOption { package = mkOption {
type = types.package; type = types.package;
default = config.nix-bitcoin.pkgs.nbxplorer; default = config.nix-bitcoin.pkgs.nbxplorer;
defaultText = "config.nix-bitcoin.pkgs.nbxplorer";
description = "The package providing nbxplorer binaries."; description = "The package providing nbxplorer binaries.";
}; };
address = mkOption { address = mkOption {

View File

@ -17,6 +17,7 @@ let cfg = config.services.clightning.plugins.clboss; in
package = mkOption { package = mkOption {
type = types.package; type = types.package;
default = config.nix-bitcoin.pkgs.clboss; default = config.nix-bitcoin.pkgs.clboss;
defaultText = "config.nix-bitcoin.pkgs.clboss";
description = "The package providing clboss binaries."; description = "The package providing clboss binaries.";
}; };
}; };

View File

@ -69,6 +69,7 @@ let
default = pkgs.writeScriptBin "lightning-cli" '' default = pkgs.writeScriptBin "lightning-cli" ''
${nbPkgs.clightning}/bin/lightning-cli --lightning-dir='${cfg.dataDir}' "$@" ${nbPkgs.clightning}/bin/lightning-cli --lightning-dir='${cfg.dataDir}' "$@"
''; '';
defaultText = "(See source)";
description = "Binary to connect with the clightning instance."; description = "Binary to connect with the clightning instance.";
}; };
getPublicAddressCmd = mkOption { getPublicAddressCmd = mkOption {

View File

@ -27,6 +27,7 @@ let
package = mkOption { package = mkOption {
type = types.package; type = types.package;
default = config.nix-bitcoin.pkgs.lightning-loop; default = config.nix-bitcoin.pkgs.lightning-loop;
defaultText = "config.nix-bitcoin.pkgs.lightning-loop";
description = "The package providing lightning-loop binaries."; description = "The package providing lightning-loop binaries.";
}; };
dataDir = mkOption { dataDir = mkOption {
@ -54,6 +55,7 @@ let
--macaroonpath '${cfg.dataDir}/${network}/loop.macaroon' \ --macaroonpath '${cfg.dataDir}/${network}/loop.macaroon' \
--tlscertpath '${secretsDir}/loop-cert' "$@" --tlscertpath '${secretsDir}/loop-cert' "$@"
''; '';
defaultText = "(See source)";
description = "Binary to connect with the lightning-loop instance."; description = "Binary to connect with the lightning-loop instance.";
}; };
tor = nbLib.tor; tor = nbLib.tor;

View File

@ -27,6 +27,7 @@ let
package = mkOption { package = mkOption {
type = types.package; type = types.package;
default = config.nix-bitcoin.pkgs.lightning-pool; default = config.nix-bitcoin.pkgs.lightning-pool;
defaultText = "config.nix-bitcoin.pkgs.lightning-pool";
description = "The package providing lightning-pool binaries."; description = "The package providing lightning-pool binaries.";
}; };
dataDir = mkOption { dataDir = mkOption {
@ -54,6 +55,7 @@ let
--network ${network} \ --network ${network} \
--basedir '${cfg.dataDir}' "$@" --basedir '${cfg.dataDir}' "$@"
''; '';
defaultText = "(See source)";
description = "Binary to connect with the lightning-pool instance."; description = "Binary to connect with the lightning-pool instance.";
}; };
tor = nbLib.tor; tor = nbLib.tor;

View File

@ -148,12 +148,14 @@ let
default = pkgs.writeScriptBin "elements-cli" '' default = pkgs.writeScriptBin "elements-cli" ''
${nbPkgs.elementsd}/bin/elements-cli -datadir='${cfg.dataDir}' "$@" ${nbPkgs.elementsd}/bin/elements-cli -datadir='${cfg.dataDir}' "$@"
''; '';
defaultText = "(See source)";
description = "Binary to connect with the liquidd instance."; description = "Binary to connect with the liquidd instance.";
}; };
swapCli = mkOption { swapCli = mkOption {
default = pkgs.writeScriptBin "liquidswap-cli" '' default = pkgs.writeScriptBin "liquidswap-cli" ''
${nbPkgs.liquid-swap}/bin/liquidswap-cli -c '${cfg.dataDir}/elements.conf' "$@" ${nbPkgs.liquid-swap}/bin/liquidswap-cli -c '${cfg.dataDir}/elements.conf' "$@"
''; '';
defaultText = "(See source)";
description = "Binary for managing liquid swaps."; description = "Binary for managing liquid swaps.";
}; };
tor = nbLib.tor; tor = nbLib.tor;

View File

@ -15,6 +15,7 @@ let
package = mkOption { package = mkOption {
type = types.package; type = types.package;
default = config.nix-bitcoin.pkgs.lndconnect; default = config.nix-bitcoin.pkgs.lndconnect;
defaultText = "config.nix-bitcoin.pkgs.lndconnect";
description = "The package providing lndconnect binaries."; description = "The package providing lndconnect binaries.";
}; };
}; };

View File

@ -81,6 +81,7 @@ let
package = mkOption { package = mkOption {
type = types.package; type = types.package;
default = config.nix-bitcoin.pkgs.lnd; default = config.nix-bitcoin.pkgs.lnd;
defaultText = "config.nix-bitcoin.pkgs.lnd";
description = "The package providing lnd binaries."; description = "The package providing lnd binaries.";
}; };
cli = mkOption { cli = mkOption {
@ -92,6 +93,7 @@ let
--tlscertpath '${cfg.certPath}' \ --tlscertpath '${cfg.certPath}' \
--macaroonpath '${networkDir}/admin.macaroon' "$@" --macaroonpath '${networkDir}/admin.macaroon' "$@"
''; '';
defaultText = "(See source)";
description = "Binary to connect with the lnd instance."; description = "Binary to connect with the lnd instance.";
}; };
getPublicAddressCmd = mkOption { getPublicAddressCmd = mkOption {