From 171130e09a3f18a166c76df48a71ccf15e99a1c6 Mon Sep 17 00:00:00 2001
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Date: Fri, 3 Mar 2017 20:08:53 -0500
Subject: [PATCH 1/4] jekyll: 3.0.1 -> 3.4.1

---
 pkgs/applications/misc/jekyll/Gemfile.lock |  49 +++--
 pkgs/applications/misc/jekyll/default.nix  |  10 +-
 pkgs/applications/misc/jekyll/gemset.nix   | 218 ++++++++++++---------
 3 files changed, 155 insertions(+), 122 deletions(-)

diff --git a/pkgs/applications/misc/jekyll/Gemfile.lock b/pkgs/applications/misc/jekyll/Gemfile.lock
index c2d82181be2..fffc3316527 100644
--- a/pkgs/applications/misc/jekyll/Gemfile.lock
+++ b/pkgs/applications/misc/jekyll/Gemfile.lock
@@ -1,36 +1,44 @@
 GEM
   remote: https://rubygems.org/
   specs:
-    RedCloth (4.2.9)
-    colorator (0.1)
-    ffi (1.9.10)
-    jekyll (3.0.1)
-      colorator (~> 0.1)
+    RedCloth (4.3.2)
+    addressable (2.5.0)
+      public_suffix (~> 2.0, >= 2.0.2)
+    colorator (1.1.0)
+    ffi (1.9.18)
+    forwardable-extended (2.6.0)
+    jekyll (3.4.1)
+      addressable (~> 2.4)
+      colorator (~> 1.0)
       jekyll-sass-converter (~> 1.0)
       jekyll-watch (~> 1.1)
       kramdown (~> 1.3)
       liquid (~> 3.0)
       mercenary (~> 0.3.3)
+      pathutil (~> 0.9)
       rouge (~> 1.7)
       safe_yaml (~> 1.0)
-    jekyll-sass-converter (1.4.0)
-      sass (~> 3.4)
-    jekyll-watch (1.3.0)
-      listen (~> 3.0)
     jekyll-paginate (1.1.0)
-    kramdown (1.9.0)
+    jekyll-sass-converter (1.5.0)
+      sass (~> 3.4)
+    jekyll-watch (1.5.0)
+      listen (~> 3.0, < 3.1)
+    kramdown (1.13.2)
     liquid (3.0.6)
-    listen (3.0.5)
-      rb-fsevent (>= 0.9.3)
-      rb-inotify (>= 0.9)
-    mercenary (0.3.5)
-    rb-fsevent (0.9.7)
-    rb-inotify (0.9.5)
+    listen (3.0.8)
+      rb-fsevent (~> 0.9, >= 0.9.4)
+      rb-inotify (~> 0.9, >= 0.9.7)
+    mercenary (0.3.6)
+    pathutil (0.14.0)
+      forwardable-extended (~> 2.6)
+    public_suffix (2.0.5)
+    rb-fsevent (0.9.8)
+    rb-inotify (0.9.8)
       ffi (>= 0.5.0)
-    rdiscount (2.1.8)
-    rouge (1.10.1)
+    rdiscount (2.2.0.1)
+    rouge (1.11.1)
     safe_yaml (1.0.4)
-    sass (3.4.20)
+    sass (3.4.23)
 
 PLATFORMS
   ruby
@@ -38,7 +46,8 @@ PLATFORMS
 DEPENDENCIES
   RedCloth
   jekyll
+  jekyll-paginate
   rdiscount
 
 BUNDLED WITH
