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

enable private github installations and netrc usage

Open h0nIg opened this issue 9 months ago • 8 comments

h0nIg avatar Apr 15 '25 10:04 h0nIg

Can we add a dummy test for this easily?

SuperSandro2000 avatar Apr 15 '25 11:04 SuperSandro2000

At least in the github CI we do have github credentials stored in $GITHUB_TOKEN at hand that could be skipped with pytest if those credentials are not at hand: https://docs.pytest.org/en/stable/how-to/skipping.html

Mic92 avatar Apr 16 '25 06:04 Mic92

Those http errors now look suspicious.

Mic92 avatar Apr 16 '25 07:04 Mic92

@SuperSandro2000 please merge when you think this is ready.

Mic92 avatar Apr 17 '25 07:04 Mic92

@SuperSandro2000 @Mic92 i'm done here, works for us with our GHES instance (and as a side effect with private repo's on github.com)

h0nIg avatar Apr 17 '25 12:04 h0nIg

I tested this on a GHES instance and got treated with this:

Traceback (most recent call last):
  File "/nix/store/fri7brzjjl4ykic6g94rh908mpfbx7rx-nix-update-1.11.0/bin/.nix-update-wrapped", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "/nix/store/fri7brzjjl4ykic6g94rh908mpfbx7rx-nix-update-1.11.0/lib/python3.12/site-packages/nix_update/__init__.py", line 368, in main
    package = update(options)
              ^^^^^^^^^^^^^^^
  File "/nix/store/fri7brzjjl4ykic6g94rh908mpfbx7rx-nix-update-1.11.0/lib/python3.12/site-packages/nix_update/update.py", line 589, in update
    update_hash = update_version(
                  ^^^^^^^^^^^^^^^
  File "/nix/store/fri7brzjjl4ykic6g94rh908mpfbx7rx-nix-update-1.11.0/lib/python3.12/site-packages/nix_update/update.py", line 449, in update_version
    new_version = fetch_latest_version(
                  ^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/fri7brzjjl4ykic6g94rh908mpfbx7rx-nix-update-1.11.0/lib/python3.12/site-packages/nix_update/version/__init__.py", line 147, in fetch_latest_version
    raise VersionError(msg)
nix_update.errors.VersionError: Please specify the version. We can only get the latest version from codeberg/crates.io/gitea/github/gitlab/pypi/savannah/sourcehut/rubygems/npm projects right now

The fetcher I am using looks like this:

  src = fetchFromGitHub {
    githubBase = "github.corp";
    owner = "group";
    repo = "project";
    tag = "v${version}";
    private = true;
    forceFetchGit = true;
    preferLocalBuild = true;
    hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
  };

SuperSandro2000 avatar May 05 '25 13:05 SuperSandro2000

I tested this on a GHES instance and got treated with this:

Traceback (most recent call last):
  File "/nix/store/fri7brzjjl4ykic6g94rh908mpfbx7rx-nix-update-1.11.0/bin/.nix-update-wrapped", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "/nix/store/fri7brzjjl4ykic6g94rh908mpfbx7rx-nix-update-1.11.0/lib/python3.12/site-packages/nix_update/__init__.py", line 368, in main
    package = update(options)
              ^^^^^^^^^^^^^^^
  File "/nix/store/fri7brzjjl4ykic6g94rh908mpfbx7rx-nix-update-1.11.0/lib/python3.12/site-packages/nix_update/update.py", line 589, in update
    update_hash = update_version(
                  ^^^^^^^^^^^^^^^
  File "/nix/store/fri7brzjjl4ykic6g94rh908mpfbx7rx-nix-update-1.11.0/lib/python3.12/site-packages/nix_update/update.py", line 449, in update_version
    new_version = fetch_latest_version(
                  ^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/fri7brzjjl4ykic6g94rh908mpfbx7rx-nix-update-1.11.0/lib/python3.12/site-packages/nix_update/version/__init__.py", line 147, in fetch_latest_version
    raise VersionError(msg)
nix_update.errors.VersionError: Please specify the version. We can only get the latest version from codeberg/crates.io/gitea/github/gitlab/pypi/savannah/sourcehut/rubygems/npm projects right now

The fetcher I am using looks like this:

  src = fetchFromGitHub {
    githubBase = "github.corp";
    owner = "group";
    repo = "project";
    tag = "v${version}";
    private = true;
    forceFetchGit = true;
    preferLocalBuild = true;
    hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
  };

because you use forceFetchGit=true, git != github url, only github url's are matched image

h0nIg avatar May 05 '25 19:05 h0nIg

We resolved the above issue in a private chat. I had to remove forceFetchGit and override the cacert in fetchurl -> fetchzip -> fetchFromGitHub with out internal CA and then it works as expected.

Only things I noticed is, that instead of displaying errors we show stack traces when no netrc is available or when it cannot be parsed.

SuperSandro2000 avatar May 07 '25 09:05 SuperSandro2000

ping @Mic92

h0nIg avatar Jun 15 '25 11:06 h0nIg

077f4cfaa48a97d65ab161cc3253218f69f88c29 seems to have broken certain packages. For example in nixpks master nix-update avalonia will attempt to fetch https://github.com/AvaloniaUI/Avalonia.git/releases.atom instead of https://github.com/AvaloniaUI/Avalonia/releases.atom.

corngood avatar Aug 06 '25 15:08 corngood