Run ~node2nix~[fn:node2nix] on the repo to convert JavaScript dependencies into Nix-addressable packages
Run ~clj2nix~[fn:clj2nix] on the repo to convert Clojure/Java/Maven dependencies into Nix-addressible packages
Nix needs a way to integrate both of these together. NPM has a mostly freeform build system, composing only of build artifacts and you can do fuck all. I overrode the Node component instead, because of this. I used the following code:
{ pkgs ? import <nixpkgs> { inherit system; }
, system ? builtins.currentSystem
, clojure ? pkgs.clojure
, stdenv ? pkgs.stdenv
}@args:
with import ./default.nix args;
let cljdeps = import ./clj-deps.nix { inherit pkgs; };
classp = cljdeps.makeClasspaths {};
clojure_wrapped = pkgs.runCommand "clojure-wrapped" {
nativeBuildInputs = [ pkgs.makeWrapper ];
} ''
mkdir -p $out/bin
makeWrapper ${clojure}/bin/clojure $out/bin/clojure \
--add-flags "-Scp ${classp}:src"
'';
in package.override {
nativeBuildInputs = [clojure_wrapped];
outputs = [ "out" "bundle" ];
postInstall = ''
mkdir -p $bundle
sed -i "s|:output-dir \"js\"|:output-dir \"$bundle\"|" shadow-cljs.edn
npx shadow-cljs release app
'';
}
[fn:node2nix] https://github.com/svanderburg/node2nix or nixpkgs.node2nix [fn:clj2nix] https://github.com/hlolli/clj2nix