-   1.10.6
+   1.14.4
diff --git a/pkgs/applications/misc/jekyll/default.nix b/pkgs/applications/misc/jekyll/default.nix
index b06a28513b8..f3661030a2b 100644
--- a/pkgs/applications/misc/jekyll/default.nix
+++ b/pkgs/applications/misc/jekyll/default.nix
@@ -1,11 +1,13 @@
-{ stdenv, lib, bundlerEnv, ruby_2_2, curl }:
+{ stdenv, lib, bundlerEnv, ruby }:
 
 bundlerEnv rec {
   name = "jekyll-${version}";
-  version = "3.0.1";
 
-  ruby = ruby_2_2;
-  gemdir = ./.;
+  version = (import gemset).jekyll.version;
+  inherit ruby;
+  gemfile = ./Gemfile;
+  lockfile = ./Gemfile.lock;
+  gemset = ./gemset.nix;
 
   meta = with lib; {
     description = "Simple, blog aware, static site generator";
diff --git a/pkgs/applications/misc/jekyll/gemset.nix b/pkgs/applications/misc/jekyll/gemset.nix
index a5c72d09385..0811f356582 100644
--- a/pkgs/applications/misc/jekyll/gemset.nix
+++ b/pkgs/applications/misc/jekyll/gemset.nix
@@ -1,145 +1,167 @@
 {
-  "RedCloth" = {
-    version = "4.2.9";
+  addressable = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1j5r0anj8m4qlf2psnldip4b8ha2bsscv11lpdgnfh4nnchzjnxw";
       type = "gem";
-      sha256 = "06pahxyrckhgb7alsxwhhlx1ib2xsx33793finj01jk8i054bkxl";
     };
+    version = "2.5.0";
   };
-  "colorator" = {
-    version = "0.1";
+  colorator = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0f7wvpam948cglrciyqd798gdc6z3cfijciavd0dfixgaypmvy72";
       type = "gem";
-      sha256 = "09zp15hyd9wlbgf1kmrf4rnry8cpvh1h9fj7afarlqcy4hrfdpvs";
     };
-  };
-  "ffi" = {
-    version = "1.9.10";
-    source = {
-      type = "gem";
-      sha256 = "1m5mprppw0xcrv2mkim5zsk70v089ajzqiq5hpyb0xg96fcyzyxj";
-    };
-  };
-  "jekyll" = {
-    version = "3.0.1";
-    source = {
-      type = "gem";
-      sha256 = "107svn6r7pvkg9wwfi4r44d2rqppysjf9zf09h7z1ajsy8k2s65a";
-    };
-    dependencies = [
-      "colorator"
-      "jekyll-sass-converter"
-      "jekyll-watch"
-      "jekyll-paginate"
-      "kramdown"
-      "liquid"
-      "mercenary"
-      "rouge"
-      "safe_yaml"
-    ];
-  };
-  "jekyll-sass-converter" = {
-    version = "1.4.0";
-    source = {
-      type = "gem";
-      sha256 = "095757w0pg6qh3wlfg1j1mw4fsz7s89ia4zai5f2rhx9yxsvk1d8";
-    };
-    dependencies = [
-      "sass"
-    ];
-  };
-  "jekyll-watch" = {
-    version = "1.3.0";
-    source = {
-      type = "gem";
-      sha256 = "1mqwvrd2hm6ah5zsxqsv2xdp31wl94pl8ybb1q324j79z8pvyarg";
-    };
-    dependencies = [
-      "listen"
-    ];
-  };
-  "jekyll-paginate" = {
     version = "1.1.0";
+  };
+  ffi = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "034f52xf7zcqgbvwbl20jwdyjwznvqnwpbaps9nk18v9lgb1dpx0";
       type = "gem";
+    };
+    version = "1.9.18";
+  };
+  forwardable-extended = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "15zcqfxfvsnprwm8agia85x64vjzr2w0xn9vxfnxzgcv8s699v0v";
+      type = "gem";
+    };
+    version = "2.6.0";
+  };
+  jekyll = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0qbnjx7bpshbcam6p9ss2g6gpd3gxz6h4w9yszphj3ip335yhawb";
+      type = "gem";
+    };
+    version = "3.4.1";
+  };
+  jekyll-paginate = {
+    source = {
       sha256 = "0r7bcs8fq98zldih4787zk5i9w24nz5wa26m84ssja95n3sas2l8";
-    };
-  };
-  "kramdown" = {
-    version = "1.9.0";
-    source = {
       type = "gem";
-      sha256 = "12sral2xli39mnr4b9m2sxdlgam4ni0a1mkxawc5311z107zj3p0";
     };
+    version = "1.1.0";
   };
