Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

Commit

Permalink
WIP: because that upstream fetchrepoproject is just not cool enough f…
Browse files Browse the repository at this point in the history
…or use

needs nix with NixOS/nix#2582 merged
  • Loading branch information
ajs124 committed Feb 26, 2019
1 parent 871de59 commit c377539
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 3 deletions.
16 changes: 13 additions & 3 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,36 @@
rev ? "${rom}-16.0",
opengappsVariant ? null,
enableWireguard ? false,
manifest ? "https://github.com/LineageOS/android.git -g all,-darwin,-infra",
manifest ? "https://github.com/LineageOS/android.git",
extraFlags ? "-g all,-darwin,-infra --no-repo-verify",
sha256 ? "0iqjqi2vwi6lfrk0034fdb1v8927g0vak2qanljw6hvcad0fid6r",
savePartitionImages ? false
}:

with pkgs;
with pkgs; with lib;
let
nixdroid-env = callPackage ./buildenv.nix {};
fetchRepoProject = callPackage ./fetchRepoProject.nix {};
in stdenv.mkDerivation rec {
name = "nixdroid-${rev}-${device}";
src = fetchRepoProject {
inherit manifest sha256 rev;
inherit manifest sha256 rev extraFlags;
name = "${name}-src";
localManifests = lib.flatten [
(./roomservice- + "${device}.xml")
(lib.optional (opengappsVariant != null) [ ./opengapps.xml ])
(lib.optional enableWireguard [ ./wireguard.xml ])
];
repoRepoURL = "https://github.com/ajs124/tools_repo";
repoRepoRev = "master";
};

unpackPhase = ''
echo ${concatStringsSep "\n" (mapAttrsToList (n: v: v.outPath + " " + n) (import ./srcs.nix))} | while read s; do
cp -a $s
done
'';

prePatch = ''
# Find device tree
boardConfig="$(ls "device/"*"/${device}/BoardConfig.mk")"
Expand Down
69 changes: 69 additions & 0 deletions fetchRepoProject.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{ stdenvNoCC, gitRepo, cacert, copyPathsToStore }:

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

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

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 {
inherit name;

inherit cacert manifest rev repoRepoURL repoRepoRev referenceDir; # TODO

outputHashAlgo = "sha256";
outputHashMode = "recursive";
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 $out
cd $out
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 > srcs.nix
rm -rf .repo*
'';
}

0 comments on commit c377539

Please sign in to comment.