This thread contains a patchset. You're looking at the original emails,
but you may wish to use the patch review UI.
Review patch
8
[PATCH 1/8] Initial commit
---
000-disable-cljsbuild.patch | 12 ++++++
001-native-image-args.patch | 13 ++++++
default.nix | 82 ++++++++++++++++++++++++ -------------
3 files changed, 79 insertions(+), 28 deletions(-)
create mode 100644 000-disable-cljsbuild.patch
create mode 100644 001-native-image-args.patch
diff --git a/000-disable-cljsbuild.patch b/000-disable-cljsbuild.patch
new file mode 100644
index 00000000000..ccea59fa3bd
--- /dev/null
+++ b/000-disable-cljsbuild.patch
@@ -0,0 +1,12 @@
+ diff --git a/project.clj b/project.clj
+ index b881c1e..407680c 100644
+ --- a/project.clj
+ +++ b/project.clj
+ @@ -11,7 +11,6 @@
+ [rewrite-clj "1.0.605-alpha"]]
+ :plugins [[lein-cljsbuild "1.1.7"]
+ [io.taylorwood/lein-native-image "0.3.1"]]
+ - :hooks [leiningen.cljsbuild]
+ :cljsbuild {:builds
+ {"dev" {:source-paths ["src" "test"]
+ :compiler {:main cljfmt.test-runner
diff --git a/001-native-image-args.patch b/001-native-image-args.patch
new file mode 100644
index 00000000000..b9340b9c778
--- /dev/null
+++ b/001-native-image-args.patch
@@ -0,0 +1,13 @@
+ diff --git a/project.clj b/project.clj
+ index b881c1e..c1474d6 100644
+ --- a/project.clj
+ +++ b/project.clj
+ @@ -26,6 +26,8 @@
+ "-H:+ReportExceptionStackTraces"
+ "-J-Dclojure.spec.skip-macros=true"
+ "-J-Dclojure.compiler.direct-linking=true"
+ + "-H:CLibraryPath={GRAALVM}/lib"
+ + "-H:-CheckToolchain"
+ "-H:ReflectionConfigurationFiles=reflection.json"
+ "--initialize-at-build-time"
+ "--report-unsupported-elements-at-runtime"
diff --git a/default.nix b/default.nix
index faed7e26354..5bc8179c235 100644
--- a/default.nix
+++ b/default.nix
@@ -1,28 +1,54 @@
- let requiredVersion = import ./lib/minver.nix; in
-
- if ! builtins ? nixVersion || builtins.compareVersions requiredVersion builtins.nixVersion == 1 then
-
- abort ''
-
- This version of Nixpkgs requires Nix >= ${requiredVersion}, please upgrade:
-
- - If you are running NixOS, `nixos-rebuild' can be used to upgrade your system.
-
- - Alternatively, with Nix > 2.0 `nix upgrade-nix' can be used to imperatively
- upgrade Nix. You may use `nix-env --version' to check which version you have.
-
- - If you installed Nix using the install script (https://nixos.org/nix/install),
- it is safe to upgrade by running it again:
-
- curl -L https://nixos.org/nix/install | sh
-
- For more information, please see the NixOS release notes at
- https://nixos.org/nixos/manual or locally at
- ${toString ./nixos/doc/manual/release-notes}.
-
- If you need further help, see https://nixos.org/nixos/support.html
- ''
-
- else
-
- import ./pkgs/top-level/impure.nix
+ { pkgs, stdenv, ... }:
+
+ let
+ version = "0.8.0";
+ name = "cljfmt-${version}";
+ src = (pkgs.fetchFromGitHub {
+ owner = "weavejester";
+ repo = "cljfmt";
+ rev = version;
+ sha256 = "sha256-PewWP1O9x8h7666F9lNcoh6UrFatYfhkFNub57500rs=";
+ }) + "/cljfmt";
+
+ dependencies = stdenv.mkDerivation {
+ name = "${name}-dependencies";
+ inherit src;
+ buildInputs = [ pkgs.leiningen ];
+ buildPhase = ''
+ export LEIN_HOME=$out/.lein
+ export LEIN_JVM_OPTS="-Dmaven.repo.local=$out/.m2 -Duser.home=$out"
+ lein deps
+ '';
+ # keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
+ installPhase = ''
+ find $out/.m2 -type f -regex '.+\\(\\.lastUpdated\\|resolver-status\\.properties\\|_remote\\.repositories\\)' -delete
+ '';
+ outputHashAlgo = "sha256";
+ outputHashMode = "recursive";
+ outputHash = "sha256-eTI0Huw8MKcqNygqQ3hsuZCQk6qbFrUXGOnKmUNy0BI=";
+ };
+
+ in stdenv.mkDerivation {
+ inherit version name src;
+ buildInputs = [ pkgs.leiningen pkgs.graalvm11-ce pkgs.glibcLocales ];
+
+ patches = [ ./000-disable-cljsbuild.patch ./001-native-image-args.patch ];
+
+ postPatch = ''
+ substituteInPlace project.clj --replace '{GRAALVM}' ${pkgs.graalvm11-ce}
+ '';
+
+ buildPhase = ''
+ mkdir -p $out/.lein
+ export LEIN_HOME=$out/.lein
+ export LEIN_JVM_OPTS="-Dmaven.repo.local=$out/.m2 -Duser.home=$out"
+ ln -s ${dependencies}/.m2 $out/.m2
+ LEIN_OFFLINE=true lein native-image
+ '';
+
+ installPhase = ''
+ install -d $out/bin
+ install -t $out/bin target/cljfmt
+ '';
+
+ }
--
2.33.1
[PATCH 5/8] Preparing for merge into nixpkgs repo
---
.../interpreters/clojure/cljfmt/000-disable-cljsbuild.patch | 0
.../interpreters/clojure/cljfmt/001-native-image-args.patch | 0
.../development/interpreters/clojure/cljfmt/default.nix | 0
3 files changed, 0 insertions(+), 0 deletions(-)
rename 000-disable-cljsbuild.patch => pkgs/development/interpreters/clojure/cljfmt/000-disable-cljsbuild.patch (100%)
rename 001-native-image-args.patch => pkgs/development/interpreters/clojure/cljfmt/001-native-image-args.patch (100%)
rename default.nix => pkgs/development/interpreters/clojure/cljfmt/default.nix (100%)
diff --git a/000-disable-cljsbuild.patch b/pkgs/development/interpreters/clojure/cljfmt/000-disable-cljsbuild.patch
similarity index 100%
rename from 000-disable-cljsbuild.patch
rename to pkgs/development/interpreters/clojure/cljfmt/000-disable-cljsbuild.patch
diff --git a/001-native-image-args.patch b/pkgs/development/interpreters/clojure/cljfmt/001-native-image-args.patch
similarity index 100%
rename from 001-native-image-args.patch
rename to pkgs/development/interpreters/clojure/cljfmt/001-native-image-args.patch
diff --git a/default.nix b/pkgs/development/interpreters/clojure/cljfmt/default.nix
similarity index 100%
rename from default.nix
rename to pkgs/development/interpreters/clojure/cljfmt/default.nix
--
2.33.1
[PATCH 4/8] Add meta section
---
default.nix | 9 +++++++ --
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/default.nix b/default.nix
index 9d2cdd828ad..121d6f3e180 100644
--- a/default.nix
+++ b/default.nix
@@ -1,7 +1,6 @@
- { pkgs, stdenv, ... }:
+ { pkgs, stdenv, lib, ... }:
let
-
fetchLeiningenDeps = { name, src, sha256 }:
stdenv.mkDerivation {
name = "${name}-dependencies";
@@ -60,4 +59,10 @@ in stdenv.mkDerivation {
install -t $out/bin target/cljfmt
'';
+ meta = with lib; {
+ description = "A tool for formatting Clojure code";
+ homepage = "https://github.com/weavejester/cljfmt";
+ license = licenses.epl10;
+ platforms = graalvm11-ce.meta.platforms;
+ };
}
--
2.33.1
[PATCH 3/8] Create generic functions for leiningen
---
default.nix | 57 +++++++++++++++++++++++++++++++ ----------------------
1 file changed, 33 insertions(+), 24 deletions(-)
diff --git a/default.nix b/default.nix
index 121d57427e4..9d2cdd828ad 100644
--- a/default.nix
+++ b/default.nix
@@ -1,6 +1,34 @@
{ pkgs, stdenv, ... }:
let
+
+ fetchLeiningenDeps = { name, src, sha256 }:
+ stdenv.mkDerivation {
+ name = "${name}-dependencies";
+ inherit src;
+ buildInputs = [ pkgs.leiningen ];
+ buildPhase = ''
+ export LEIN_HOME=$out/.lein
+ export LEIN_JVM_OPTS="-Dmaven.repo.local=$out/.m2 -Duser.home=$out"
+ lein deps
+ '';
+ # keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
+ installPhase = ''
+ find $out/.m2 -type f -regex '.+\\(\\.lastUpdated\\|resolver-status\\.properties\\|_remote\\.repositories\\)' -delete
+ '';
+ outputHashAlgo = "sha256";
+ outputHashMode = "recursive";
+ outputHash = sha256;
+ };
+
+ runLeiningen = cmd: dependencies: ''
+ mkdir -p $out/.lein
+ export LEIN_HOME=$out/.lein
+ export LEIN_JVM_OPTS="-Dmaven.repo.local=$out/.m2 -Duser.home=$out"
+ ln -s ${dependencies}/.m2 $out/.m2
+ LEIN_OFFLINE=true lein ${cmd}
+ '';
+
version = "0.8.0";
name = "cljfmt-${version}";
src = (pkgs.fetchFromGitHub {
@@ -10,23 +38,10 @@ let
sha256 = "sha256-PewWP1O9x8h7666F9lNcoh6UrFatYfhkFNub57500rs=";
}) + "/cljfmt";
- dependencies = stdenv.mkDerivation {
- name = "${name}-dependencies";
- inherit src;
- buildInputs = [ pkgs.leiningen ];
- buildPhase = ''
- export LEIN_HOME=$out/.lein
- export LEIN_JVM_OPTS="-Dmaven.repo.local=$out/.m2 -Duser.home=$out"
- lein deps
- '';
- # keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
- installPhase = ''
- find $out/.m2 -type f -regex '.+/_remote\.repositories' -delete
- '';
- outputHashAlgo = "sha256";
- outputHashMode = "recursive";
- outputHash = "1fhnmnm5iwwrysk1g04mzj4p159fady8jfsb3c31aifnwcv4qd5b";
- };
+ dependencies = (fetchLeiningenDeps {
+ inherit name src;
+ sha256 = "1fhnmnm5iwwrysk1g04mzj4p159fady8jfsb3c31aifnwcv4qd5b";
+ });
in stdenv.mkDerivation {
inherit version name src;
@@ -38,13 +53,7 @@ in stdenv.mkDerivation {
substituteInPlace project.clj --replace '{GRAALVM}' ${pkgs.graalvm11-ce}
'';
- buildPhase = ''
- mkdir -p $out/.lein
- export LEIN_HOME=$out/.lein
- export LEIN_JVM_OPTS="-Dmaven.repo.local=$out/.m2 -Duser.home=$out"
- ln -s ${dependencies}/.m2 $out/.m2
- LEIN_OFFLINE=true lein native-image
- '';
+ buildPhase = runLeiningen "native-image" dependencies;
installPhase = ''
install -d $out/bin
--
2.33.1
[PATCH 2/8] Fix deletion of files with timestamp
---
default.nix | 4 ++ --
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/default.nix b/default.nix
index 5bc8179c235..121d57427e4 100644
--- a/default.nix
+++ b/default.nix
@@ -21,11 +21,11 @@ let
'';
# keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
installPhase = ''
- find $out/.m2 -type f -regex '.+\\(\\.lastUpdated\\|resolver-status\\.properties\\|_remote\\.repositories\\)' -delete
+ find $out/.m2 -type f -regex '.+/_remote\.repositories' -delete
'';
outputHashAlgo = "sha256";
outputHashMode = "recursive";
- outputHash = "sha256-eTI0Huw8MKcqNygqQ3hsuZCQk6qbFrUXGOnKmUNy0BI=";
+ outputHash = "1fhnmnm5iwwrysk1g04mzj4p159fady8jfsb3c31aifnwcv4qd5b";
};
in stdenv.mkDerivation {
--
2.33.1
[PATCH 8/8] Don't pollute $out
---
pkgs/development/interpreters/clojure/cljfmt/default.nix | 8 ++++ ----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pkgs/development/interpreters/clojure/cljfmt/default.nix b/pkgs/development/interpreters/clojure/cljfmt/default.nix
index 3c7e6b3672a..98109846cd1 100644
--- a/pkgs/development/interpreters/clojure/cljfmt/default.nix
+++ b/pkgs/development/interpreters/clojure/cljfmt/default.nix
@@ -21,10 +21,10 @@ let
};
runLeiningen = cmd: dependencies: ''
- mkdir -p $out/.lein
- export LEIN_HOME=$out/.lein
- export LEIN_JVM_OPTS="-Dmaven.repo.local=$out/.m2 -Duser.home=$out"
- ln -s ${dependencies}/.m2 $out/.m2
+ mkdir -p /tmp/.lein
+ ln -s ${dependencies}/.m2 /tmp/.m2
+ export LEIN_HOME=/tmp/.lein
+ export LEIN_JVM_OPTS="-Dmaven.repo.local=/tmp/.m2 -Duser.home=/tmp"
LEIN_OFFLINE=true lein ${cmd}
'';
--
2.33.1
[PATCH 7/8] Explicitly list dependencies
---
.../interpreters/clojure/cljfmt/default.nix | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/pkgs/development/interpreters/clojure/cljfmt/default.nix b/pkgs/development/interpreters/clojure/cljfmt/default.nix
index 121d6f3e180..3c7e6b3672a 100644
--- a/pkgs/development/interpreters/clojure/cljfmt/default.nix
+++ b/pkgs/development/interpreters/clojure/cljfmt/default.nix
@@ -1,11 +1,11 @@
- { pkgs, stdenv, lib, ... }:
+ { lib, stdenv, fetchFromGitHub, leiningen, graalvm11-ce, ... }:
let
fetchLeiningenDeps = { name, src, sha256 }:
stdenv.mkDerivation {
name = "${name}-dependencies";
inherit src;
- buildInputs = [ pkgs.leiningen ];
+ buildInputs = [ leiningen ];
buildPhase = ''
export LEIN_HOME=$out/.lein
export LEIN_JVM_OPTS="-Dmaven.repo.local=$out/.m2 -Duser.home=$out"
@@ -30,7 +30,7 @@ let
version = "0.8.0";
name = "cljfmt-${version}";
- src = (pkgs.fetchFromGitHub {
+ src = (fetchFromGitHub {
owner = "weavejester";
repo = "cljfmt";
rev = version;
@@ -44,12 +44,12 @@ let
in stdenv.mkDerivation {
inherit version name src;
- buildInputs = [ pkgs.leiningen pkgs.graalvm11-ce pkgs.glibcLocales ];
+ buildInputs = [ leiningen graalvm11-ce ];
patches = [ ./000-disable-cljsbuild.patch ./001-native-image-args.patch ];
postPatch = ''
- substituteInPlace project.clj --replace '{GRAALVM}' ${pkgs.graalvm11-ce}
+ substituteInPlace project.clj --replace '{GRAALVM}' ${graalvm11-ce}
'';
buildPhase = runLeiningen "native-image" dependencies;
--
2.33.1
[PATCH 6/8] Add to nixpkgs
---
default.nix | 28 ++++++++++++++++++++++++++++
pkgs/top-level/all-packages.nix | 2 ++
2 files changed, 30 insertions(+)
create mode 100644 default.nix
diff --git a/default.nix b/default.nix
new file mode 100644
index 00000000000..faed7e26354
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,28 @@
+ let requiredVersion = import ./lib/minver.nix; in
+
+ if ! builtins ? nixVersion || builtins.compareVersions requiredVersion builtins.nixVersion == 1 then
+
+ abort ''
+
+ This version of Nixpkgs requires Nix >= ${requiredVersion}, please upgrade:
+
+ - If you are running NixOS, `nixos-rebuild' can be used to upgrade your system.
+
+ - Alternatively, with Nix > 2.0 `nix upgrade-nix' can be used to imperatively
+ upgrade Nix. You may use `nix-env --version' to check which version you have.
+
+ - If you installed Nix using the install script (https://nixos.org/nix/install),
+ it is safe to upgrade by running it again:
+
+ curl -L https://nixos.org/nix/install | sh
+
+ For more information, please see the NixOS release notes at
+ https://nixos.org/nixos/manual or locally at
+ ${toString ./nixos/doc/manual/release-notes}.
+
+ If you need further help, see https://nixos.org/nixos/support.html
+ ''
+
+ else
+
+ import ./pkgs/top-level/impure.nix
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index f53c2e1a089..f5a5501dc3c 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -13740,6 +13740,8 @@ with pkgs;
clisp = callPackage ../development/interpreters/clisp { };
clisp-tip = callPackage ../development/interpreters/clisp/hg.nix { };
+ cljfmt = callPackage ../development/interpreters/clojure/cljfmt { };
+
clojupyter = callPackage ../applications/editors/jupyter-kernels/clojupyter {
jre = jre8;
};
--
2.33.1
[PATCH v2] cljfmt: init at 0.8.0
Use `lein native-image` to build an executable, so leiningen is not
needed to run it.
---
.../cljfmt/000-disable-cljsbuild.patch | 12 ++++
.../cljfmt/001-native-image-args.patch | 13 ++++
.../interpreters/clojure/cljfmt/default.nix | 68 +++++++++++++++++++
pkgs/top-level/all-packages.nix | 2 +
4 files changed, 95 insertions(+)
create mode 100644 pkgs/development/interpreters/clojure/cljfmt/000-disable-cljsbuild.patch
create mode 100644 pkgs/development/interpreters/clojure/cljfmt/001-native-image-args.patch
create mode 100644 pkgs/development/interpreters/clojure/cljfmt/default.nix
diff --git a/pkgs/development/interpreters/clojure/cljfmt/000-disable-cljsbuild.patch b/pkgs/development/interpreters/clojure/cljfmt/000-disable-cljsbuild.patch
new file mode 100644
index 00000000000..ccea59fa3bd
--- /dev/null
+++ b/pkgs/development/interpreters/clojure/cljfmt/000-disable-cljsbuild.patch
@@ -0,0 +1,12 @@
+ diff --git a/project.clj b/project.clj
+ index b881c1e..407680c 100644
+ --- a/project.clj
+ +++ b/project.clj
+ @@ -11,7 +11,6 @@
+ [rewrite-clj "1.0.605-alpha"]]
+ :plugins [[lein-cljsbuild "1.1.7"]
+ [io.taylorwood/lein-native-image "0.3.1"]]
+ - :hooks [leiningen.cljsbuild]
+ :cljsbuild {:builds
+ {"dev" {:source-paths ["src" "test"]
+ :compiler {:main cljfmt.test-runner
diff --git a/pkgs/development/interpreters/clojure/cljfmt/001-native-image-args.patch b/pkgs/development/interpreters/clojure/cljfmt/001-native-image-args.patch
new file mode 100644
index 00000000000..b9340b9c778
--- /dev/null
+++ b/pkgs/development/interpreters/clojure/cljfmt/001-native-image-args.patch
@@ -0,0 +1,13 @@
+ diff --git a/project.clj b/project.clj
+ index b881c1e..c1474d6 100644
+ --- a/project.clj
+ +++ b/project.clj
+ @@ -26,6 +26,8 @@
+ "-H:+ReportExceptionStackTraces"
+ "-J-Dclojure.spec.skip-macros=true"
+ "-J-Dclojure.compiler.direct-linking=true"
+ + "-H:CLibraryPath={GRAALVM}/lib"
+ + "-H:-CheckToolchain"
+ "-H:ReflectionConfigurationFiles=reflection.json"
+ "--initialize-at-build-time"
+ "--report-unsupported-elements-at-runtime"
diff --git a/pkgs/development/interpreters/clojure/cljfmt/default.nix b/pkgs/development/interpreters/clojure/cljfmt/default.nix
new file mode 100644
index 00000000000..98109846cd1
--- /dev/null
+++ b/pkgs/development/interpreters/clojure/cljfmt/default.nix
@@ -0,0 +1,68 @@
+ { lib, stdenv, fetchFromGitHub, leiningen, graalvm11-ce, ... }:
+
+ let
+ fetchLeiningenDeps = { name, src, sha256 }:
+ stdenv.mkDerivation {
+ name = "${name}-dependencies";
+ inherit src;
+ buildInputs = [ leiningen ];
+ buildPhase = ''
+ export LEIN_HOME=$out/.lein
+ export LEIN_JVM_OPTS="-Dmaven.repo.local=$out/.m2 -Duser.home=$out"
+ lein deps
+ '';
+ # keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
+ installPhase = ''
+ find $out/.m2 -type f -regex '.+\\(\\.lastUpdated\\|resolver-status\\.properties\\|_remote\\.repositories\\)' -delete
+ '';
+ outputHashAlgo = "sha256";
+ outputHashMode = "recursive";
+ outputHash = sha256;
+ };
+
+ runLeiningen = cmd: dependencies: ''
+ mkdir -p /tmp/.lein
+ ln -s ${dependencies}/.m2 /tmp/.m2
+ export LEIN_HOME=/tmp/.lein
+ export LEIN_JVM_OPTS="-Dmaven.repo.local=/tmp/.m2 -Duser.home=/tmp"
+ LEIN_OFFLINE=true lein ${cmd}
+ '';
+
+ version = "0.8.0";
+ name = "cljfmt-${version}";
+ src = (fetchFromGitHub {
+ owner = "weavejester";
+ repo = "cljfmt";
+ rev = version;
+ sha256 = "sha256-PewWP1O9x8h7666F9lNcoh6UrFatYfhkFNub57500rs=";
+ }) + "/cljfmt";
+
+ dependencies = (fetchLeiningenDeps {
+ inherit name src;
+ sha256 = "1fhnmnm5iwwrysk1g04mzj4p159fady8jfsb3c31aifnwcv4qd5b";
+ });
+
+ in stdenv.mkDerivation {
+ inherit version name src;
+ buildInputs = [ leiningen graalvm11-ce ];
+
+ patches = [ ./000-disable-cljsbuild.patch ./001-native-image-args.patch ];
+
+ postPatch = ''
+ substituteInPlace project.clj --replace '{GRAALVM}' ${graalvm11-ce}
+ '';
+
+ buildPhase = runLeiningen "native-image" dependencies;
+
+ installPhase = ''
+ install -d $out/bin
+ install -t $out/bin target/cljfmt
+ '';
+
+ meta = with lib; {
+ description = "A tool for formatting Clojure code";
+ homepage = "https://github.com/weavejester/cljfmt";
+ license = licenses.epl10;
+ platforms = graalvm11-ce.meta.platforms;
+ };
+ }
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index f53c2e1a089..f5a5501dc3c 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -13740,6 +13740,8 @@ with pkgs;
clisp = callPackage ../development/interpreters/clisp { };
clisp-tip = callPackage ../development/interpreters/clisp/hg.nix { };
+ cljfmt = callPackage ../development/interpreters/clojure/cljfmt { };
+
clojupyter = callPackage ../applications/editors/jupyter-kernels/clojupyter {
jre = jre8;
};
--
2.33.1