Skip to content

Commit dbfd13b

Browse files
committed
gitRepo: patch git to work around unsafe directory "feature"
Our hack for gitRepo relied on fetching from the Nix store but git 2.35 doesn't allow accessing git repos with "dubious" ownership. This little patch just short-circuits the check.
1 parent f14ad92 commit dbfd13b

File tree

5 files changed

+32
-28
lines changed

5 files changed

+32
-28
lines changed

flake.lock

Lines changed: 1 addition & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33

44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
6-
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
76

87
androidPkgs.url = "github:tadfisher/android-nixpkgs/stable";
98

109
flake-compat.url = "github:nix-community/flake-compat";
1110
};
1211

13-
outputs = { self, nixpkgs, nixpkgs-unstable, androidPkgs, flake-compat, ... }@inputs: let
12+
outputs = { self, nixpkgs, androidPkgs, flake-compat, ... }@inputs: let
1413
pkgs = import ./pkgs/default.nix { inherit inputs; };
1514
in {
1615
# robotnixSystem evaluates a robotnix configuration

pkgs/gitRepo/default.nix

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
{ lib, inputs, fetchFromGitHub, rsync, git, gnupg, less, openssh, ... }:
1+
{ lib, gitRepo, fetchFromGitHub, fetchpatch2, rsync, git, gnupg, less, openssh, ... }:
22
let
3-
inherit (inputs) nixpkgs-unstable;
4-
5-
unstablePkgs = nixpkgs-unstable.legacyPackages.x86_64-linux;
3+
git-patched = git.overrideAttrs (old: {
4+
patches = old.patches or [ ] ++ [
5+
./ignore_dubious_ownership.patch
6+
];
7+
# Likely won't succeed with the patch and we don't care.
8+
doCheck = false;
9+
doInstallCheck = false;
10+
});
611
in
7-
unstablePkgs.gitRepo.overrideAttrs(oldAttrs: rec {
12+
gitRepo.overrideAttrs(oldAttrs: rec {
813
version = "2.45";
914

1015
src = fetchFromGitHub {
@@ -14,7 +19,7 @@ in
1419
hash = "sha256-f765TcOHL8wdPa9qSmGegofjCXx1tF/K5bRQnYQcYVc=";
1520
};
1621

17-
nativeBuildInputs = (oldAttrs.nativeBuildInputs or []) ++ [ rsync git ];
22+
nativeBuildInputs = (oldAttrs.nativeBuildInputs or []) ++ [ rsync git-patched ];
1823

1924
repo2nixPatches = ./patches;
2025

@@ -65,6 +70,10 @@ in
6570
wrapProgram "$out/bin/repo" \
6671
--set REPO_URL "file://$out/var/repo" \
6772
--set REPO_REV "$(cat ./COMMITED_REPO_REV)" \
68-
--prefix PATH ":" "${ lib.makeBinPath [ git gnupg less openssh ] }"
73+
--prefix PATH ":" "${ lib.makeBinPath [ git-patched gnupg less openssh ] }"
6974
'';
75+
76+
passthru = {
77+
inherit git-patched;
78+
};
7079
})
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
diff --git a/setup.c b/setup.c
2+
--- a/setup.c
3+
+++ b/setup.c
4+
@@ -1332,6 +1332,7 @@
5+
void die_upon_dubious_ownership(const char *gitfile, const char *worktree,
6+
const char *gitdir)
7+
{
8+
+ return; // Stubbed
9+
struct strbuf report = STRBUF_INIT, quoted = STRBUF_INIT;
10+
const char *path;
11+

pkgs/overlay.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ self: super: {
3434
});
3535
nix-prefetch-git = super.callPackage ./fetchgit/nix-prefetch-git.nix {};
3636

37-
gitRepo = super.callPackage ./gitRepo { inherit inputs; };
37+
gitRepo = super.callPackage ./gitRepo {
38+
inherit (super) gitRepo;
39+
};
3840

3941
###
4042

0 commit comments

Comments
 (0)