nix-community / wiki

Nixos wiki [maintainer=@samueldr]
http://wiki.nixos.org/
MIT License
102 stars 7 forks source link

Wiki suggests `builtins.fetchurl` takes a 'hash' parameter #44

Open nmattia opened 1 year ago

nmattia commented 1 year ago

I'm not fixing directly since I don't know what the right way to do it is, but:

Screenshot 2022-12-17 at 17 31 07

and trying it out:

  src = fetchurl {
    url = "foo.zip";
    hash = "sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw==";
  };

gives:

error: undefined variable 'fetchurl'

and

  src = builtins.fetchurl {
    url = "foo.zip";
    hash = "sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw==";
  };

gives:

error: unsupported argument 'hash' to 'fetchurl'

until finally:

  src = pkgs.fetchurl {
    url = "foo.zip";
    hash = "sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw==";
  };

works, though this it's surprising that a seemingly Nix, general wiki entry documents nixpkgs-specific behavior

Mic92 commented 1 year ago

I could not find any instance of builtins.fetchurl using hash in the wiki. Where did you find this?

nmattia commented 1 year ago

@Mic92 there is none, but since fetchurl is introduced without context I assumed it was builtins.fetchurl instead of nixpkgs' fetchurl, hence my confusion