Error: attempt to call something which is not a function but a set

I’m trying to setup an environment for neutron in a shell.nix file so I easily reproduce it. My shell.nix looks like this

{ pkgs ? import <nixpkgs> { } }:
let
  neuronSrc = builtins.fetchTarball "https://github.com/srid/neuron/archive/master.tar.gz";
  neuronPkg = import neuronSrc {};
in
pkgs.mkShell {
  nativeBuildInputs = with pkgs; [
    neuronPkg
  ];
  nix.binaryCaches = [
    "https://srid.cachix.org"
  ];

  shellHook = ''
    exec neuron rib -ws localhost:8080
  '';
}

When I run nix-shell --show-trace I get:

error: attempt to call something which is not a function but a set

       at /home/haf/exobrain/shell.nix:4:15:

            3|   neuronSrc = builtins.fetchTarball "https://github.com/srid/neuron/archive/master.tar.gz";
            4|   neuronPkg = import neuronSrc {};
             |               ^
            5| in

       … while evaluating anonymous lambda

       at /nix/store/8v8khi0pny77jn5fjypzzm1s5182ifip-nixos-21.05pre284548.1fe6ed37fd9/nixos/pkgs/stdenv/generic/make-derivation.nix:139:17:

          138|           (map (drv: drv.__spliced.buildBuild or drv) depsBuildBuild)
          139|           (map (drv: drv.nativeDrv or drv) nativeBuildInputs
             |                 ^
          140|              ++ lib.optional separateDebugInfo' ../../build-support/setup-hooks/separate-debug-info.sh

       … from call site

       … while evaluating 'getOutput'

       at /nix/store/8v8khi0pny77jn5fjypzzm1s5182ifip-nixos-21.05pre284548.1fe6ed37fd9/nixos/lib/attrsets.nix:482:23:

          481|   */
          482|   getOutput = output: pkg:
             |                       ^
          483|     if pkg.outputUnspecified or false

       … from call site

       … while evaluating the attribute 'nativeBuildInputs' of the derivation 'nix-shell'

       at /nix/store/8v8khi0pny77jn5fjypzzm1s5182ifip-nixos-21.05pre284548.1fe6ed37fd9/nixos/pkgs/stdenv/generic/make-derivation.nix:197:11:

          196|         // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          197|           name =
             |           ^
          198|             let

I don’t know what I’m doing wrong since when I search for similar configurations they look like mine

This is a fairly simple syntax error. Your main issue is this: import neuronSrc { }, specifically the { }. If you take a look at the default.nix in the repository, it uses something called flake-compat and the important part of that is it outputs an attrset. And you can’t “call” attrsets like you can functions. So instead you can just do import neuronSrc.

To get the package that you want you can do something like this: neuronPkg.packages.${pkgs.system}.neuron. That is the place in the attribute set that the neuron package is stored. If your curious about the format, you can learn about nix flakes and the attrset “outputs” defined in the flake spec.

Thanks, I supposed this had to do with flakes somehow, I changed my shell.nix to:

{ pkgs ? import <nixpkgs> { } }:
let
  neuronSrc = builtins.fetchTarball "https://github.com/srid/neuron/archive/master.tar.gz";
  neuronPkg = import neuronSrc;
in
pkgs.mkShell {
  nativeBuildInputs = with pkgs; [
    neuronPkg.packages.${pkgs.system}.neuron
  ];
  nix.binaryCaches = [
    "https://srid.cachix.org"
  ];

  shellHook = ''
    exec neuron rib -ws localhost:8080
  '';
}

unfortunately, now I’m getting:

error: cannot coerce a set to a string

       at /nix/store/8v8khi0pny77jn5fjypzzm1s5182ifip-nixos-21.05pre284548.1fe6ed37fd9/nixos/pkgs/stdenv/generic/make-derivation.nix:197:11:

          196|         // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          197|           name =
             |           ^
          198|             let

       … while evaluating the attribute 'nix' of the derivation 'nix-shell'

       at /nix/store/8v8khi0pny77jn5fjypzzm1s5182ifip-nixos-21.05pre284548.1fe6ed37fd9/nixos/pkgs/stdenv/generic/make-derivation.nix:197:11:

          196|         // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          197|           name =
             |           ^
          198|             let

Seems to be a problem with how I configured the binary cache, when I comment this part

  nix.binaryCaches = [
    "https://srid.cachix.org"
  ];

It works fine but spends too long compiling the packages. Any idea how I could use cachix declaratively in my shell.nix?

I also have this issue, but I have no idea what’s wrong with my config file, but it looks like a lot when I look at the trace…

Here’s my pastebin of the --show-trace : NixOS: error: attempt to call something which is not a function but a set - Pastebin.com

Here’s my configuration.nix file: configuration.nix - Pastebin.com

In your configuration.nix on lines 211 & 212, you have a } followed by a {. This is terminating the first attribute set and starting another. This happens again on lines 626 & 627.

Remove the { & } characters on those lines and that should fix the attempt to call something which is not a function but a set error.

There are other problems with your configuration, but start with this and see of the error messages are easier to understand for the other problems.

Got it!

I omitted those lines with the curly brackets.

I now have this error: error: … while evaluating the attribute 'config' at /nix/var/n - Pastebin.com

Here’s the current config file: # Edit this configuration file to define what should be installed on# your sys - Pastebin.com

At the very bottom of your error message it says error: The option `boot.initrd.boot' does not exist.

In your config on lines 40 and 42, you’re setting the option boot.initrd.boot.
I recommend using a format tool on your configuration. I use nixpkgs-fmt. This would make it easier to see what options you’re using.

I also recommend using NixOS Search - Options for finding the options you’re looking for. (See here for a list of options that are valid in boot.initrd.)