0

I'm trying to change the version of netbeans using this guide. I'm using the config.nix expression inside my /etc/configuration.nix This is what it looks like:

 nixpkgs.config = {
    packageOverrides = pkgs: rec {
      myNetbeans = pkgs.stdenv.lib.overrideDerivation pkgs.netbeans ( oldAttrs: {
        name = "netbeans-8.1";
        src = fetchurl {
          url = ttp://download.netbeans.org/netbeans/8.1/final/zip/netbeans-8.1-201510222201.zip;
          md5 = "361ce18421761a057bad5cb6cf7b58f4";
        };
      });
    };
  };

I believe I have everything right but it is unable to find fetchurl and I get these errors.

error: undefined variable ‘fetchurl’ at /etc/nixos/configuration.nix:83:15 (use ‘--show-trace’ to show detailed location information) error: undefined variable ‘fetchurl’ at /etc/nixos/configuration.nix:83:15 (use ‘--show-trace’ to show detailed location information) building the system configuration... error: undefined variable ‘fetchurl’ at /etc/nixos/configuration.nix:83:15 (use ‘--show-trace’ to show detailed location information)

How can I fix this error and get netbeans upgraded?

3

You're nearly there. The fetchurl variable is only present/defined in the scope of the pkgs set. That's the cause of the error message saying the fetchurl variable is undefined. So simply access the fetchurl attribute from the scope of the pkgs set, i.e. pkgs.fetchurl, the same as you have for pkgs.netbeans.

If you need to access lots of attributes from a set then make use of the with nix language construct (ref).

PS you'll need to correct the typo in url = http://.

  • Thanks! that worked great! I also had to add myNetbeans to the packages. I guess I could just use netbeans... – John Mercier Mar 23 '16 at 2:46
  • Do you mean because you then had to install it into your .nix-profile using the imperative nix-env -i? If so you could instead install it declaratively by setting environment.systemPackages = [ pkgs.myNetbeans ]; (ref). The flexibility to customise packages as you desire is a really strong feature of nix. – brocking Mar 23 '16 at 13:51
  • Yes that is what I mean. I put this all into my configuration.nix. – John Mercier Mar 24 '16 at 0:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.