-  "liquid" = {
-    version = "3.0.6";
+  jekyll-sass-converter = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "01m921763yfgx1gc33k5ixqz623f4c4azgnpqhgsc2q61fyfk3q1";
       type = "gem";
+    };
+    version = "1.5.0";
+  };
+  jekyll-watch = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "02rg3wi95w2l0bg1igl5k6pza723vn2b2gj975gycz1cpmhdjn6z";
+      type = "gem";
+    };
+    version = "1.5.0";
+  };
+  kramdown = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1isiqc40q44zg57bd6cfnw1a2l0s2j5skw2awn2cz3gcm7wsf49d";
+      type = "gem";
+    };
+    version = "1.13.2";
+  };
+  liquid = {
+    source = {
       sha256 = "033png37ym4jrjz5bi7zb4ic4yxacwvnllm1xxmrnr4swgyyygc2";
-    };
-  };
-  "listen" = {
-    version = "3.0.5";
-    source = {
       type = "gem";
-      sha256 = "182wd2pkf690ll19lx6zbk01a3rqkk5lwsyin6kwydl7lqxj5z3g";
     };
-    dependencies = [
-      "rb-fsevent"
-      "rb-inotify"
-    ];
+    version = "3.0.6";
   };
-  "mercenary" = {
-    version = "0.3.5";
+  listen = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1l0y7hbyfiwpvk172r28hsdqsifq1ls39hsfmzi1vy4ll0smd14i";
       type = "gem";
-      sha256 = "0ls7z086v4xl02g4ia5jhl9s76d22crgmplpmj0c383liwbqi9pb";
     };
+    version = "3.0.8";
   };
-  "rb-fsevent" = {
-    version = "0.9.7";
+  mercenary = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "10la0xw82dh5mqab8bl0dk21zld63cqxb1g16fk8cb39ylc4n21a";
       type = "gem";
-      sha256 = "1xlkflgxngwkd4nyybccgd1japrba4v3kwnp00alikj404clqx4v";
     };
+    version = "0.3.6";
   };
-  "rb-inotify" = {
-    version = "0.9.5";
+  pathutil = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0f444wx6vjd30lkkb2zn1k5a6g33lidrpyy7lmgy66n1gsiipzn7";
       type = "gem";
-      sha256 = "0kddx2ia0qylw3r52nhg83irkaclvrncgy2m1ywpbhlhsz1rymb9";
     };
-    dependencies = [
-      "ffi"
-    ];
+    version = "0.14.0";
   };
-  "rdiscount" = {
-    version = "2.1.8";
+  public_suffix = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "040jf98jpp6w140ghkhw2hvc1qx41zvywx5gj7r2ylr1148qnj7q";
       type = "gem";
-      sha256 = "0vcyy90r6wfg0b0y5wqp3d25bdyqjbwjhkm1xy9jkz9a7j72n70v";
     };
+    version = "2.0.5";
   };
-  "rouge" = {
-    version = "1.10.1";
+  rb-fsevent = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1pdiasp9zlr306yld19szapi6kdjk38rpv1hih9x0ry40x6mb63n";
       type = "gem";
-      sha256 = "0wp8as9ypdy18kdj9h70kny1rdfq71mr8cj2bpahr9vxjjvjasqz";
     };
+    version = "0.9.8";
   };
-  "safe_yaml" = {
-    version = "1.0.4";
+  rb-inotify = {
     source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0bq14f3md5nm00kgxgf0r9lcbn0vgbwljgajif0slxcwv622fjg9";
       type = "gem";
+    };
+    version = "0.9.8";
+  };
+  rdiscount = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1arvk3k06prxasq1djbj065ixar4zl171340g7wr1ww4gj9makx3";
+      type = "gem";
+    };
+    version = "2.2.0.1";
+  };
+  RedCloth = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0m9dv7ya9q93r8x1pg2gi15rxlbck8m178j1fz7r5v6wr1avrrqy";
+      type = "gem";
+    };
+    version = "4.3.2";
+  };
+  rouge = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "13amckbdknnc5491ag28y8pqbyfpbzx5n4rlmadxhd3wkrhp92c8";
+      type = "gem";
+    };
+    version = "1.11.1";
+  };
+  safe_yaml = {
+    source = {
       sha256 = "1hly915584hyi9q9vgd968x2nsi5yag9jyf5kq60lwzi5scr7094";
-    };
-  };
-  "sass" = {
-    version = "3.4.20";
-    source = {
       type = "gem";
-      sha256 = "04rpdcp258arh2wgdk9shbqnzd6cbbbpi3wpi9a0wby8awgpxmyf";
     };
+    version = "1.0.4";
   };
-}
+  sass = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0da4mn3n60cm1ss1pw1rrpa7fxagglxiwcgvz1asf1qgf4mvcwyr";
+      type = "gem";
+    };
+    version = "3.4.23";
+  };
+}
\ No newline at end of file

From 0832addf6798207cb1f60a8b96389424aa68b630 Mon Sep 17 00:00:00 2001
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Date: Fri, 3 Mar 2017 21:09:04 -0500
Subject: [PATCH 2/4] jekyll: fix 'jekyll new'

Original error:

$ nix-shell -p jekyll --command "jekyll new test"
Running bundle install in /private/tmp/test...
  Bundler: There was an error while trying to write to
  Bundler:
`/nix/store/l67429rhvrmr7c4c1msb7s8zjq4fx7ad-gemfile-and-lockfile/.bundle/config`.
  Bundler: It is likely that you need to grant write permissions for
that path.
---
 pkgs/development/ruby-modules/gem-config/default.nix | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/pkgs/development/ruby-modules/gem-config/default.nix b/pkgs/development/ruby-modules/gem-config/default.nix
index 20dc23979f5..6a83e079916 100644
--- a/pkgs/development/ruby-modules/gem-config/default.nix
+++ b/pkgs/development/ruby-modules/gem-config/default.nix
@@ -78,6 +78,15 @@ in
         [ darwin.apple_sdk.frameworks.CoreServices ];
   };
 
+  # disable bundle install as it can't install anything in addition to what is
+  # specified in pkgs/applications/misc/jekyll/Gemfile anyway
+  jekyll = attrs: {
+    postInstall = ''
+      installPath=$(cat $out/nix-support/gem-meta/install-path)
+      sed -i $installPath/lib/jekyll/commands/new.rb -e 's@Exec.run("bundle", "install"@Exec.run("true"@'
+    '';
+  };
+
   # note that you need version >= v3.16.14.8,
   # otherwise the gem will fail to link to the libv8 binary.
   # see: https://github.com/cowboyd/libv8/pull/161

From 3400c3575e7cad0fd8053a0ecd63962012af4773 Mon Sep 17 00:00:00 2001
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Date: Fri, 3 Mar 2017 21:23:34 -0500
Subject: [PATCH 3/4] jekyll: add gems needed to run default site

---
 pkgs/applications/misc/jekyll/Gemfile      |  2 ++
 pkgs/applications/misc/jekyll/Gemfile.lock |  6 ++++++
 pkgs/applications/misc/jekyll/gemset.nix   | 16 ++++++++++++++++
 3 files changed, 24 insertions(+)

diff --git a/pkgs/applications/misc/jekyll/Gemfile b/pkgs/applications/misc/jekyll/Gemfile
index 4074421fca3..97ebb9705bd 100644
--- a/pkgs/applications/misc/jekyll/Gemfile
+++ b/pkgs/applications/misc/jekyll/Gemfile
@@ -1,5 +1,7 @@
 source 'https://rubygems.org'
 gem 'jekyll'
+gem 'jekyll-feed'
 gem 'jekyll-paginate'
 gem 'rdiscount'
 gem 'RedCloth'
