hellwolf / solc.nix

Providing assorted versions of solidity compilers (solc).
MIT License
17 stars 9 forks source link

Problem with `mkDefault` #16

Open beeb opened 2 months ago

beeb commented 2 months ago

Hey! I have a weird problem with mkDefault on one of my machines, could be due to recent changes in nixpkgs, not sure.

My flake:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    foundry = {
      url = "github:shazow/foundry.nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    flake-utils.url = "github:numtide/flake-utils";
    solc = {
      url = "github:hellwolf/solc.nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  outputs = { self, nixpkgs, flake-utils, foundry, solc }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          overlays = [ foundry.overlay solc.overlay ];
        };
      in
      {
        devShells.default = pkgs.mkShell {
          packages = with pkgs; [
            foundry-bin
            solc_0_8_26
            (solc.mkDefault pkgs solc_0_8_26)
          ];
        };
      });
}

Then:

$ which solc
/nix/store/h0rjvdm9k4iqj79ls0f1j36wjb62f281-python3.12-solc-select-1.0.4/bin/solc

$ which solc-0.8.26
/nix/store/z6psizxc8xlsbgf85yb8hhnza1sq946x-solc-static-0.8.26/bin/solc-0.8.26

$ solc --version
Traceback (most recent call last):
  File "/nix/store/h0rjvdm9k4iqj79ls0f1j36wjb62f281-python3.12-solc-select-1.0.4/bin/.solc-wrapped", line 9, in <module>
    sys.exit(solc())
             ^^^^^^
  File "/nix/store/h0rjvdm9k4iqj79ls0f1j36wjb62f281-python3.12-solc-select-1.0.4/lib/python3.12/site-packages/solc_select/__main__.py", line 87, in solc
    res = current_version()
          ^^^^^^^^^^^^^^^^^
  File "/nix/store/h0rjvdm9k4iqj79ls0f1j36wjb62f281-python3.12-solc-select-1.0.4/lib/python3.12/site-packages/solc_select/solc_select.py", line 67, in current_version
    raise argparse.ArgumentTypeError(
argparse.ArgumentTypeError: No solc version set. Run `solc-select use VERSION` or set SOLC_VERSION environment variable.
hellwolf commented 2 months ago

Hi!

Thanks for reporting! I will have a look.

I am aware that this issue could happen because solc-select nixpkg is in conflict with the default solc exported by this package.

I will research a bit how to solve that nicely!

beeb commented 2 months ago

It's a bit weird, because I think this version of solc doesn't come from your overlay. I removed the solc_0_8_26 and (solc.mkDefault) entries and I still have that on my path. I have a couple more things in the flake like slither-analyzer so maybe it comes from another one of the deps.

beeb commented 2 months ago

Ah yes, I confirm the problem is that slither-analyzer provides solc too and it seems it needs some environment variable to work properly. Now need to figure out how I can not make it conflict with the solc from your overlay.