Last active
November 14, 2019 03:15
-
-
Save heathdrobertson/67601264548a648a6299c85f496decf3 to your computer and use it in GitHub Desktop.
Setting up a Jekyll Static Website for GitHub Pages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> {}; | |
stdenv.mkDerivation { | |
name = "base-jekyll-builder"; | |
buildInputs = [ | |
ruby | |
jekyll | |
nodejs | |
]; | |
shellHook = '' | |
jekyll new blog | |
cp post.nix blog/ | |
cd blog/ | |
bundler package --no-install --path vendor | |
rm -rf .bundler/ vendor/ | |
$(nix-build '<nixpkgs>' -A bundix)/bin/bundix | |
rm result | |
cd ../ && chown -R 1000:1000 blog/ && chmod -R 777 blog/ | |
''; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> { }; | |
let jekyll_env = bundlerEnv rec { | |
name = "jekyll_env"; | |
inherit ruby; | |
gemfile = ./Gemfile; | |
lockfile = ./Gemfile.lock; | |
gemset = ./gemset.nix; | |
}; | |
in | |
stdenv.mkDerivation rec { | |
name = "jekyll_env"; | |
buildInputs = [ jekyll_env bundler ruby ]; | |
shellHook = '' | |
export LANG=C.UTF-8 | |
exec ${jekyll_env}/bin/jekyll serve --watch --host 0.0.0.0 --port 4000 | |
''; | |
} | |
###### | |
#NOTES | |
###### | |
# post.nix generates a local environment for updating a Jekyll website, hosted on GitHub Pages. | |
# This file borrows heavily from: | |
# http://stesie.github.io/2016/08/nixos-github-pages-env | |
# This line is to prevent a sass compile error, generated because the NixOs Docker image is built on Alpine Linux and locales are not installed by default: | |
# export LANG=C.UTF-8 | |
# Alternatively: | |
# Add -e=LANG C.UTF-8 or --env-file=env.list to your docker run command. | |
# Add LANG=C.UTF-8 to your docker env.list file | |
# docker run --rm --volumes-from=nix -it -v=$(pwd):/home -w=/home --ip=localhost -p=4000:4000 nixos/nix nix-shell /home/post.nix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> {}; | |
stdenv.mkDerivation { | |
name = "base-jekyll-builder"; | |
buildInputs = [ | |
ruby | |
jekyll | |
nodejs | |
]; | |
shellHook = '' | |
chown -R 1000:1000 blog/ && chmod -R 777 blog/ | |
cd blog/ | |
bundler package --no-install --path vendor | |
rm -rf .bundle/ vendor/ | |
$(nix-build '<nixpkgs>' -A bundix)/bin/bundix | |
rm result | |
cd ../ && chown -R 1000:1000 blog/ && chmod -R 777 blog/ | |
''; | |
} | |
###### | |
#NOTES | |
###### | |
# update.nix is used to rebuild the Jekyll environment after updates to _config.yml or Gemfile. | |
# This file borrows heavily from: http://stesie.github.io/2016/08/nixos-github-pages-env | |
# docker run --rm --volumes-from=nix -it -v=$(pwd):/home -w=/home nixos/nix nix-shell /home/update.nix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment