From 5711966f8b856f9b0a4326264b84d6e839588d8c Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 8 Dec 2016 20:01:13 +0100 Subject: Finish git-deploy --- default.nix | 9 ++++++- provider/posts/blog/git-deploy.md | 51 +++++++++++++++++++++++++++++++++++---- src/Site.hs | 2 +- 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/default.nix b/default.nix index d9d3c52..629f1bb 100644 --- a/default.nix +++ b/default.nix @@ -2,7 +2,14 @@ }: rec { - dirty-haskell = pkgs.stdenv.lib.overrideDerivation (pkgs.haskellPackages.callPackage ./blog.nix {}) + haskellPackages = pkgs.haskellPackages.override { + overrides = self : super : { + hakyll = pkgs.haskell.lib.overrideCabal super.hakyll (drv: { + doCheck = false; + }); + }; + }; + dirty-haskell = pkgs.stdenv.lib.overrideDerivation (haskellPackages.callPackage ./blog.nix {}) (attrs : { src = ./.; shellHook = '' diff --git a/provider/posts/blog/git-deploy.md b/provider/posts/blog/git-deploy.md index 14745a6..af4d29b 100644 --- a/provider/posts/blog/git-deploy.md +++ b/provider/posts/blog/git-deploy.md @@ -1,17 +1,58 @@ --- title: dirty-haskell.org´s git-based publication system +published: 2016-12-08 tags: Blog Software --- -Initially I set up dirty-haskell.org (which is currently powered by [hakyll]()) -to [rsync]() the results of compiling up onto my server whenever I intone +Initially I set up dirty-haskell.org (which is currently powered by [hakyll]) +to [rsync] the results of compiling up onto my server whenever I intone `dirty-haskell deploy`{.sh}. In my ever continuing quest to have my life consist mostly of an array of git repositories however this didn't seem satisfactory. -Therefore I configured my [gitolite]() instance to automatically compile und +Therefore I configured my [gitolite] instance to automatically compile und publish the current git version whenever I push to `master`. +Gitolite provides us with facilities to install [githooks]. Publishing will be +handled by `post-update`: + +~~~{.sh} +#!/usr/bin/env zsh + +touchedMaster=false + +for ref ($@); do + [[ ${ref} =~ .*/master$ ]] || continue + + touchedMaster=true + break +done + +$touchedMaster || exit 0 + +exec &>(logger --id=$$ -p daemon.info -t dirty-haskell) + +tmpDir=$(mktemp -d) +delTmpDir() { + cd / + rm -rvf ${tmpDir} +} + +trap delTmpDir EXIT + +git clone --branch master --depth 1 --single-branch . ${tmpDir} + +cd ${tmpDir} +nix-shell --run "dirty-haskell build" +nix-shell --run "dirty-haskell deploy" +~~~ + +The script checks if the master branch was moved to a new commit or otherwise +touched and, if so, clones a copy of the repo to a temporary directory and runs +hakyll´s deploy command in it, which is set to rsync the compiled version to a +folder where it´ll be picked up by nginx. + [hakyll]: https://jaspervdj.be/hakyll/ -[rsync]: -[gitolite]: +[rsync]: https://git.samba.org/rsync.git +[gitolite]: http://gitolite.com +[githooks]: http://githooks.com diff --git a/src/Site.hs b/src/Site.hs index 6aa50c9..607c33c 100644 --- a/src/Site.hs +++ b/src/Site.hs @@ -261,5 +261,5 @@ toFilePath' = (providerDirectory config ) . toFilePath config :: Configuration config = defaultConfiguration { providerDirectory = "provider" - , deployCommand = "rsync -av --progress -c --delete-delay -m _site/ gkleen@ymir.yggdrasil.li:/srv/www/dirty-haskell.org/" + , deployCommand = "rsync -av --progress -c --delete-delay -m _site/ /srv/www/dirty-haskell.org/" } -- cgit v1.2.3