summary refs log tree commit diff
path: root/pkgs/applications/misc/jekyll/default.nix
blob: 54857d6142068e701222549e914054c7e50c4a81 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ lib, bundlerApp, ruby
, writeShellScriptBin, makeWrapper
, withOptionalDependencies ? false
}:

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 {
  pname = "jekyll";
  exes = [ "jekyll" ];

  inherit ruby;
  gemdir = if withOptionalDependencies
    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 = ''
      Jekyll is a simple, blog-aware, static site generator, written in Ruby.
      Think of it like a file-based CMS, without all the complexity. Jekyll
      takes your content, renders Markdown and Liquid templates, and spits out a
      complete, static website ready to be served by Apache, Nginx or another
      web server. Jekyll is the engine behind GitHub Pages, which you can use to
      host sites right from your GitHub repositories.
    '';
    homepage    = "https://jekyllrb.com/";
    #changelog   = "https://raw.githubusercontent.com/jekyll/jekyll/v${version}/History.markdown";
    license     = licenses.mit;
    maintainers = with maintainers; [ primeos pesterhazy ];
    platforms   = platforms.unix;
  };
}