From 5cb0123393938b82344b744b177b6645e21c6503 Mon Sep 17 00:00:00 2001 From: niten Date: Wed, 1 Jun 2022 13:59:31 -0700 Subject: [PATCH] Try reverting to 0.6.8 again --- build.tools.nix | 22 ++++++++++++---------- flake.lock | 8 ++++---- flake.nix | 6 +++--- mkClojureLib.nix | 32 ++++++++++++++++++++------------ src/build.clj | 41 ++++++++++++++++++++--------------------- 5 files changed, 59 insertions(+), 50 deletions(-) diff --git a/build.tools.nix b/build.tools.nix index 770d29d..56f0c9a 100644 --- a/build.tools.nix +++ b/build.tools.nix @@ -71,27 +71,29 @@ in stdenv.mkDerivation { ${concatStringsSep "\n" (map extract-jar dep-jars)} ${concatStringsSep "\n" (map (java-compile tools-classpath) tools-namespaces)} - ${java-compile "" "'build"} + ${java-compile tools-classpath "'build"} jar cmf ${manifest} ./out.jar -C . ${ concatStringsSep " " [ - "build" - "cljs" - "cognitect" - "com" - "javax" - "mozilla" - "plugin.xml" + "META-INF" "about.html" + "build.clj" + "classes" + "cljs" "clojure" + "cognitect" "cognitect_aws_http.edn" + "com" "data_readers.cljc" + "javax" "licenses" + "mozilla" "org" + "plugin.xml" ] } - cat /tmp/*.edn + [ $? -eq 0 ] || /tmp/*.edn ''; - in pthru "${build-script}"; + in "${build-script}"; installPhase = '' cp out.jar $out diff --git a/flake.lock b/flake.lock index 62a3c8f..75b7a06 100644 --- a/flake.lock +++ b/flake.lock @@ -89,16 +89,16 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1645296114, - "narHash": "sha256-y53N7TyIkXsjMpOG7RhvqJFGDacLs9HlyHeSTBioqYU=", + "lastModified": 1654005557, + "narHash": "sha256-J6elwUzPoco+r5qWPHhvS2EHVWomUtNcxzkfdAQOwEU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "530a53dcbc9437363471167a5e4762c5fcfa34a1", + "rev": "08950a6e29cf7bddee466592eb790a417550f7f9", "type": "github" }, "original": { "id": "nixpkgs", - "ref": "nixos-21.05", + "ref": "nixos-22.05", "type": "indirect" } }, diff --git a/flake.nix b/flake.nix index afc3fbd..85af6bd 100644 --- a/flake.nix +++ b/flake.nix @@ -2,11 +2,11 @@ description = "clojure/tools.build packaged for NixOS."; inputs = { - nixpkgs.url = "nixpkgs/nixos-21.05"; + nixpkgs.url = "nixpkgs/nixos-22.05"; utils.url = "github:numtide/flake-utils"; clj2nix.url = "github:hlolli/clj2nix"; build-tools-src = { - url = "github:clojure/tools.build?tag=v0.8.2"; + url = "github:clojure/tools.build?tag=v0.6.8"; flake = false; }; gitignore = { @@ -22,7 +22,7 @@ system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages."${system}"; build-tools-jar = pkgs.callPackage ./build.tools.nix { - version = "0.8.2"; + version = "0.6.8"; inherit build-tools-src; inherit (gitignore.lib) gitignoreSource; }; diff --git a/mkClojureLib.nix b/mkClojureLib.nix index 8b30385..5fd41d9 100644 --- a/mkClojureLib.nix +++ b/mkClojureLib.nix @@ -1,19 +1,21 @@ -{ lib, stdenv, callPackage, clojure, jre, writeTextDir, writeShellScript, toEDN +{ lib, stdenv, callPackage, clojure, jre, writeText, writeShellScript, toEDN }: +{ src, name, group, version, deps-edn, clj-deps, src-paths, build-tools-jar, ... }: -{ src, name, group, version, clj-deps, src-paths, build-tools-jar, ... }: with lib; let - build-tools-deps = writeTextDir "deps.edn" (toEDN { + build-tools-deps = toEDN { aliases.build = { - ns-default = "'build"; extra-deps."'io.github.clojure/tools.build"."local/root" = - "${build-tools-jar}"; + ''\"${build-tools-jar}\"''; }; - }); + }; classpath = clj-deps.makeClasspaths { }; + build-deps = callPackage ./deps.nix { }; + build-classpath = build-deps.makeClasspaths { }; + full-name = "${name}-${version}-standalone.jar"; target = "$TEMP/target"; @@ -24,25 +26,31 @@ let mkdir -p ${target} clojure \ - -Scp .:${build-tools-jar}:${classpath} \ - -Sdeps ${build-tools-deps} \ + -Scp ${build-classpath}:${classpath}:${build-tools-jar}:. \ + -Sdeps "${build-tools-deps}" \ -X:build \ - lib-uberjar \ + build/lib-uberjar \ :project ${group}/${name} \ :version ${version} \ :src-dirs ${concatStringsSep "," src-paths} \ - :target ${target} + :target '"${target}"' \ + :deps-edn '"${deps-edn}"' + + [ $? -eq 0 ] || cat /tmp/*.edn ''; + pthru = o: builtins.trace o o; + in stdenv.mkDerivation { name = full-name; src = src; nativeBuildInputs = [ clojure jre ]; - buildInputs = (map (x: x.paths) clj-deps.packages); + buildInputs = (map (x: x.paths) clj-deps.packages) + ++ (map (x: x.paths) build-deps.packages); - buildPhase = "${build-script}"; + buildPhase = pthru "${build-script}"; installPhase = '' mv ${target}/${name}-${version}-standalone.jar $out diff --git a/src/build.clj b/src/build.clj index cbdc62b..0287035 100644 --- a/src/build.clj +++ b/src/build.clj @@ -1,15 +1,12 @@ (ns build - (:require [clojure.tools.build.api :as b])) + (:require [clojure.tools.build.api :as b] + [clojure.string :as str])) (defn make-class-dir [target] (format "%s/classes" target)) -(def basis (b/create-basis {:project "deps.edn"})) - -(defonce timestamp - (.format (java.time.LocalDateTime/now) - java.time.format.DateTimeFormatter/BASIC_ISO_DATE)) +(defn make-basis [deps] (b/create-basis {:project deps})) (defonce default-target "./target") -(defonce default-srcs ["src"]) +(defonce default-srcs "src") (defn make-jar-filename [target project version] (format "%s/%s-%s.jar" @@ -25,43 +22,45 @@ params) (defn lib-jar - [{:keys [project version target srcs] - :or {version timestamp - target default-target + [{:keys [project version target srcs deps-edn] + :or {target default-target srcs default-srcs} :as params}] (let [project-sym (symbol project) target-jar (make-jar-filename target project version) - class-dir (make-class-dir target)] + class-dir (make-class-dir target) + basis (make-basis deps-edn) + src-dirs (str/split srcs #",")] (clean params) - (b/copy-dir {:src-dirs srcs}) + (b/copy-dir {:src-dirs src-dirs}) (b/compile-clj {:basis basis - :src-dirs srcs + :src-dirs src-dirs :class-dir class-dir}) (b/write-pom {:class-dir class-dir :lib project-sym :version version :basis basis - :src-dirs srcs}) + :src-dirs src-dirs}) (b/jar {:class-dir class-dir :jar-file target-jar}) (println (format "jar file created at: %s" target-jar))) params) (defn lib-uberjar - [{:keys [project version target srcs] - :or {version timestamp - target default-target + [{:keys [project version target srcs deps-edn] + :or {target default-target srcs default-srcs} :as params}] (let [project-sym (symbol project) - target-uber (jar-filename target project version) - class-dir (make-class-dir target)] + target-uber (make-uber-filename target project version) + class-dir (make-class-dir target) + basis (make-basis deps-edn) + src-dirs (str/split srcs #",")] (clean params) - (b/copy-dir {:src-dirs srcs + (b/copy-dir {:src-dirs src-dirs :target-dir class-dir}) (b/compile-clj {:basis basis - :src-dirs srcs + :src-dirs src-dirs :class-dir class-dir}) (b/uber {:class-dir class-dir :uber-file target-uber