nix: put clojure deps under pkgs.deps.clojure

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-05-06 12:29:02 +02:00
parent a96b35996f
commit 381b2462a4
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
6 changed files with 71 additions and 13 deletions

View File

@ -0,0 +1,60 @@
{ stdenv, lib, writeShellScriptBin, fetchurl }:
let
inherit (lib)
removeSuffix optionalString splitString concatMapStrings
attrByPath attrValues last makeOverridable;
# load dependencies
deps = import ./deps.nix;
# some .jar files have an `-aot` suffix that doesn't work for .pom files
getPOM = jarUrl: "${removeSuffix "-aot" jarUrl}.pom";
script = writeShellScriptBin "create-local-maven-repo" (''
mkdir -p $out
cd $out
'' +
(concatMapStrings (dep:
let
url = "${dep.host}/${dep.path}";
pom = {
sha1 = attrByPath [ "pom" "sha1" ] "" dep;
sha256 = attrByPath [ "pom" "sha256" ] "" dep;
};
pom-download = optionalString (pom.sha256 != "") (
fetchurl { url = getPOM url; inherit (pom) sha256; }
);
jar = {
sha1 = attrByPath [ "jar" "sha1" ] "" dep;
sha256 = attrByPath [ "jar" "sha256" ] "" dep;
};
jar-download = optionalString (jar.sha256 != "") (
fetchurl { url = "${url}.${dep.type}"; inherit (jar) sha256; }
);
fileName = last (splitString "/" dep.path);
directory = removeSuffix fileName dep.path;
in
''
mkdir -p ${directory}
${optionalString (pom-download != "") ''
ln -s "${pom-download}" "${getPOM dep.path}"
''}
${optionalString (pom.sha1 != "") ''
echo "${pom.sha1}" > "${getPOM dep.path}.sha1"
''}
${optionalString (jar-download != "") ''
ln -s "${jar-download}" "${dep.path}.${dep.type}"
''}
${optionalString (jar.sha1 != "") ''
echo "${jar.sha1}" > "${dep.path}.${dep.type}.sha1"
''}
'')
(attrValues deps)));
in makeOverridable stdenv.mkDerivation {
name = "status-react-clojure-deps";
phases = [ "buildPhase" ];
buildPhase = "${script}/bin/create-local-maven-repo";
}

View File

@ -1,5 +1,4 @@
# Auto-generated by /nix/deps/clojure/generate.sh # Auto-generated by /nix/deps/clojure/generate.sh
{ }:
let let
repos = rec { repos = rec {

View File

@ -44,8 +44,6 @@ function get_nix_sha() {
function get_deps_header() { function get_deps_header() {
echo "# Auto-generated by /nix/deps/clojure/generate.sh echo "# Auto-generated by /nix/deps/clojure/generate.sh
{ }:
let let
repos = rec { repos = rec {
central = \"https://repo1.maven.org/maven2\"; central = \"https://repo1.maven.org/maven2\";

View File

@ -5,10 +5,8 @@
let let
callPackage = newScope { inherit localMavenRepoBuilder projectNodePackage; }; callPackage = newScope { inherit localMavenRepoBuilder projectNodePackage; };
clojureDeps = import ../../deps/clojure/deps.nix { };
# Import a jsbundle compiled out of clojure codebase # Import a jsbundle compiled out of clojure codebase
jsbundle = callPackage ./jsbundle { inherit clojureDeps; }; jsbundle = callPackage ./jsbundle { };
# Import a patched version of watchman (important for sandboxed builds on macOS) # Import a patched version of watchman (important for sandboxed builds on macOS)
watchmanFactory = callPackage ./watchman.nix { }; watchmanFactory = callPackage ./watchman.nix { };

View File

@ -3,12 +3,10 @@
# #
{ target ? "android", { target ? "android",
stdenv, lib, clojure, nodejs, bash, git, openjdk, stdenv, lib, deps, clojure, nodejs, bash, git, openjdk,
clojureDeps, localMavenRepoBuilder, projectNodePackage }: localMavenRepoBuilder, projectNodePackage }:
let stdenv.mkDerivation {
clojureDepsLocal = localMavenRepoBuilder "clojure-project-deps" clojureDeps;
in stdenv.mkDerivation {
name = "status-react-build-jsbundle-${target}"; name = "status-react-build-jsbundle-${target}";
src = src =
let path = ./../../../..; let path = ./../../../..;
@ -45,7 +43,7 @@ in stdenv.mkDerivation {
substituteInPlace shadow-cljs.edn \ substituteInPlace shadow-cljs.edn \
--replace '${anchor}' \ --replace '${anchor}' \
'${anchor} '${anchor}
:maven {:local-repo "${clojureDepsLocal}"}' :maven {:local-repo "${deps.clojure}"}'
''; '';
configurePhase = '' configurePhase = ''
# Symlink Node.js modules to build directory # Symlink Node.js modules to build directory
@ -58,7 +56,7 @@ in stdenv.mkDerivation {
buildPhase = '' buildPhase = ''
# Assemble CLASSPATH from available clojure dependencies. # Assemble CLASSPATH from available clojure dependencies.
# We append 'src' so it can find the local sources. # We append 'src' so it can find the local sources.
export CLASS_PATH="$(find ${clojureDepsLocal} -iname '*.jar' | tr '\n' ':')src" export CLASS_PATH="$(find ${deps.clojure} -iname '*.jar' | tr '\n' ':')src"
# target must be one of the builds defined in shadow-cljs.edn # target must be one of the builds defined in shadow-cljs.edn
java -cp "$CLASS_PATH" clojure.main -m shadow.cljs.devtools.cli release ${target} java -cp "$CLASS_PATH" clojure.main -m shadow.cljs.devtools.cli release ${target}

View File

@ -20,6 +20,11 @@ in {
inherit (self) config; inherit (self) config;
}); });
# Project dependencies
deps = {
clojure = callPackage ./deps/clojure { };
};
# Android environement # Android environement
androidEnvCustom = callPackage ./mobile/android/sdk { }; androidEnvCustom = callPackage ./mobile/android/sdk { };
androidPkgs = self.androidEnvCustom.licensedPkgs; androidPkgs = self.androidEnvCustom.licensedPkgs;