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

Cannot find Git revision in ref 'refs/heads/master' since Nix 2.20 #1037

Open
ShamrockLee opened this issue Aug 18, 2024 · 0 comments · May be fixed by #1055
Open

Cannot find Git revision in ref 'refs/heads/master' since Nix 2.20 #1037

ShamrockLee opened this issue Aug 18, 2024 · 0 comments · May be fixed by #1055

Comments

@ShamrockLee
Copy link
Contributor

Description

Starting from Nix 2.20, an error appears when evaluating a Rust derivation built with dream2nix's rust-cargo-lock and buildRustPackage:

       error: Cannot find Git revision 'a1bf3a613f451af7fc0a59411c56abc47fe8e8e1' in ref 'refs/heads/master' of repository 'https://github.com/salsa-rs/salsa.git'! Please make sure that the rev exists on the ref you've specified or add allRefs = true; to fetchGit.

Steps to reproduce

  1. Place the flake.nix and flake.lock files in the "Reproduction files" in the same directory and cd.
  2. Run nix run github:NixOS/nix/2.19-maintenance flake check path:., and see successful result.
  3. Run nix run github:NixOS/nix/2.20-maintenance flake check path:., and see the error:
❯ nix run github:NixOS/nix/2.20-maintenance flake check path:.
error:
       … while checking flake output 'packages'

       … while checking the derivation 'packages.x86_64-linux.ruff'

       … while calling the 'head' builtin
         at /nix/store/g2ysyzdx76m4z7lnmyddcwdz25lx7kn1-source/lib/attrsets.nix:1575:11:
         1574|         || pred here (elemAt values 1) (head values) then
         1575|           head values
             |           ^
         1576|         else

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: Cannot find Git revision 'a1bf3a613f451af7fc0a59411c56abc47fe8e8e1' in ref 'refs/heads/master' of repository 'https://github.com/salsa-rs/salsa.git'! Please make sure that the rev exists on the ref you've specified or add allRefs = true; to fetchGit.

Reproduction files

flake.nix

{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
  inputs.flake-parts.url = "github:hercules-ci/flake-parts";
  # Build ruff of custom version with dream2nix
  inputs.dream2nix.url = "github:nix-community/dream2nix";
  # The branch name contains an unfortunate typo.
  inputs.ruff-source.url = "github:astral-sh/ruff/0.5.5";
  inputs.ruff-source.flake = false;

  outputs = {self, ...} @ inputs: let
    inherit (inputs.nixpkgs) lib;
  in
    inputs.flake-parts.lib.mkFlake {inherit inputs;} {
      perSystem = {
        config,
        self',
        inputs',
        pkgs,
        system,
        ...
      }: let
        callDream2NixModule = module:
          inputs.dream2nix.lib.evalModules {
            packageSets.nixpkgs = pkgs;
            modules = [
              module
              {
                paths.projectRoot = ./.;
                paths.projectRootFile = ./flake.nix;
                paths.package = ./.;
              }
            ];
          };
      in {
        packages = {
          ruff = callDream2NixModule (
            {
              config,
              lib,
              dream2nix,
              ...
            }: {
              imports = [
                dream2nix.modules.dream2nix.rust-cargo-lock
                dream2nix.modules.dream2nix.buildRustPackage
              ];

              deps = {nixpkgs, ...}: {
                inherit
                  (nixpkgs)
                  installShellFiles
                  rust-jemalloc-sys
                  ;
                CoreService =
                  if nixpkgs.stdenv.isDarwin
                  then nixpkgs.darwin.apple_sdk.frameworks.CoreService
                  else null;
                # For phases
                ruff-nixpkgs = nixpkgs.ruff;
              };

              name = lib.mkForce "ruff";
              version = lib.mkForce "0.5.5";

              mkDerivation = {
                src = inputs.ruff-source.outPath;
                nativeBuildInputs = with config.deps; [
                  installShellFiles
                ];
                buildInputs = with config.deps; [
                  rust-jemalloc-sys
                  CoreService
                ];
                # Install shell files
                inherit
                  (config.deps.ruff-nixpkgs)
                  postInstall
                  ;
              };

              public = {
                meta = {
                  inherit
                    (config.deps.ruff-nixpkgs.meta)
                    description
                    mainProgram
                    ;
                };
              };
            }
          );
        };
      };
      systems = lib.attrNames inputs.nixpkgs.legacyPackages;
    };
}

flake.lock

