This repository has been archived by the owner on Feb 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrepo2nix.nix
67 lines (53 loc) · 1.73 KB
/
repo2nix.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{
pkgs ? import <nixpkgs> {},
device, rev, manifest, sha256
# Optional parameters:
, repoRepoURL ? "https://github.com/ajs124/tools_repo"
, repoRepoRev ? "master"
, referenceDir ? ""
, extraFlags ? "--no-repo-verify"
, localManifests ? []
}:
assert repoRepoRev != "" -> repoRepoURL != "";
# stdenvNoCC, gitRepo, cacert, copyPathsToStore
with pkgs;
with stdenvNoCC.lib;
let
extraRepoInitFlags = [
(optionalString (repoRepoURL != "") "--repo-url=${repoRepoURL}")
(optionalString (repoRepoRev != "") "--repo-branch=${repoRepoRev}")
(optionalString (referenceDir != "") "--reference=${referenceDir}")
(optionalString (extraFlags != "") "${extraFlags}")
];
repoInitFlags = [
"--manifest-url=${manifest}"
"--manifest-branch=${rev}"
"--depth=1"
] ++ extraRepoInitFlags;
local_manifests = copyPathsToStore localManifests;
in stdenvNoCC.mkDerivation {
name = "repo2nix-${rev}-${device}";
outputHashAlgo = "sha256";
outputHash = sha256;
preferLocalBuild = true;
enableParallelBuilding = true;
impureEnvVars = fetchers.proxyImpureEnvVars ++ [
"GIT_PROXY_COMMAND" "SOCKS_SERVER"
];
nativeBuildInputs = [ gitRepo cacert ];
GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
buildCommand = ''
# Path must be absolute (e.g. for GnuPG: ~/.repoconfig/gnupg/pubring.kbx)
export HOME="$(pwd)"
mkdir .repo
${optionalString (local_manifests != []) ''
mkdir .repo/local_manifests
for local_manifest in ${concatMapStringsSep " " toString local_manifests}; do
cp $local_manifest .repo/local_manifests/$(stripHash $local_manifest; echo $strippedName)
done
''}
repo init ${concatStringsSep " " repoInitFlags}
repo nix > "$out"
rm -rf .repo*
'';
}