+gem 'minima'
diff --git a/pkgs/applications/misc/jekyll/Gemfile.lock b/pkgs/applications/misc/jekyll/Gemfile.lock
index fffc3316527..da4be83382f 100644
--- a/pkgs/applications/misc/jekyll/Gemfile.lock
+++ b/pkgs/applications/misc/jekyll/Gemfile.lock
@@ -18,6 +18,8 @@ GEM
       pathutil (~> 0.9)
       rouge (~> 1.7)
       safe_yaml (~> 1.0)
+    jekyll-feed (0.9.1)
+      jekyll (~> 3.3)
     jekyll-paginate (1.1.0)
     jekyll-sass-converter (1.5.0)
       sass (~> 3.4)
@@ -29,6 +31,8 @@ GEM
       rb-fsevent (~> 0.9, >= 0.9.4)
       rb-inotify (~> 0.9, >= 0.9.7)
     mercenary (0.3.6)
+    minima (2.1.0)
+      jekyll (~> 3.3)
     pathutil (0.14.0)
       forwardable-extended (~> 2.6)
     public_suffix (2.0.5)
@@ -46,7 +50,9 @@ PLATFORMS
 DEPENDENCIES
   RedCloth
   jekyll
+  jekyll-feed
   jekyll-paginate
+  minima
   rdiscount
 
 BUNDLED WITH
diff --git a/pkgs/applications/misc/jekyll/gemset.nix b/pkgs/applications/misc/jekyll/gemset.nix
index 0811f356582..5b1a35209ae 100644
--- a/pkgs/applications/misc/jekyll/gemset.nix
+++ b/pkgs/applications/misc/jekyll/gemset.nix
@@ -39,6 +39,14 @@
     };
     version = "3.4.1";
   };
+  jekyll-feed = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1dj62gy1jskkn703mi5h0bkg1psbpkdm2qqdw3bhjfid9358qvay";
+      type = "gem";
+    };
+    version = "0.9.1";
+  };
   jekyll-paginate = {
     source = {
       sha256 = "0r7bcs8fq98zldih4787zk5i9w24nz5wa26m84ssja95n3sas2l8";
@@ -93,6 +101,14 @@
     };
     version = "0.3.6";
   };
+  minima = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1s7ks9fqfvqx7qicnkrg76wavg9mjas52f7iyhr89lz9mqiy7p39";
+      type = "gem";
+    };
+    version = "2.1.0";
+  };
   pathutil = {
     source = {
       remotes = ["https://rubygems.org"];

From 212340bc6b893a9b947cb0ce68531dad75749ce8 Mon Sep 17 00:00:00 2001
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Date: Fri, 3 Mar 2017 23:05:37 -0500
Subject: [PATCH 4/4] jekyll: set proper permissions on new site

Fixes #22858
---
 pkgs/development/ruby-modules/gem-config/default.nix | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/pkgs/development/ruby-modules/gem-config/default.nix b/pkgs/development/ruby-modules/gem-config/default.nix
index 6a83e079916..5f1c29f164c 100644
--- a/pkgs/development/ruby-modules/gem-config/default.nix
+++ b/pkgs/development/ruby-modules/gem-config/default.nix
@@ -79,11 +79,14 @@ in
   };
 
   # disable bundle install as it can't install anything in addition to what is
-  # specified in pkgs/applications/misc/jekyll/Gemfile anyway
+  # specified in pkgs/applications/misc/jekyll/Gemfile anyway. Also do chmod_R
+  # to compensate for read-only files in site_template in nix store.
   jekyll = attrs: {
     postInstall = ''
       installPath=$(cat $out/nix-support/gem-meta/install-path)
-      sed -i $installPath/lib/jekyll/commands/new.rb -e 's@Exec.run("bundle", "install"@Exec.run("true"@'
+      sed -i $installPath/lib/jekyll/commands/new.rb \
+          -e 's@Exec.run("bundle", "install"@Exec.run("true"@' \
+          -e 's@FileUtils.cp_r site_template + "/.", path@FileUtils.cp_r site_template + "/.", path; FileUtils.chmod_R "u+w", path@'
     '';
   };