{
  "nodes": {
    "dream2nix": {
      "inputs": {
        "nixpkgs": "nixpkgs",
        "purescript-overlay": "purescript-overlay",
        "pyproject-nix": "pyproject-nix"
      },
      "locked": {
        "lastModified": 1722526955,
        "narHash": "sha256-fFS8aDnfK9Qfm2FLnQ8pqWk8FzvFEv5LvTuZTZLREnc=",
        "owner": "nix-community",
        "repo": "dream2nix",
        "rev": "3fd4c14d3683baac8d1f94286ae14fe160888b51",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "repo": "dream2nix",
        "type": "github"
      }
    },
    "flake-parts": {
      "inputs": {
        "nixpkgs-lib": "nixpkgs-lib"
      },
      "locked": {
        "lastModified": 1722555600,
        "narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=",
        "owner": "hercules-ci",
        "repo": "flake-parts",
        "rev": "8471fe90ad337a8074e957b69ca4d0089218391d",
        "type": "github"
      },
      "original": {
        "owner": "hercules-ci",
        "repo": "flake-parts",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1720181791,
        "narHash": "sha256-i4vJL12/AdyuQuviMMd1Hk2tsGt02hDNhA0Zj1m16N8=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "4284c2b73c8bce4b46a6adf23e16d9e2ec8da4bb",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixpkgs-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nixpkgs-lib": {
      "locked": {
        "lastModified": 1722555339,
        "narHash": "sha256-uFf2QeW7eAHlYXuDktm9c25OxOyCoUOQmh5SZ9amE5Q=",
        "type": "tarball",
        "url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz"
      },
      "original": {
        "type": "tarball",
        "url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz"
      }
    },
    "nixpkgs_2": {
      "locked": {
        "lastModified": 1723282977,
        "narHash": "sha256-oTK91aOlA/4IsjNAZGMEBz7Sq1zBS0Ltu4/nIQdYDOg=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "a781ff33ae258bbcfd4ed6e673860c3e923bf2cc",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-24.05",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "purescript-overlay": {
      "inputs": {
        "nixpkgs": [
          "dream2nix",
          "nixpkgs"
        ],
        "slimlock": "slimlock"
      },
      "locked": {
        "lastModified": 1696022621,
        "narHash": "sha256-eMjFmsj2G1E0Q5XiibUNgFjTiSz0GxIeSSzzVdoN730=",
        "owner": "thomashoneyman",
        "repo": "purescript-overlay",
        "rev": "047c7933abd6da8aa239904422e22d190ce55ead",
        "type": "github"
      },
      "original": {
        "owner": "thomashoneyman",
        "repo": "purescript-overlay",
        "type": "github"
      }
    },
    "pyproject-nix": {
      "flake": false,
      "locked": {
        "lastModified": 1702448246,
        "narHash": "sha256-hFg5s/hoJFv7tDpiGvEvXP0UfFvFEDgTdyHIjDVHu1I=",
        "owner": "davhau",
        "repo": "pyproject.nix",
        "rev": "5a06a2697b228c04dd2f35659b4b659ca74f7aeb",
        "type": "github"
      },
      "original": {
        "owner": "davhau",
        "ref": "dream2nix",
        "repo": "pyproject.nix",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "dream2nix": "dream2nix",
        "flake-parts": "flake-parts",
        "nixpkgs": "nixpkgs_2",
        "ruff-source": "ruff-source"
      }
    },
    "ruff-source": {
      "flake": false,
      "locked": {
        "lastModified": 1721918821,
        "narHash": "sha256-dqfK6YdAV4cdUYB8bPE9I5FduBJ90RxUA7TMvcVq6Zw=",
        "owner": "astral-sh",
        "repo": "ruff",
        "rev": "fc16d8d04d86aa94a8aac14bbb87089b64d443a1",
        "type": "github"
      },
      "original": {
        "owner": "astral-sh",
        "ref": "0.5.5",
        "repo": "ruff",
        "type": "github"
      }
    },
    "slimlock": {
      "inputs": {
        "nixpkgs": [
          "dream2nix",
          "purescript-overlay",
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1688610262,
        "narHash": "sha256-Wg0ViDotFWGWqKIQzyYCgayeH8s4U1OZcTiWTQYdAp4=",
        "owner": "thomashoneyman",
        "repo": "slimlock",
        "rev": "b5c6cdcaf636ebbebd0a1f32520929394493f1a6",
        "type": "github"
      },
      "original": {
        "owner": "thomashoneyman",
        "repo": "slimlock",
        "type": "github"
      }
    }
  },
  "root": "root",
  "version": 7
}
@yusdacra yusdacra linked a pull request Oct 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant