nix-bitcoin icon indicating copy to clipboard operation
nix-bitcoin copied to clipboard

Recursion...?

Open IngwiePhoenix opened this issue 2 years ago • 0 comments

Hello!

I followed the guide on how to add this to an existing configuration, but now I get this error:

"error: infinite recursion encountered"
error:
       … while evaluating the attribute 'config.system.build.toplevel'

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:322:9:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          323|         _module = checked (config._module);

       … while calling the 'seq' builtin

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:322:18:

          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          323|         _module = checked (config._module);

       … while evaluating a branch condition

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:261:9:

          260|       checkUnmatched =
          261|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
             |         ^
          262|           let

       … in the left operand of the AND (&&) operator

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:261:72:

          260|       checkUnmatched =
          261|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
             |                                                                        ^
          262|           let

       … in the left operand of the AND (&&) operator

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:261:33:

          260|       checkUnmatched =
          261|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
             |                                 ^
          262|           let

       … while evaluating a branch condition

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:254:12:

          253|
          254|         in if declaredConfig._module.freeformType == null then declaredConfig
             |            ^
          255|           # Because all definitions that had an associated option ended in

       … from call site

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:242:28:

          241|           # For definitions that have an associated option
          242|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                            ^
          243|

       … while calling 'mapAttrsRecursiveCond'

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/attrsets.nix:731:5:

          730|     # Attribute set to recursively map over.
          731|     set:
             |     ^
          732|     let

       … from call site

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:234:33:

          233|           ({ inherit lib options config specialArgs; } // specialArgs);
          234|         in mergeModules prefix (reverseList collected);
             |                                 ^
          235|

       … while calling 'reverseList'

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/lists.nix:504:17:

          503|   */
          504|   reverseList = xs:
             |                 ^
          505|     let l = length xs; in genList (n: elemAt xs (l - n - 1)) l;

       … from call site

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:229:25:

          228|       merged =
          229|         let collected = collectModules
             |                         ^
          230|           class

       … while calling anonymous lambda

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:445:37:

          444|
          445|     in modulesPath: initialModules: args:
             |                                     ^
          446|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);

       … from call site

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:446:7:

          445|     in modulesPath: initialModules: args:
          446|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);
             |       ^
          447|

       … while calling 'filterModules'

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:413:36:

          412|       # modules recursively. It returns the final list of unique-by-key modules
          413|       filterModules = modulesPath: { disabled, modules }:
             |                                    ^
          414|         let

       … while calling anonymous lambda

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:439:31:

          438|           disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabled;
          439|           keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
             |                               ^
          440|         in map (attrs: attrs.module) (builtins.genericClosure {

       … from call site

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:400:22:

          399|           let
          400|             module = checkModule (loadModule args parentFile "${parentKey}:anon-${toString n}" x);
             |                      ^
          401|             collectedImports = collectStructuredModules module._file module.key module.imports args;

       … while calling anonymous lambda

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:359:11:

          358|         then
          359|           m:
             |           ^
          360|             if m._class != null -> m._class == class

       … from call site

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:400:35:

          399|           let
          400|             module = checkModule (loadModule args parentFile "${parentKey}:anon-${toString n}" x);
             |                                   ^
          401|             collectedImports = collectStructuredModules module._file module.key module.imports args;

       … while calling 'loadModule'

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:336:53:

          335|       # Like unifyModuleSyntax, but also imports paths and calls functions if necessary
          336|       loadModule = args: fallbackFile: fallbackKey: m:
             |                                                     ^
          337|         if isFunction m then

       … from call site

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:337:12:

          336|       loadModule = args: fallbackFile: fallbackKey: m:
          337|         if isFunction m then
             |            ^
          338|           unifyModuleSyntax fallbackFile fallbackKey (applyModuleArgs fallbackKey m args)

       … while calling 'isFunction'

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/trivial.nix:443:16:

          442|   */
          443|   isFunction = f: builtins.isFunction f ||
             |                ^
          444|     (f ? __functor && isFunction (f.__functor f));

       … while calling anonymous lambda

         at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:506:44:

          505|       context = name: ''while evaluating the module argument `${name}' in "${key}":'';
          506|       extraArgs = builtins.mapAttrs (name: _:
             |                                            ^
          507|         builtins.addErrorContext (context name)

       … while evaluating the module argument `pkgs' in "/etc/nixos/configuration.nix":

       error: infinite recursion encountered

       at /nix/store/ljwdzrj5pgx6ymh7jwmpl65bwkvk7qml-nixos/nixos/lib/modules.nix:508:28:

          507|         builtins.addErrorContext (context name)
          508|           (args.${name} or config._module.args.${name})
             |                            ^
          509|       ) (lib.functionArgs f);

This is the configuration that I am using right now (Its messy, sorry... xD)

configuration.nix
# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, lib, modulesPath, ... }:
let

  nix-bitcoin = pkgs.fetchGithub {
    # https://github.com/fort-nix/nix-bitcoin
    owner = "fort-nix";
    repo = "nix-bitcoin";
    rev = "nixos-23.11";
  };

  tor = {
    socks = "192.168.2.1:9050";
    onion = "192.168.2.1:9001";
  };
  i2p = {
    socks = "192.168.2.1:4447";
    sam = "192.168.2.1:7656";
  };

in {
  imports = [
    "${modulesPath}/virtualisation/lxc-container.nix"
    "${nix-bitcoin}/modules/modules.nix"
  ];

  networking = {
    dhcpcd.enable = false;
    useDHCP = false;
    useHostResolvConf = false;
    hostName = "nixboi";
  };

  systemd.network = {
    enable = true;
    networks."50-eth0" = {
      matchConfig.Name = "eth0";
      networkConfig = {
        DHCP = "ipv4";
        IPv6AcceptRA = true;
      };
      linkConfig.RequiredForOnline = "routable";
    };
  };

  ## Via: https://leo.leung.xyz/wiki/NixOS_inside_LXC_on_Proxmox
  # Supress systemd units that don't work because of LXC
  systemd.suppressedSystemUnits = [
    "dev-mqueue.mount"
    "sys-kernel-debug.mount"
    "sys-fs-fuse-connections.mount"
  ];

  # start tty0 on serial console
  systemd.services."getty@tty1" = {
    enable = lib.mkForce true;
    wantedBy = [ "getty.target" ]; # to start at boot
    serviceConfig.Restart = "always"; # restart when session is closed
  };

  users = {
    defaultUserShell = pkgs.fish;
    mutableUsers = false;
    users.root = {
      openssh.authorizedKeys.keys = [
      # ...
      ];
    };
  };

  environment.systemPackages = with pkgs; [
    nano binutils fish coreutils
    htop btop
  ];

  # Package config
  programs.fish = {
    enable = true;
    vendor.config.enable = true;
    vendor.completions.enable = true;
  };

  system.stateVersion = "23.11";
  system.autoUpgrade = {
    enable = true;
    persistent = true;
    # Do I even need this in LXC?
    allowReboot = true;
    rebootWindow = {
      lower = "01:00";
      upper = "05:00";
    };
    dates = "daily";
  };

  # Classic.
  services.openssh.enable = true;

  # And here, we coin.
  services = {
    bitcoind = {
      enable = false;
      address = "0.0.0.0";
      listen = true;
      #getPublicAddressCmd = "${pkgs.curl}/bin/curl -L https://ifconfig.me";
      rpc = "0.0.0.0"; # Because, I can.
      allowip = ["192.168.2.0/24" "100.64.0.0/24"];
      disablewallet = false;
      
      extraConfig = ''
        # TODO: IPv4/v6 fwd; its an in-network IP.
        upnp=0
        # Configure external Tor + i2pd
        i2psam=${i2p.sam}
        onion=${tor.socks}
      '';
    };
    # telegraf, for monitoring.
    #
    clightning = {
      enable = false;
      address = "0.0.0.0";
      proxy = tor.socks;
      always-use-proxy = true;
      wallet = "sqlite3:///var/lib/clightning/bitcoin/lightningd.sqlite3";
      plugins = {
        ## currencyrate : Converts things
        #currencyrate.enable = true;
        ## monitor : Basic monitoring
        #monitor.enable
        ## Prometheus : Proper monitoring
        #prometheus.enable = true;
        #prometheus.listen = "0.0.0.0:9900";
      };
    };
    clightning-rest = {
      enable = false;
      lndconnect = {
        enable = true;
        onion = true;
      };
    };
    monero = {
      enable = false;
      mining = {
        enable = false;
        #address = "";
      };
      # Lazy auto-expose to everywhere.
      rpc.address = "0.0.0.0";
      #extraConfig = `` ... ``;
    };
  };

  ## nix-bitcoin specifica
  #nix-bitcoin = {
  #  generateSecrets = true;
  #  
  #};
  # Prevent garbage collection of the nix-bitcoin source
  #system.extraDependencies = [ nix-bitcoin ];
}

Can you help me figure out what I missed? I am still working out the basics; I want to ready the config first. Right now, my bitcoind/cln runs in an alpine chroot - I would like to relocate that into this NixOS lxc so I can move it around as much as I'd like. LXC is good for that :)

Kind regards, Ingwie

IngwiePhoenix avatar Mar 02 '24 20:03 IngwiePhoenix