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 {
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;

View File

@ -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 {

View File

@ -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.";
};
};

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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.";
};
};

View File

@ -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 {