# Flake auth versus derivation flexibility

**URL:** https://discourse.nixos.org/t/flake-auth-versus-derivation-flexibility/23392
**Category:** Nix
**Created:** [November 21, 2022, 11:28pm UTC](https://discourse.nixos.org/t/flake-auth-versus-derivation-flexibility/23392 "2022-11-21T23:28:31Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![urandom](https://discourse.nixos.org/user_avatar/discourse.nixos.org/urandom/32/6839_2.png) [@urandom](https://discourse.nixos.org/u/urandom)
#### Post date: [November 21, 2022, 11:28pm UTC](https://discourse.nixos.org/t/flake-auth-versus-derivation-flexibility/23392/1 "2022-11-21T23:28:32Z")

</div>

when packaging some private repo go stuff recently it became apparent that the primary open source [recte unauthenticated] use cases make for really painful private repo ux. I will also note that this likely scales well to other languages, but I will speak to go, as I know it best.

if I am developing a go module, the language lists all of the upstream dependencies with cryptographic hashes, as required by the toolchain. as such, it is trivial to write either a fod that fetches all of them via script (what `pkgs.buildGoModule` does), an ifd that consumes the lock file (like `pkgs.mkYarnPackage`), or non-ifd magic that does the same (like [naersk](https://github.com/nix-community/naersk)).

unfortunately, none of these play well with private repos. currently I have mirrored the behaviour that pkgs.fetchGitHub uses with its private flag, but this is beyond brittle on darwin, since those environment variables cannot persist across reboot.

on the flip side, flakes solve auth with a new [`access-tokens`](https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-access-tokens) config parameter. this works great, and fetching github type flakes is simple. however, this only works for configured inputs, and because inputs is not full nix, we cannot say “I want inputs of all the repos listed in go.sum”. furthermore, this auth information is accessible within derivations, so we cannot “pass it down” to functions like `pkgs.fetchGitHub` or `pkgs.buildGoModule`.

I get that a lot of this is probably legacy, and an ask of flake maintainers may be to put all your dependencies as explicit flake inputs, but that quickly fails to scale: e.g. [kubernetes](https://github.com/kubernetes/kubernetes/blob/57eb5d631ccd615cd161b6da36afc759af004b93/go.sum) would need 1300 inputs. is this a known issue? are there any suggested workarounds?

---

<div class="post-metadata">

### Author: ![anthr76](https://discourse.nixos.org/user_avatar/discourse.nixos.org/anthr76/32/6320_2.png) [@anthr76](https://discourse.nixos.org/u/anthr76)
#### Post date: [February 10, 2024, 2:49am UTC](https://discourse.nixos.org/t/flake-auth-versus-derivation-flexibility/23392/2 "2024-02-10T02:49:32Z")

</div>

I’m also very much facing this @urandom have you ever found a decent solution to this problem?
