nix: data in nix/deps/clojure should be JSON

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-05-14 10:33:02 +02:00
parent d133f57678
commit 6746b7d932
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
5 changed files with 1470 additions and 1717 deletions

View File

@ -3,10 +3,10 @@
let
inherit (lib)
removeSuffix optionalString splitString concatMapStrings
attrByPath attrValues last makeOverridable;
attrByPath attrValues last makeOverridable importJSON;
# load dependencies
deps = import ./deps.nix;
deps = importJSON ./deps.json;
# some .jar files have an `-aot` suffix that doesn't work for .pom files
getPOM = jarUrl: "${removeSuffix "-aot" jarUrl}.pom";
@ -30,7 +30,7 @@ let
sha256 = attrByPath [ "jar" "sha256" ] "" dep;
};
jar-download = optionalString (jar.sha256 != "") (
fetchurl { url = "${url}.${dep.type}"; inherit (jar) sha256; }
fetchurl { url = "${url}.jar"; inherit (jar) sha256; }
);
fileName = last (splitString "/" dep.path);
directory = removeSuffix fileName dep.path;
@ -45,13 +45,13 @@ let
echo "${pom.sha1}" > "${getPOM dep.path}.sha1"
''}
${optionalString (jar-download != "") ''
ln -s "${jar-download}" "${dep.path}.${dep.type}"
ln -s "${jar-download}" "${dep.path}.jar"
''}
${optionalString (jar.sha1 != "") ''
echo "${jar.sha1}" > "${dep.path}.${dep.type}.sha1"
echo "${jar.sha1}" > "${dep.path}.jar.sha1"
''}
'')
(attrValues deps)));
deps));
in makeOverridable stdenv.mkDerivation {
name = "status-react-clojure-deps";

1418
nix/deps/clojure/deps.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,9 +4,9 @@ binaryage/oops/0.7.0/oops-0.7.0.jar
cider/cider-nrepl/0.24.0/cider-nrepl-0.24.0.jar
cider/piggieback/0.4.1/piggieback-0.4.1.jar
cljs-bean/cljs-bean/1.3.0/cljs-bean-1.3.0.jar
cljsjs/react-dom-server/16.13.0-0/react-dom-server-16.13.0-0.jar
cljsjs/react-dom/16.13.0-0/react-dom-16.13.0-0.jar
cljsjs/react/16.13.0-0/react-16.13.0-0.jar
cljsjs/react-dom/16.13.0-0/react-dom-16.13.0-0.jar
cljsjs/react-dom-server/16.13.0-0/react-dom-server-16.13.0-0.jar
clout/clout/2.1.2/clout-2.1.2.jar
com/andrewmcveigh/cljs-time/0.5.2/cljs-time-0.5.2.jar
com/bhauman/cljs-test-display/0.1.1/cljs-test-display-0.1.1.jar
@ -17,40 +17,40 @@ com/cognitect/transit-js/0.8.846/transit-js-0.8.846.jar
com/fasterxml/jackson/core/jackson-core/2.8.7/jackson-core-2.8.7.jar
com/google/code/findbugs/jsr305/3.0.1/jsr305-3.0.1.jar
com/google/code/gson/gson/2.7/gson-2.7.jar
com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar
com/google/elemental2/elemental2-core/1.0.0-RC1/elemental2-core-1.0.0-RC1.jar
com/google/errorprone/error_prone_annotations/2.3.1/error_prone_annotations-2.3.1.jar
com/google/guava/guava/25.1-jre/guava-25.1-jre.jar
com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar
com/google/javascript/closure-compiler-externs/v20191027/closure-compiler-externs-v20191027.jar
com/google/javascript/closure-compiler-unshaded/v20191027/closure-compiler-unshaded-v20191027.jar
com/google/javascript/closure-compiler-externs/v20200504/closure-compiler-externs-v20200504.jar
com/google/javascript/closure-compiler-unshaded/v20200504/closure-compiler-unshaded-v20200504.jar
com/google/jsinterop/base/1.0.0/base-1.0.0.jar
com/google/jsinterop/jsinterop-annotations/1.0.2/jsinterop-annotations-1.0.2.jar
com/google/protobuf/protobuf-java/3.0.2/protobuf-java-3.0.2.jar
com/google/protobuf/protobuf-java/3.11.1/protobuf-java-3.11.1.jar
com/google/re2j/re2j/1.3/re2j-1.3.jar
com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar
commons-codec/commons-codec/1.10/commons-codec-1.10.jar
commons-fileupload/commons-fileupload/1.4/commons-fileupload-1.4.jar
commons-io/commons-io/2.6/commons-io-2.6.jar
compojure/compojure/1.5.2/compojure-1.5.2.jar
com/taoensso/encore/2.105.0/encore-2.105.0.jar
com/taoensso/timbre/4.10.0/timbre-4.10.0.jar
com/taoensso/truss/1.5.0/truss-1.5.0.jar
com/taoensso/tufte/2.1.0/tufte-2.1.0.jar
com/wsscode/pathom/2.2.31/pathom-2.2.31.jar
com/wsscode/spec-inspec/1.0.0-alpha2/spec-inspec-1.0.0-alpha2.jar
commons-codec/commons-codec/1.10/commons-codec-1.10.jar
commons-fileupload/commons-fileupload/1.4/commons-fileupload-1.4.jar
commons-io/commons-io/2.6/commons-io-2.6.jar
compojure/compojure/1.5.2/compojure-1.5.2.jar
crypto-equality/crypto-equality/1.0.0/crypto-equality-1.0.0.jar
crypto-random/crypto-random/1.2.0/crypto-random-1.2.0.jar
day8/re-frame/test/0.1.5/test-0.1.5.jar
edn-query-language/eql/0.0.9/eql-0.0.9.jar
expound/expound/0.8.4/expound-0.8.4.jar
fipp/fipp/0.6.22/fipp-0.6.22.jar
fipp/fipp/0.6.23/fipp-0.6.23.jar
hawk/hawk/0.2.11/hawk-0.2.11.jar
hiccup/hiccup/1.0.5/hiccup-1.0.5.jar
hickory/hickory/0.7.1/hickory-0.7.1.jar
http-kit/http-kit/2.2.0/http-kit-2.2.0.jar
instaparse/instaparse/1.4.0/instaparse-1.4.0.jar
io/aviso/pretty/0.1.33/pretty-0.1.33.jar
io/undertow/undertow-core/2.0.30.Final/undertow-core-2.0.30.Final.jar
io/undertow/undertow-core/2.1.0.Final/undertow-core-2.1.0.Final.jar
javax/servlet/servlet-api/2.5/servlet-api-2.5.jar
javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar
medley/medley/0.8.2/medley-0.8.2.jar
@ -61,50 +61,49 @@ net/java/dev/jna/jna/3.2.2/jna-3.2.2.jar
nrepl/nrepl/0.7.0/nrepl-0.7.0.jar
org/checkerframework/checker-qual/2.0.0/checker-qual-2.0.0.jar
org/clojure/clojure/1.10.1/clojure-1.10.1.jar
org/clojure/clojurescript/1.10.597/clojurescript-1.10.597.jar
org/clojure/core.async/1.1.587/core.async-1.1.587.jar
org/clojure/clojurescript/1.10.758/clojurescript-1.10.758.jar
org/clojure/core.async/1.2.603/core.async-1.2.603.jar
org/clojure/core.cache/0.8.2/core.cache-0.8.2.jar
org/clojure/core.memoize/0.8.2/core.memoize-0.8.2.jar
org/clojure/core.rrb-vector/0.1.1/core.rrb-vector-0.1.1.jar
org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar
org/clojure/data.json/1.0.0/data.json-1.0.0.jar
org/clojure/data.priority-map/0.0.7/data.priority-map-0.0.7.jar
org/clojure/google-closure-library-third-party/0.0-20191016-6ae1f72f/google-closure-library-third-party-0.0-20191016-6ae1f72f.jar
org/clojure/google-closure-library/0.0-20191016-6ae1f72f/google-closure-library-0.0-20191016-6ae1f72f.jar
org/clojure/google-closure-library-third-party/0.0-20191016-6ae1f72f/google-closure-library-third-party-0.0-20191016-6ae1f72f.jar
org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar
org/clojure/test.check/1.0.0/test.check-1.0.0.jar
org/clojure/tools.analyzer.jvm/1.0.0/tools.analyzer.jvm-1.0.0.jar
org/clojure/tools.analyzer/1.0.0/tools.analyzer-1.0.0.jar
org/clojure/tools.analyzer.jvm/1.0.0/tools.analyzer.jvm-1.0.0.jar
org/clojure/tools.cli/1.0.194/tools.cli-1.0.194.jar
org/clojure/tools.logging/0.4.1/tools.logging-0.4.1.jar
org/clojure/tools.macro/0.1.5/tools.macro-0.1.5.jar
org/clojure/tools.reader/1.3.2/tools.reader-1.3.2.jar
org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.jar
org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar
org/jboss/logging/jboss-logging/3.4.0.Final/jboss-logging-3.4.0.Final.jar
org/jboss/logging/jboss-logging/3.4.1.Final/jboss-logging-3.4.1.Final.jar
org/jboss/threads/jboss-threads/3.1.0.Final/jboss-threads-3.1.0.Final.jar
org/jboss/xnio/xnio-api/3.8.0.Final/xnio-api-3.8.0.Final.jar
org/jboss/xnio/xnio-nio/3.8.0.Final/xnio-nio-3.8.0.Final.jar
org/jsoup/jsoup/1.9.2/jsoup-1.9.2.jar
org/mozilla/rhino/1.7R5/rhino-1.7R5.jar
org/msgpack/msgpack/0.6.12/msgpack-0.6.12.jar
org/ow2/asm/asm/5.2/asm-5.2.jar
org/wildfly/client/wildfly-client-config/1.0.1.Final/wildfly-client-config-1.0.1.Final.jar
org/wildfly/common/wildfly-common/1.5.2.Final/wildfly-common-1.5.2.Final.jar
quoin/quoin/0.1.2/quoin-0.1.2.jar
reagent/reagent/0.10.0/reagent-0.10.0.jar
re-com/re-com/2.8.0/re-com-2.8.0.jar
refactor-nrepl/refactor-nrepl/2.5.0/refactor-nrepl-2.5.0.jar
re-frame/re-frame/0.12.0/re-frame-0.12.0.jar
re-frisk-remote/re-frisk-remote/1.3.1/re-frisk-remote-1.3.1.jar
re-frisk/sente/1.15.0/sente-1.15.0.jar
reagent/reagent/0.10.0/reagent-0.10.0.jar
refactor-nrepl/refactor-nrepl/2.5.0/refactor-nrepl-2.5.0.jar
ring-cors/ring-cors/0.1.8/ring-cors-0.1.8.jar
ring/ring-codec/1.1.2/ring-codec-1.1.2.jar
ring/ring-core/1.8.0/ring-core-1.8.0.jar
ring/ring-core/1.8.1/ring-core-1.8.1.jar
spec-coerce/spec-coerce/1.0.0-alpha6/spec-coerce-1.0.0-alpha6.jar
status-im/timbre/4.10.0-2-status/timbre-4.10.0-2-status.jar
thheller/shadow-client/1.3.2/shadow-client-1.3.2.jar
thheller/shadow-cljs/2.8.99/shadow-cljs-2.8.99-aot.jar
thheller/shadow-cljs/2.9.2/shadow-cljs-2.9.2-aot.jar
thheller/shadow-cljsjs/0.0.21/shadow-cljsjs-0.0.21.jar
thheller/shadow-util/0.7.0/shadow-util-0.7.0.jar
viebel/codox-klipse-theme/0.0.1/codox-klipse-theme-0.0.1.jar

File diff suppressed because it is too large Load Diff

View File

@ -11,9 +11,14 @@ if [[ -z "${IN_NIX_SHELL}" ]]; then
fi
CLASSPATH_FILE="${GIT_ROOT}/nix/deps/clojure/deps.list"
NIX_DEPS_FILE="${GIT_ROOT}/nix/deps/clojure/deps.nix"
JSON_DEPS_FILE="${GIT_ROOT}/nix/deps/clojure/deps.json"
MAVEN_CACHE_PATH="${HOME}/.m2/repository"
declare -A REPOS=(
[central]="https://repo1.maven.org/maven2"
[clojars]="https://repo.clojars.org"
)
function gen_deps_list() {
# split into separate lines
CLASSPATH_LINES=$(yarn shadow-cljs classpath | tr ':' '\n')
@ -42,16 +47,6 @@ function get_nix_sha() {
nix hash-file --base32 --type sha256 "$1" 2> /dev/null
}
function get_deps_header() {
echo "# Auto-generated by /nix/deps/clojure/generate.sh
let
repos = rec {
central = \"https://repo1.maven.org/maven2\";
clojars = \"https://repo.clojars.org\";
};
in {"
}
function nix_entry_from_jar() {
JAR_REL_PATH="${1}"
JAR_REL_NAME="${JAR_REL_PATH%.jar}"
@ -62,6 +57,7 @@ function nix_entry_from_jar() {
POM_PATH=$(echo ${JAR_DIR}/*.pom)
REPO_NAME=$(get_repo_for_dir "${JAR_DIR}")
REPO_URL=${REPOS[${REPO_NAME}]}
JAR_SHA1=$(cat "${JAR_PATH}.sha1")
JAR_SHA256=$(get_nix_sha "${JAR_PATH}")
@ -71,21 +67,18 @@ function nix_entry_from_jar() {
# Format into a Nix attrset entry
echo -n "
\"${JAR_REL_NAME}\" =
{
host = repos.${REPO_NAME};
path = \"${JAR_REL_NAME}\";
type = \"jar\";
pom = {
sha1 = \"${POM_SHA1}\";
sha256 = \"${POM_SHA256}\";
};
jar = {
sha1 = \"${JAR_SHA1}\";
sha256 = \"${JAR_SHA256}\";
};
};
"
\"path\": \"${JAR_REL_NAME}\",
\"host\": \"${REPO_URL}\",
\"pom\": {
\"sha1\": \"${POM_SHA1}\",
\"sha256\": \"${POM_SHA256}\"
},
\"jar\": {
\"sha1\": \"${JAR_SHA1}\",
\"sha256\": \"${JAR_SHA256}\"
}
}"
}
# generate the deps.list file with relative paths
@ -93,14 +86,17 @@ gen_deps_list > "${CLASSPATH_FILE}"
echo "Saved Clojure deps list to: ${CLASSPATH_FILE}" >&2
# add the header which defines repo URLs
get_deps_header > "${NIX_DEPS_FILE}"
echo -en "[" > "${JSON_DEPS_FILE}"
# for each dependency generate an attrset with metadata
DEPS=$(cat "${CLASSPATH_FILE}")
LAST=$(tail -n1 "${CLASSPATH_FILE}")
for DEP in ${DEPS}; do
nix_entry_from_jar "${DEP}" >> "${NIX_DEPS_FILE}"
nix_entry_from_jar "${DEP}" >> "${JSON_DEPS_FILE}"
# JSON is stupid and requires no comma on last element
[[ "${DEP}" != "${LAST}" ]] && echo "," >> "${JSON_DEPS_FILE}"
done
# close the attrset
echo -e "\n}" >> "${NIX_DEPS_FILE}"
echo "Generated Clojure deps for Nix: ${NIX_DEPS_FILE}" >&2
echo -e "\n]" >> "${JSON_DEPS_FILE}"
echo "Generated Clojure deps for Nix: ${JSON_DEPS_FILE}" >&2