feat(.envrc): only gcroot explicitly specified 3p/sources

Not all dependencies in //third_party/sources are equally important for
evaluation, some are never used (e.g. rustsec-advisory-db is re-fetched
using fetchFromGitHub). It seems to be a good idea to make it
configurable what to gcroot and thus unconditionally download as soon
as .envrc is loaded for the first time.

This frees //third_party/sources to be used more extensively, e.g. for
managing third_party dependencies that aren't used at eval time.

This commit is very conservative and only gcroots:

- nixpkgs, nixpgs-stable (obviously)
- rust-overlay (applied to our nixpkgs instance unconditionally)
- home-manager (used in //third_party/overlays/tvl)

I'm open to re-enabling gcrooting of the following other sources which
are only necessary to evaluate some targets:

- agenix (obvious candidate, widely used in depot)
- naersk (used for many targets)
- napalm (used in //users/Profpatsch and //users/sterni)
- impermanence (only used in //users/tazjin)

Change-Id: I39eef14d08bec6857499655e30ecf47d5fdd1260
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12965
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
sterni 2025-01-09 16:36:30 +01:00
parent 3e802d3bdf
commit 767d6fdf78
2 changed files with 11 additions and 2 deletions

6
.envrc
View file

@ -1,12 +1,16 @@
# Create a gcroot that keeps all third_party.sources alive # Create a gcroot that keeps all third_party.sources alive
nix-build --out-link .gcroots/sources -E ' nix-build --show-trace --out-link .gcroots/sources -E '
with import ./. {}; with import ./. {};
third_party.nixpkgs.writeText "depot-3p-sources.txt" ( third_party.nixpkgs.writeText "depot-3p-sources.txt" (
toString ( toString (
builtins.map (s: s.outPath or null) ( builtins.map (s: s.outPath or null) (
# Only gcroot sources that are explicitly marked using
# niv modify --attribute gcroot=true <source>
builtins.filter (source: source.gcroot or false) (
builtins.attrValues third_party.sources builtins.attrValues third_party.sources
) )
) )
)
)' )'
# Configure the local PATH to contain tools which are fetched ad-hoc # Configure the local PATH to contain tools which are fetched ad-hoc

View file

@ -14,6 +14,7 @@
"gitignore.nix": { "gitignore.nix": {
"branch": "master", "branch": "master",
"description": "Nix functions for filtering local git sources", "description": "Nix functions for filtering local git sources",
"gcroot": true,
"homepage": "", "homepage": "",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "gitignore.nix", "repo": "gitignore.nix",
@ -26,6 +27,7 @@
"home-manager": { "home-manager": {
"branch": "master", "branch": "master",
"description": "Manage a user environment using Nix [maintainer=@rycee] ", "description": "Manage a user environment using Nix [maintainer=@rycee] ",
"gcroot": true,
"homepage": "https://nix-community.github.io/home-manager/", "homepage": "https://nix-community.github.io/home-manager/",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
@ -74,6 +76,7 @@
"nixpkgs": { "nixpkgs": {
"branch": "nixos-unstable", "branch": "nixos-unstable",
"description": "Nix Packages collection", "description": "Nix Packages collection",
"gcroot": true,
"homepage": "", "homepage": "",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
@ -86,6 +89,7 @@
"nixpkgs-stable": { "nixpkgs-stable": {
"branch": "nixos-23.11", "branch": "nixos-23.11",
"description": "Nix Packages collection", "description": "Nix Packages collection",
"gcroot": true,
"homepage": "", "homepage": "",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
@ -98,6 +102,7 @@
"rust-overlay": { "rust-overlay": {
"branch": "master", "branch": "master",
"description": "Pure and reproducible nix overlay of binary distributed rust toolchains", "description": "Pure and reproducible nix overlay of binary distributed rust toolchains",
"gcroot": true,
"homepage": "", "homepage": "",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",