summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Weiss <dev.primeos@gmail.com>2019-06-28 15:33:06 +0200
committerMichael Weiss <dev.primeos@gmail.com>2019-06-28 16:12:15 +0200
commitd24aefd52f75f0854a417c3adf02c9d310c23157 (patch)
tree3205580589c784c98908bdb758498329b904a5fe
parent67ea4fcd3b4c06216951778c004371a3186512b7 (diff)
downloadnixpkgs-d24aefd52f75f0854a417c3adf02c9d310c23157.tar
nixpkgs-d24aefd52f75f0854a417c3adf02c9d310c23157.tar.gz
nixpkgs-d24aefd52f75f0854a417c3adf02c9d310c23157.tar.bz2
nixpkgs-d24aefd52f75f0854a417c3adf02c9d310c23157.tar.lz
nixpkgs-d24aefd52f75f0854a417c3adf02c9d310c23157.tar.xz
nixpkgs-d24aefd52f75f0854a417c3adf02c9d310c23157.tar.zst
nixpkgs-d24aefd52f75f0854a417c3adf02c9d310c23157.zip
jekyll: Improve the "jekyll new" experience
See https://github.com/NixOS/nixpkgs/issues/58126 for more details.

This will instruct the user how to manually finish the setup instead of
failing with error messages (unfortunately it is quite a bit hacky
though...).

Extra note:
We cannot use "bundle config --local" due to BUNDLE_GEMFILE (would
attempt to create .bundle/config in the Nix store) and manually creating
.bundle/config doesn't work either as these configuration variables are
still overwritten by the environment variables, even though this
shouldn't be the case [0].

[0]: https://bundler.io/v2.0/man/bundle-config.1.html
-rw-r--r--pkgs/applications/misc/jekyll/default.nix27
1 files changed, 26 insertions, 1 deletions
diff --git a/pkgs/applications/misc/jekyll/default.nix b/pkgs/applications/misc/jekyll/default.nix
index 34cf0e21db7..9ae9ab254e8 100644
--- a/pkgs/applications/misc/jekyll/default.nix
+++ b/pkgs/applications/misc/jekyll/default.nix
@@ -1,8 +1,27 @@
 { lib, bundlerApp, ruby
+, writeShellScriptBin, makeWrapper
 , withOptionalDependencies ? false
 }:
 
-bundlerApp rec {
+let
+  rubyWrapper = writeShellScriptBin "ruby" ''
+    if [[ "$#" -eq 2 ]]; then
+      if [[ "''${1##*/}" == "bundle" && "$2" == "install" ]]; then
+        # See https://github.com/NixOS/nixpkgs/issues/58126 for more details.
+        echo 'Skipping "bundle install" as it fails due to the Nix wrapper.'
+        echo 'Please enter the new directory and run the following commands to serve the page:'
+        echo 'nix-shell -p bundler --run "bundle install --gemfile=Gemfile --path vendor/cache"'
+        echo 'nix-shell -p bundler --run "bundle exec jekyll serve"'
+        exit 0
+        # The following nearly works:
+        unset BUNDLE_FROZEN
+        exec ${ruby}/bin/ruby "$@" --gemfile=Gemfile --path=vendor/cache
+      fi
+    fi
+    # Else: Don't modify the arguments:
+    exec ${ruby}/bin/ruby "$@"
+  '';
+in bundlerApp rec {
   pname = "jekyll";
   exes = [ "jekyll" ];
 
@@ -11,6 +30,12 @@ bundlerApp rec {
     then ./full
     else ./basic;
 
+  buildInputs = [ makeWrapper ];
+
+  postBuild = ''
+    wrapProgram $out/bin/jekyll --prefix PATH : ${rubyWrapper}/bin
+  '';
+
   meta = with lib; {
     description = "A blog-aware, static site generator, written in Ruby";
     longDescription = ''