nix-update icon indicating copy to clipboard operation
nix-update copied to clipboard

git diff call fails, ".../default.nix" is outside repository at "/repo/path"

Open colemickens opened this issue 1 year ago • 4 comments

nix-update \
--flake \
packages.x86_64-linux.foot \
--version \
branch=master \
--commit \
--override-filename \
./pkgs/foot/metadata.nix

results in:

[the nix expr that nix-update evals + prints is omitted, except the last line of the output here:]
$ git diff --color=never --word-diff=porcelain -- /nix/store/hhwdvcdgz7qz2prms49lr1h82v5qagxp-source/pkgs/foot/default.nix
fatal: /nix/store/hhwdvcdgz7qz2prms49lr1h82v5qagxp-source/pkgs/foot/default.nix: '/nix/store/hhwdvcdgz7qz2prms49lr1h82v5qagxp-source/pkgs/foot/default.nix' is outside repository at '/home/cole/code/nixpkgs-wayland
[traceback omitted]

(note this is not with master of nixpkgs-wayland, but a branch where I'm experimenting with nix-update instead of my old bespoke update script)

Not quite sure what's going on here? I'm passing a relative path for the file for it to try and update, I'm not doing anything to make an out of repo reference, as far as I can tell.

colemickens avatar Sep 19 '24 21:09 colemickens

So, very interestingly, if I manually revert foot to an old rev and run it, it works! But it fails on the second run.

First run produces commit:

commit b02274d75440280a62b851289f87e5e7d0c9b7d7
Author: Cole Mickens <[email protected]>
Date:   Thu Sep 19 14:43:11 2024 -0700

    packages.x86_64-linux.foot: 1.18.1-unstable-2024-09-13 -> 1.18.1-unstable-2024-09-15

    Diff: https://codeberg.org/dnkl/foot/compare/33f3818520bd5f7a063f64442c54d41625332aeb...297cb370aa3f9e9a9093415217be410fae6fccfa

    Changelog: https://codeberg.org/dnkl/foot/releases/tag/1.18.1-unstable-2024-09-15

diff --git a/pkgs/foot/metadata.nix b/pkgs/foot/metadata.nix
index e6e366da..affc7618 100644
--- a/pkgs/foot/metadata.nix
+++ b/pkgs/foot/metadata.nix
@@ -5,7 +5,7 @@ rec {
   repo = "foot";
   repo_git = "https://${domain}/${owner}/${repo}";
   branch = "master";
-  version = "1.18.1-unstable-2024-09-13";
-  rev = "33f3818520bd5f7a063f64442c54d41625332aeb";
-  sha256 = "sha256-iNj14FO5Lr1UU/h0MdOgWor7xo/lJz1CunYbI9yg8Ls=";
+  version = "1.18.1-unstable-2024-09-15";
+  rev = "297cb370aa3f9e9a9093415217be410fae6fccfa";
+  sha256 = "sha256-H/YdqM2pQfyoUWIEou0Xm0P5LxDoO4N5eb5Ymvtplls=";
 }

Which looks pretty much exactly right.

But, a subsequent run (that I'd expect to be an idempotent/no-op) produces the error shown above.

colemickens avatar Sep 19 '24 21:09 colemickens

Note, also, I find it odd that it is diffing default.nix even when I override the file? But also it works the first try somehow so?

colemickens avatar Sep 19 '24 21:09 colemickens

In the successful case:

Update 1.18.1-unstable-2024-09-13 -> 1.18.1-unstable-2024-09-15 in ./pkgs/foot/metadata.nix
$ nix-build --expr let src = (let flake = builtins.getFlake "/home/cole/code/nixpkgs-wayland"; in flake.packages.${builtins.currentSystem}."packages"."x86_64-linux"."foot" or flake."packages"."x86_64-linux"."foot").src; in (src.overrideAttrs or (f: src // f src)) (_: { outputHash = ""; outputHashAlgo = "sha256"; }) --extra-experimental-features flakes nix-command
Package maintainers:
  - Lukas Epple (@sternenseemann)
$ git -C /home/cole/code/nixpkgs-wayland diff -- ./pkgs/foot/metadata.nix

ref: https://github.com/Mic92/nix-update/blob/7dd0e4467c571ebb7e53d9e3d40c49f75473efdf/nix_update/update.py#L394-L396

colemickens avatar Sep 19 '24 21:09 colemickens

Note, also, I find it odd that it is diffing default.nix even when I override the file? But also it works the first try somehow so?

The override file flag was added later and may not be taken into account by the diff command.

Mic92 avatar Sep 20 '24 07:09 Mic92