Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions pkgs/by-name/np/npc/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
lib,
rustPlatform,
fetchFromGitHub,
git,
nix,
nix-update-script,
}:
rustPlatform.buildRustPackage (finalAttrs: {
pname = "npc";
version = "1.0.0";

__structuredAttrs = true;

src = fetchFromGitHub {
owner = "samestep";
repo = "npc";
tag = "v${finalAttrs.version}";
hash = "sha256-qgg1WwxcpqxmK+xchIWbGQ/EXUJdYje9++CziTFnmtA=";
};

cargoHash = "sha256-cxkVBKqFmlHjUrmx2jbGmGgrrZLpVmi/o6HzDKckudQ=";

env = {
GIT_BIN = lib.getExe git;

@samestep samestep Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this is wrong; see samestep/npc#6. What do you think is the best solution here?

  1. Try sending another email on the Git mailing list to see if people respond this time?
  2. Add Jonathan Tan's one-line patch to the Git package definition in Nixpkgs, and target staging.
  3. Use that patch but only for the Git that gets fed to npc itself.
  4. Something else?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spotted that; I'd assumed (perhaps naively) that the bug was at least rare, so it'd be fine to just live with it until it gets fixed in the Git source code.

That said, I rather expect submitting Jonathan Tan's one-line patch as a properly formatted patch to the Git mailing list would get it accepted. And once there's a patch on the mailing list, regardless of whether it's accepted or not, I think it'd be reasonable to add it to the Nixpkgs Git package.

@samestep samestep Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd assumed (perhaps naively) that the bug was at least rare, so it'd be fine to just live with it until it gets fixed in the Git source code.

It's been several months since I've tried running npd with Git 2.48+, but if I remember correctly, I was hitting the bug pretty consistently before I pinned the older Git version. If it's not too much to ask, would you be able to try it out on your end to see if you hit it?

That said, I rather expect submitting Jonathan Tan's one-line patch as a properly formatted patch to the Git mailing list would get it accepted.

Yeah I think you're right 😅 to be honest, I've had this on my TODO list for months now. Obviously the patch itself is super easy, but then I'd also have to include a regression test, and I just haven't gotten around to understanding the Git codebase's testing setup well enough to feel confident in writing and sending it...

@me-and me-and Jul 17, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I just ran the following and didn't hit the problem in any of the ten test clones

( set -xeuo pipefail; for (( n=0; n<10; n++ )); do d="$(mktemp -d)"; git clone --mirror --filter=tree:0 https://github.com/NixOS/nixpkgs.git "$d"; rm -rf "$d"; done )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the initial clone works fine; it's the git fetch that gives the error. Although, I did also recently change how the fetching works in samestep/npc@8d5e25b, so maybe it avoids the bug now somehow? I'd be surprised though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that was 50 runs without reproducing the bug with git v2.54.0! I'll test with v2.49 now, just to be sure it's not an environmental issue...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow! And I assume this is after the more recent change to how npc fetches? If you want, it may also be useful to try with an npc commit prior to that change.

I'll look into sending that patch on the Git mailing list later today.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'm not managing to reproduce the problem with git v2.49.0 either. Specifically, I've just run the following and didn't see any issues:

( set -euo pipefail; git () { /nix/store/lchj5sfm6yyhv5jhahh5xr2fg239218r-git-2.49.0/bin/git "$@"; }; d="$(mktemp -d)"; git clone --mirror --filter=tree:0 https://github.com/NixOS/nixpkgs.git "$d"; cd "$d"; for (( n=0; n<20; n++ )); do git fetch --no-show-forced-updates; done )

So I don't think we can conclude anything from my testing other than there's some environmental factor at play :(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for testing! I'll do some more testing on my end later today.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And as a slightly different datapoint: I just rebuilt a couple of my machines using npc from your flake, but with both nixpkgs and nixpkgs-git pinned to a recent nixpkgs-unstable. Twenty runs of npc fetch on two different systems and I didn't see anything untoward.

NIX_BIN = lib.getExe nix;
};

passthru.updateScript = nix-update-script { };

meta = {
description = "Nixpkgs channel history CLI";
homepage = "https://github.com/samestep/npc";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [
samestep
me-and
];
};
})
Loading