Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f5364122b590
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d10c3cc5eedf
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Jul 4, 2017

  1. gitRepoToName: make it compatible with old fetchFromGitHub's "${repo}…

    …-${rev}-scr" to avoid mass rebuild
    Volth committed Jul 4, 2017
    Copy the full SHA
    e7521e2 View commit details

Commits on Jul 5, 2017

  1. Copy the full SHA
    ab8dd33 View commit details

Commits on Jul 9, 2017

  1. Merge: more compatibility for git* fetchers

    They're additional commits from #26877.
    Changing names of the fetched stuff was changing very many hashes,
    and I think it's better to avoid that for the moment to reduce work
    needed by nixpkgs users.  The fetchers are expected to be commonly
    used even outside nixpkgs, and the current naming wasn't that bad
    usually.
    vcunat committed Jul 9, 2017
    Copy the full SHA
    d10c3cc View commit details
Showing with 30 additions and 13 deletions.
  1. +14 −2 pkgs/build-support/fetchgit/default.nix
  2. +16 −11 pkgs/build-support/fetchgit/gitrepotoname.nix
16 changes: 14 additions & 2 deletions pkgs/build-support/fetchgit/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
{stdenv, git, cacert, gitRepoToName}:
{stdenv, git, cacert}: let
urlToName = url: rev: let
inherit (stdenv.lib) removeSuffix splitString last;
base = last (splitString ":" (baseNameOf (removeSuffix "/" url)));

matched = builtins.match "(.*).git" base;

short = builtins.substring 0 7 rev;

appendShort = if (builtins.match "[a-f0-9]*" rev) != null
then "-${short}"
else "";
in "${if matched == null then base else builtins.head matched}${appendShort}";
in
{ url, rev ? "HEAD", md5 ? "", sha256 ? "", leaveDotGit ? deepClone
, fetchSubmodules ? true, deepClone ? false
, branchName ? null
, name ? gitRepoToName url rev
, name ? urlToName url rev
, # Shell code executed after the file has been fetched
# successfully. This can do things like check or transform the file.
postFetch ? ""
27 changes: 16 additions & 11 deletions pkgs/build-support/fetchgit/gitrepotoname.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{ lib }:

urlOrRepo: rev: let
inherit (lib) removeSuffix splitString last;
base = last (splitString ":" (baseNameOf (removeSuffix "/" urlOrRepo)));
let
inherit (lib) removeSuffix hasPrefix removePrefix splitString stringToCharacters concatMapStrings last elem;

matched = builtins.match "(.*).git" base;

short = builtins.substring 0 7 rev;

appendShort = if (builtins.match "[a-f0-9]*" rev) != null
then "-${short}"
else "";
in "${if matched == null then base else builtins.head matched}${appendShort}"
allowedChars = stringToCharacters "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-._?=";
sanitizeStoreName = s:
let
s' = concatMapStrings (c: if elem c allowedChars then c else "") (stringToCharacters s);
s'' = if hasPrefix "." s' then "_${removePrefix "." s'}" else s';
in
s'';
in
urlOrRepo: rev:
let
repo' = last (splitString ":" (baseNameOf (removeSuffix ".git" (removeSuffix "/" urlOrRepo))));
rev' = baseNameOf rev;
in
"${sanitizeStoreName repo'}-${sanitizeStoreName rev'}-src"