Evolving, not working
This commit is contained in:
parent
da554a2ba0
commit
31629acbb0
|
@ -1,10 +1,9 @@
|
||||||
{ lib, stdenv, build-tools-src, clojure, callPackage, writeText
|
{ lib, stdenv, build-tools-src, clojure, callPackage, writeText
|
||||||
, writeShellScript, gitignoreSource, jre, ... }:
|
, writeShellScript, gitignoreSource, jre, version, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
base-name = "clojure-build-tools";
|
base-name = "clojure-build-tools";
|
||||||
version = "0.8.2";
|
|
||||||
full-name = "${base-name}-${version}.jar";
|
full-name = "${base-name}-${version}.jar";
|
||||||
cljdeps = callPackage ./deps.nix { };
|
cljdeps = callPackage ./deps.nix { };
|
||||||
tools-classpath = cljdeps.makeClasspaths { };
|
tools-classpath = cljdeps.makeClasspaths { };
|
||||||
|
@ -21,8 +20,7 @@ let
|
||||||
java-compile = classpath: ns:
|
java-compile = classpath: ns:
|
||||||
''java -cp .:${classpath} clojure.main -e "(compile ${ns})"'';
|
''java -cp .:${classpath} clojure.main -e "(compile ${ns})"'';
|
||||||
head-or-null = lst: if (lst == [ ]) then null else head lst;
|
head-or-null = lst: if (lst == [ ]) then null else head lst;
|
||||||
matches-ext = ext: filename: type:
|
matches-ext = ext: filename: (builtins.match ".+[.]${ext}$" filename) != null;
|
||||||
(builtins.match ".+[.]${ext}$" filename) != null;
|
|
||||||
strip-ext = ext: filename:
|
strip-ext = ext: filename:
|
||||||
head-or-null (builtins.match "(.+)[.]${ext}$" filename);
|
head-or-null (builtins.match "(.+)[.]${ext}$" filename);
|
||||||
ext-files = ext: path:
|
ext-files = ext: path:
|
||||||
|
@ -33,7 +31,32 @@ let
|
||||||
task-namespaces = map (ns: "'clojure.tools.build.tasks.${ns}") tasks;
|
task-namespaces = map (ns: "'clojure.tools.build.tasks.${ns}") tasks;
|
||||||
all-namespaces = task-namespaces ++ [ "'clojure.tools.build.api" ];
|
all-namespaces = task-namespaces ++ [ "'clojure.tools.build.api" ];
|
||||||
|
|
||||||
|
file-to-namespace = base: filename:
|
||||||
|
let
|
||||||
|
swap-chars = replaceStrings [ "_" "/" ] [ "-" "." ];
|
||||||
|
strip-clj = strip-ext "clj";
|
||||||
|
strip-base = replaceStrings [ "${base}/" ] [ "" ];
|
||||||
|
ns = swap-chars (strip-base (strip-clj (toString filename)));
|
||||||
|
in "'${ns}";
|
||||||
|
|
||||||
|
concatMapAttrs = f: attrs: concatLists (mapAttrsToList f attrs);
|
||||||
|
|
||||||
|
find-files = pred: path:
|
||||||
|
let
|
||||||
|
find-files-impl = base:
|
||||||
|
concatMapAttrs (handle-file base) (builtins.readDir base);
|
||||||
|
handle-file = base: name: type:
|
||||||
|
if (type == "directory") then
|
||||||
|
find-files-impl "${base}/${name}"
|
||||||
|
else
|
||||||
|
(if (pred name) then [ "${base}/${name}" ] else [ ]);
|
||||||
|
in find-files-impl path;
|
||||||
|
|
||||||
|
tools-namespaces = let base = "${build-tools-src}/src/main/clojure";
|
||||||
|
in map (file-to-namespace base) (find-files (matches-ext "clj") base);
|
||||||
|
|
||||||
in stdenv.mkDerivation {
|
in stdenv.mkDerivation {
|
||||||
|
|
||||||
name = full-name;
|
name = full-name;
|
||||||
src = gitignoreSource "${build-tools-src}/src/main/clojure";
|
src = gitignoreSource "${build-tools-src}/src/main/clojure";
|
||||||
nativeBuildInputs = [ jre ];
|
nativeBuildInputs = [ jre ];
|
||||||
|
@ -45,8 +68,25 @@ in stdenv.mkDerivation {
|
||||||
cp ${./src}/build.clj .
|
cp ${./src}/build.clj .
|
||||||
${concatStringsSep "\n" (map extract-jar dep-jars)}
|
${concatStringsSep "\n" (map extract-jar dep-jars)}
|
||||||
${concatStringsSep "\n"
|
${concatStringsSep "\n"
|
||||||
(map (java-compile tools-classpath) (all-namespaces ++ [ "'build" ]))}
|
(map (java-compile tools-classpath) (tools-namespaces ++ [ "'build" ]))}
|
||||||
jar cmf ${manifest} ./out.jar -C . cljs cognitect com javax mozilla plugin.xml about.html clojure cognitect_aws_http.edn data_readers.cljc licenses org
|
jar cmf ${manifest} ./out.jar -C . ${
|
||||||
|
concatStringsSep " " [
|
||||||
|
"build"
|
||||||
|
"cljs"
|
||||||
|
"cognitect"
|
||||||
|
"com"
|
||||||
|
"javax"
|
||||||
|
"mozilla"
|
||||||
|
"plugin.xml"
|
||||||
|
"about.html"
|
||||||
|
"clojure"
|
||||||
|
"cognitect_aws_http.edn"
|
||||||
|
"data_readers.cljc"
|
||||||
|
"licenses"
|
||||||
|
"org"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
cat /tmp/*.edn
|
||||||
'';
|
'';
|
||||||
in "${build-script}";
|
in "${build-script}";
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
pkgs = nixpkgs.legacyPackages."${system}";
|
pkgs = nixpkgs.legacyPackages."${system}";
|
||||||
build-tools-jar = pkgs.callPackage ./build.tools.nix {
|
build-tools-jar = pkgs.callPackage ./build.tools.nix {
|
||||||
|
version = "0.8.2";
|
||||||
inherit build-tools-src;
|
inherit build-tools-src;
|
||||||
inherit (gitignore.lib) gitignoreSource;
|
inherit (gitignore.lib) gitignoreSource;
|
||||||
};
|
};
|
||||||
|
|
|
@ -42,7 +42,7 @@ in stdenv.mkDerivation {
|
||||||
nativeBuildInputs = [ clojure jre ];
|
nativeBuildInputs = [ clojure jre ];
|
||||||
buildInputs = (map (x: x.paths) clj-deps.packages);
|
buildInputs = (map (x: x.paths) clj-deps.packages);
|
||||||
|
|
||||||
buildPhase = builtins.trace "${build-script}" "${build-script}";
|
buildPhase = "${build-script}";
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mv ${target}/${name}-${version}-standalone.jar $out
|
mv ${target}/${name}-${version}-standalone.jar $out
|
||||||
|
|
Loading…
Reference in New Issue