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

adding lix fails with "default" behaviour #96

Open
crop2000 opened this issue Jul 26, 2024 · 10 comments
Open

adding lix fails with "default" behaviour #96

crop2000 opened this issue Jul 26, 2024 · 10 comments

Comments

@crop2000
Copy link
Contributor

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
Copy link
Contributor Author

crop2000 commented Jul 26, 2024

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

@andir
Copy link
Owner

andir commented Jul 27, 2024

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@colons
Copy link

colons commented Oct 20, 2024

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.

@crop2000 crop2000 reopened this Oct 20, 2024
@colons
Copy link

colons commented Oct 20, 2024

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
Copy link
Contributor Author

crop2000 commented Oct 20, 2024

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
Copy link
Contributor Author

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
Copy link

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
Copy link
Owner

andir commented Nov 12, 2024

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 :(

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

No branches or pull requests

4 participants