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

Make fetch* source derivation names (optionally) more descriptive and homogenize them across fetchers #49862

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from

Commits on Jun 5, 2024

  1. lib, treewide: introduce repoRevToName, use it in most fetch* fun…

    …ctions
    
    This patch adds `lib.repoRevToName` function that generalizes away most of the
    code used for derivation name generation by `fetch*` functions (`fetchzip`,
    `fetchFromGitHub`, etc, except those which are delayed until latter commits
    for mass-rebuild reasons).
    
    It's first argument controls how the resulting name will look (see below).
    
    Since `lib` has no equivalent of Nixpkgs' `config`, this patch adds
    `config.nameSourcesPrettily` option to Nixpkgs and then re-exposes
    `lib.repoRevToName config.nameSourcesPrettily` expression as
    `pkgs.repoRevToNameMaybe` which is then used in `fetch*` derivations.
    
    The result is that different values of `config.nameSourcesPrettily` now
    control how the `src` derivations produced by `fetch*` functions are to be
    named, e.g.:
    
    - `nameSourcesPrettily = false` (the default):
    
      ```
      $ nix-instantiate -A fuse.src
      /nix/store/<hash>-source.drv
      ```
    
    - `nameSourcesPrettily = true`:
    
      ```
      $ nix-instantiate -A fuse.src
      /nix/store/<hash>-libfuse-2.9.9-source.drv
      ```
    
    - `nameSourcesPrettily = "full"`:
    
      ```
      $ nix-instantiate -A fuse.src
      /nix/store/<hash>-libfuse-2.9.9-github-source.drv
      ```
    
    See documentation of `config.nameSourcesPrettily` for more info.
    oxij committed Jun 5, 2024
    Configuration menu
    Copy the full SHA
    b11baf4 View commit details
    Browse the repository at this point in the history
  2. fetchsvn: move the name generator outside of the thunk

    This is slightly more efficient.
    oxij committed Jun 5, 2024
    Configuration menu
    Copy the full SHA
    a09a1e7 View commit details
    Browse the repository at this point in the history
  3. lib, treewide: use repoRevToName in fetchgit and fetchhg, homog…

    …enize `name`s in `fetchsvn`
    
    In effect, this homogenizes derivation names produced by all `fetch*` functions
    so that switching from e.g. `fetchFromGitHub` to `fetchgit` would be a noop
    (assuming the content hash does not change, which is not always the case for
    `fetchFromGitHub` since GitHub uses `git archive` internally and `fetchgit`
    does not) with both the default `config.nameSourcesPrettily` setting and with
    `config.nameSourcesPrettily = true`.
    oxij committed Jun 5, 2024
    Configuration menu
    Copy the full SHA
    8749da1 View commit details
    Browse the repository at this point in the history