andir / npins

Nix dependency pinning. Very similar to Niv but has a few features that I personally wanted.
European Union Public License 1.2
231 stars 18 forks source link

adding lix fails with "default" behaviour #96

Open crop2000 opened 4 months ago

crop2000 commented 4 months ago
npins add git https://git.lix.systems/lix-project/lix

adds

    "lix": {
      "type": "GitRelease",
      "repository": {
        "type": "Git",
        "url": "https://git.lix.systems/lix-project/lix"
      },
      "pre_releases": false,
      "version_upper_bound": null,
      "release_prefix": null,
      "version": "2.90.0",
      "revision": "2a4376be20d70feaa2b0e640c5041fb66ddc67ed",
      "url": null,
      "hash": "1iyylsiv1n6mf6rbi4k4fm5nv24a940cwfz92gk9fx6axh2kxjbz"
    },

but

nix-instantiate --eval npins -A lix.outPath

produces the following error:


fetching git input 'git+https://git.lix.systems/lix-project/lix'
error:
       … while calling the 'fetchGit' builtin
         at /home/olaf/dotfiles/npins/default.nix:26:43:
           25|       })
           26|     else assert repository.type == "Git"; builtins.fetchGit {
             |                                           ^
           27|       url = repository.url;

       … while fetching the input 'git+https://git.lix.systems/lix-project/lix?rev=2a4376be20d70feaa2b0e640c5041fb66ddc67ed'

       error: Cannot find Git revision '2a4376be20d70feaa2b0e640c5041fb66ddc67ed' in ref 'refs/heads/main' of repository 'https://git.lix.systems/lix-project/lix'! Please make sure that the rev exists on the ref you've specified or add allRefs = true; to fetchGit.

the problem is that nix expect main as branch but the release is on release-2.90 branch. i wonder if this is a inherent problem of buildins.fetchGit or if it can be somehow mitigated. with information we have in npins (but do not store yet).

crop2000 commented 4 months ago

~~this is happening because too old nix (nix_2_3 2.3.18) is used in shell.nix see #97~~

andir commented 4 months ago

this is happening because too old nix (nix_2_3 2.3.18) is used in shell.nix see #97

can you define "too old"?

crop2000 commented 4 months ago

today i cannot reproduce the problem. i don't know anymore which nix-version and exact npins project revision I used. but the problem description appeared before as well on the lix matrix channel.

crop2000 commented 2 months ago

Because i didn't came across the problem again i close this issue.

colons commented 1 month ago

this recently begun happening to me with both lix and lix's nixos-module. with npins 0.2.4, npins update from the previously working version leaves me with sources.json as follows:

{
  "pins": {
    ...
    "lix": {
      "type": "GitRelease",
      "repository": {
        "type": "Git",
        "url": "https://git.lix.systems/lix-project/lix"
      },
      "pre_releases": false,
      "version_upper_bound": null,
      "release_prefix": null,
      "version": "2.91.1",
      "revision": "ad9d06f7838a25beec425ff406fe68721fef73be",
      "url": null,
      "hash": "0ibpbvc6871bqyab0msml2g2y3c6jvg6yb169lykg4257izss8c6"
    },
    "lix-nixos-module": {
      "type": "GitRelease",
      "repository": {
        "type": "Git",
        "url": "https://git.lix.systems/lix-project/nixos-module"
      },
      "pre_releases": false,
      "version_upper_bound": null,
      "release_prefix": null,
      "version": "2.91.1",
      "revision": "6478f624b2a00367e0e3d750a2c7a9f3afb72712",
      "url": null,
      "hash": "1mq5741iwa10r93shg1y8q6cxa2zjppc2w10hsrv1gfac76p8nmj"
    },
    ...
  },
  "version": 3
}

which then gives the following error when i rebuild:

fetching git input 'git+https://git.lix.systems/lix-project/nixos-module'
error:
       … while evaluating the attribute 'config.system.build.toplevel'
         at /nix/store/cariq6xs0m5yzjkxd85wqqj7bgh4a3af-source/lib/modules.nix:322:9:
          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          323|         _module = checked (config._module);

       … while evaluating 'eval.config' to select 'system' on it
         at /nix/store/cariq6xs0m5yzjkxd85wqqj7bgh4a3af-source/nixos/default.nix:17:12:
           16|
           17|   system = eval.config.system.build.toplevel;
             |            ^
           18|

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

       error: Cannot find Git revision '6478f624b2a00367e0e3d750a2c7a9f3afb72712' in ref 'refs/heads/main' of repository 'https://git.lix.systems/lix-project/nixos-module'! Please make sure that the rev exists on the ref you've specified or add allRefs = true; to fetchGit.

if i only npins update lix (avoiding updating nixos-module), i instead get:

fetching git input 'git+https://git.lix.systems/lix-project/lix'
error:
       … while calling the 'head' builtin
         at /nix/store/cariq6xs0m5yzjkxd85wqqj7bgh4a3af-source/lib/attrsets.nix:1575:11:
         1574|         || pred here (elemAt values 1) (head values) then
         1575|           head values
             |           ^
         1576|         else

       … while evaluating the attribute 'value'
         at /nix/store/cariq6xs0m5yzjkxd85wqqj7bgh4a3af-source/lib/modules.nix:809:9:
          808|     in warnDeprecation opt //
          809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          810|         inherit (res.defsFinal') highestPrio;

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

       error: Cannot find Git revision 'ad9d06f7838a25beec425ff406fe68721fef73be' in ref 'refs/heads/main' of repository 'https://git.lix.systems/lix-project/lix'! Please make sure that the rev exists on the ref you've specified or add allRefs = true; to fetchGit.
colons commented 1 month ago

im really confused about this. why does branch matter at all when it knows exactly what revision it's after? why has the revision reference been updated to something it'll refuse to check out?

crop2000 commented 1 month ago

the problem seems to be this: "Seems like npins indeed breaks for tags that are not on the default branch." I think it is builtins.fetchGit that has this problem.

crop2000 commented 1 month ago
nix-repl> builtins.fetchGit { url = "https://git.lix.systems/lix-project/lix.git"; rev = "ad9d06f7838a25beec425ff406fe68721fef73be"; }

...

       error: Cannot find Git revision 'ad9d06f7838a25beec425ff406fe68721fef73be' in ref 'refs/heads/main' of repository 'https://git.lix.systems/lix-project/lix.git'! Please make sure that the rev exists on the ref you've specified or add allRefs = true; to fetchGit.

so

nix-repl> builtins.fetchGit { url = "https://git.lix.systems/lix-project/lix.git"; rev = "ad9d06f7838a25beec425ff406fe68721fef73be"; allRefs = true; }
{
  lastModified = 1729298361;
  lastModifiedDate = "20241019003921";
  narHash = "sha256-hiGtfzxFkDc9TSYsb96Whg0vnqBVV7CUxyscZNhed0U=";
  outPath = "/nix/store/59hbcmxmj23mpf04qw28yrks7cdsplkj-source";
  rev = "ad9d06f7838a25beec425ff406fe68721fef73be";
  revCount = 16139;
  shortRev = "ad9d06f";
  submodules = false;
}

so how about using allRefs = true in https://github.com/andir/npins/blob/master/src/default.nix ?

samueldr commented 1 month ago

Note: this situation is a bit spicy as it involves:

With Nix starting somewhen after 2.18, passing allRefs isn't necessary anymore...

... but still there is that problematic issue where Nix 2.18 and Lix (nix (Lix, like Nix) 2.91.0/2.18.3-lix) exhibit that behaviour...

... which is made even more annoying when you see that if you get a Nix 2.24 to fetchGit it successfully, it then lives in the user's evaluation cache for 2.18 to see.

andir commented 2 weeks ago

Perhaps there is apetite in the Lix community to fix this issue once and for all? Perhaps using fetchTree would be a workaround if we require a newer Nix version / use it when available? I don't like the idea of advocating for newer Nix as that usually causes tons of other issues and then people will think the old version is "buggy" while it is just an unfortunate combination of versions and forks :(