Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchFromGitHub not validating hashes #10847

Closed
KevinGimbel opened this issue Jun 4, 2024 · 3 comments
Closed

fetchFromGitHub not validating hashes #10847

KevinGimbel opened this issue Jun 4, 2024 · 3 comments
Labels
bug derivation-build The process of building an individual derivation (see also sandbox label) error-messages Confusing messages and better diagnostics

Comments

@KevinGimbel
Copy link

Describe the bug

A clear and concise description of what the bug is.

Steps To Reproduce

  1. Save the following as shell.nix
let
    pkgs = import <nixpkgs> {};

    mktoc = pkgs.fetchFromGitHub {
        owner   = "KevinGimbel";
        repo    = "mktoc";
        rev     = "v4.0.0";
        hash    = "sha256-XNrn89Vv8R5r5hmDhGZVcYcUdY3Zw/+Ss/x7YfEtX2A=";
    };

    installed_pkgs = [
      mktoc
    ];
in


pkgs.mkShellNoCC {
  packages = installed_pkgs;
  # executed on start
  shellHook = ''
    mktoc --version
  '';
}
  1. Run nix-shell -v shell.nix

Now with the wrong hash, I'd expect nix to not install the tool and notify me about the hash mismatch. But it doesn't.

If I remove the hash it works:

warning: found empty hash, assuming 'sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='
[...]
  specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
            got:    sha256-Pq4o0t0cUrkXff+qSU5mlDo5A0nhFBuFk3Xz10AWDeo=

Expected behavior

nix should not install anything if the hash doesn't match.

sha256-XNrn89Vv8R5r5hmDhGZVcYcUdY3Zw/+Ss/x7YfEtX2A= isn't the hash of this repo, it's the hash from kubectl v0.30.1 and has nothing to do with mktoc (the tool I try to install).

nix-env --version output
nix-env (Nix) 2.22.1

Additional context

OS: macOS

Priorities

Add 👍 to issues you find important.

@KevinGimbel KevinGimbel added the bug label Jun 4, 2024
@szlend
Copy link
Member

szlend commented Jun 4, 2024

This is unfortunate, but working as intended. Fixed output derivations don't care about any inputs. They will pick anything that matches the hash from the nix store.

@SuperSandro2000
Copy link
Member

fetchFromGitHub is in nixpkgs and as already said this is an intended feature. Please close.

@roberth roberth added error-messages Confusing messages and better diagnostics derivation-build The process of building an individual derivation (see also sandbox label) labels Jun 5, 2024
@roberth
Copy link
Member

roberth commented Jun 5, 2024

Duplicate, but a relevant discussion is in

@roberth roberth closed this as completed Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug derivation-build The process of building an individual derivation (see also sandbox label) error-messages Confusing messages and better diagnostics
Projects
None yet
Development

No branches or pull requests

4 participants