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

Added fetchRepoProject #24239

Merged
merged 1 commit into from Mar 24, 2017
Merged

Added fetchRepoProject #24239

merged 1 commit into from Mar 24, 2017

Conversation

spacekitteh
Copy link
Contributor

@spacekitteh spacekitteh commented Mar 23, 2017

Created a "fetchGitRepo" to fetch source repositories managed by Google's git-repo

One problem is fetching clone.bundle 's fails due to python's urllib not being able to parse the result given by repo's call to git config --get-regexp url.*.insteadof, but this behaviour doesn't manifest when calling it from a normal shell, even in nixos.

@Mic92
Copy link
Member

Mic92 commented Mar 23, 2017

The name is ambiguous and people could it mixed it up with fetchgit. Maybe fetchGoogleGitRepo or fetchAndroidGitRepo?

done

export HOME=.repo
repo init --manifest-url=${manifest} --manifest-branch=${rev} --depth=1 --no-clone-bundle''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these manifests always points to fixed revisions in other repos?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep (or at least, they're supposed to)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think repo supports floating branch refs too, so that's a risk...

Copy link
Member

@Mic92 Mic92 Mar 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably this could be decided from case to case. But a fair warning would helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should the warning be presented?

stdenv.mkDerivation {
inherit name cacert;
buildCommand = with stdenv.lib; ''
mkdir ./.repo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is wrong here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should it be?

@jb55
Copy link
Contributor

jb55 commented Mar 23, 2017 via email

@spacekitteh
Copy link
Contributor Author

I have renamed it to fetchRepoProject, I think that's a far better name

assert repoRepoRev != "" -> repoRepoURL != "";

stdenv.mkDerivation {
inherit name cacert;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation seems kinda wonky across this file

@copumpkin
Copy link
Member

Looks fine to me apart from the indentation being wonky

@copumpkin
Copy link
Member

copumpkin commented Mar 24, 2017

Oh I see you asked earlier how it should look. This is how I'd do it, based on conventions I've seen elsewhere in nixpkgs:

{stdenv, git, gitRepo, gnupg ? null, cacert}:

{name, manifest, rev ? "HEAD", sha256 ? "", repoRepoURL ? "", repoRepoRev ? "", referenceDir ? "",
localManifests ? [] }:

assert repoRepoRev != "" -> repoRepoURL != "";

stdenv.mkDerivation {
  inherit name cacert;
  buildCommand = with stdenv.lib; ''
    mkdir ./.repo
    mkdir ./.repo/local_manifests
    for local_manifest in ${concatMapStringsSep " " (x: "${x}") localManifests}
    do
      cp $local_manifest ./.repo/local_manifests/$(stripHash $local_manifest; echo $strippedName)
    done

    export HOME=.repo
    repo init --manifest-url=${manifest} --manifest-branch=${rev} --depth=1 --no-clone-bundle
    ${optionalString (repoRepoURL != "") " --repo-url=${repoRepoURL}"}
    ${optionalString (repoRepoRev != "") " --repo-branch=${repoRepoRev}"}
    ${optionalString (referenceDir != "") " --reference=${referenceDir}"}

    repo sync --jobs=$NIX_BUILD_CORES --current-branch
    rm -rf $out/.repo
  '';

  GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";

  impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars ++ [
    "GIT_PROXY_COMMAND" "SOCKS_SERVER"
  ];

  buildInputs = [git gitRepo cacert] ++ stdenv.lib.optional (gnupg != null) [gnupg] ;

  outputHashAlgo = "sha256";
  outputHashMode = "recursive";
  outputHash = sha256;

  preferLocalBuild = true;
  enableParallelBuilding = true;
  inherit manifest rev repoRepoURL repoRepoRev referenceDir;
}

Edit: whoops, I screwed it up a bit by attempting to remove the string appends, but it shouldn't be hard to fix.

@spacekitteh
Copy link
Contributor Author

Alright @copumpkin I reformatted it like that (fixing the optionalString bits of course)

with import <nixpkgs> {};
let fetcher = import ./default.nix {inherit stdenv cacert
git gitRepo gnupg;};
in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same formatting issues here, sorry 😄

name = "foo";
manifest = "https://github.com/CopperheadOS/platform_manifest.git";
rev="nougat-mr1.1-release";
sha256 = "51rhjsqka5v02zw6k0m4fnwz8xrx70ifar4afsndm88i6fbd3vaw"; #fake hash, don't worry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would I worry about the hash? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the hash is just a random hash to test that repo actually does its thing (that manifest branch, without a tag, follows HEAD)... also it fetches about 80GB of sources |-)

I could change it to a smaller project with a fixed rev, though?

@spacekitteh spacekitteh force-pushed the fetchFromGitRepo branch 2 times, most recently from 8e6742b to cef00e7 Compare March 24, 2017 03:26
Added to grab projects added by git-repo.

Contains some problems still reguarding purity and clone.bundle,
but good enough for now.
@copumpkin copumpkin changed the title Added fetchGitRepo Added fetchRepoProject Mar 24, 2017
@copumpkin
Copy link
Member

Looks good to me, thanks!

@copumpkin copumpkin merged commit a9644fb into NixOS:master Mar 24, 2017
@LnL7
Copy link
Member

LnL7 commented Mar 24, 2017

This broken evaluation, fixed in f6669da.

@spacekitteh
Copy link
Contributor Author

@LnL7 that seems to have an optionalString on each (bash script) line?

@spacekitteh
Copy link
Contributor Author

Oh shit, that's because I forgot to add the change before committing. What you have at the moment doesn't work, either, @LnL7 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants