diff options
-rw-r--r-- | default.nix | 9 | ||||
-rw-r--r-- | provider/posts/blog/git-deploy.md | 51 | ||||
-rw-r--r-- | 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 @@ | |||
2 | }: | 2 | }: |
3 | 3 | ||
4 | rec { | 4 | rec { |
5 | dirty-haskell = pkgs.stdenv.lib.overrideDerivation (pkgs.haskellPackages.callPackage ./blog.nix {}) | 5 | haskellPackages = pkgs.haskellPackages.override { |
6 | overrides = self : super : { | ||
7 | hakyll = pkgs.haskell.lib.overrideCabal super.hakyll (drv: { | ||
8 | doCheck = false; | ||
9 | }); | ||
10 | }; | ||
11 | }; | ||
12 | dirty-haskell = pkgs.stdenv.lib.overrideDerivation (haskellPackages.callPackage ./blog.nix {}) | ||
6 | (attrs : | 13 | (attrs : |
7 | { src = ./.; | 14 | { src = ./.; |
8 | shellHook = '' | 15 | 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 @@ | |||
1 | --- | 1 | --- |
2 | title: dirty-haskell.org´s git-based publication system | 2 | title: dirty-haskell.org´s git-based publication system |
3 | published: 2016-12-08 | ||
3 | tags: Blog Software | 4 | tags: Blog Software |
4 | --- | 5 | --- |
5 | 6 | ||
6 | Initially I set up dirty-haskell.org (which is currently powered by [hakyll]()) | 7 | Initially I set up dirty-haskell.org (which is currently powered by [hakyll]) |
7 | to [rsync]() the results of compiling up onto my server whenever I intone | 8 | to [rsync] the results of compiling up onto my server whenever I intone |
8 | `dirty-haskell deploy`{.sh}. | 9 | `dirty-haskell deploy`{.sh}. |
9 | 10 | ||
10 | In my ever continuing quest to have my life consist mostly of an array of git | 11 | In my ever continuing quest to have my life consist mostly of an array of git |
11 | repositories however this didn't seem satisfactory. | 12 | repositories however this didn't seem satisfactory. |
12 | Therefore I configured my [gitolite]() instance to automatically compile und | 13 | Therefore I configured my [gitolite] instance to automatically compile und |
13 | publish the current git version whenever I push to `master`. | 14 | publish the current git version whenever I push to `master`. |
14 | 15 | ||
16 | Gitolite provides us with facilities to install [githooks]. Publishing will be | ||
17 | handled by `post-update`: | ||
18 | |||
19 | ~~~{.sh} | ||
20 | #!/usr/bin/env zsh | ||
21 | |||
22 | touchedMaster=false | ||
23 | |||
24 | for ref ($@); do | ||
25 | [[ ${ref} =~ .*/master$ ]] || continue | ||
26 | |||
27 | touchedMaster=true | ||
28 | break | ||
29 | done | ||
30 | |||
31 | $touchedMaster || exit 0 | ||
32 | |||
33 | exec &>(logger --id=$$ -p daemon.info -t dirty-haskell) | ||
34 | |||
35 | tmpDir=$(mktemp -d) | ||
36 | delTmpDir() { | ||
37 | cd / | ||
38 | rm -rvf ${tmpDir} | ||
39 | } | ||
40 | |||
41 | trap delTmpDir EXIT | ||
42 | |||
43 | git clone --branch master --depth 1 --single-branch . ${tmpDir} | ||
44 | |||
45 | cd ${tmpDir} | ||
46 | nix-shell --run "dirty-haskell build" | ||
47 | nix-shell --run "dirty-haskell deploy" | ||
48 | ~~~ | ||
49 | |||
50 | The script checks if the master branch was moved to a new commit or otherwise | ||
51 | touched and, if so, clones a copy of the repo to a temporary directory and runs | ||
52 | hakyll´s deploy command in it, which is set to rsync the compiled version to a | ||
53 | folder where it´ll be picked up by nginx. | ||
54 | |||
15 | [hakyll]: https://jaspervdj.be/hakyll/ | 55 | [hakyll]: https://jaspervdj.be/hakyll/ |
16 | [rsync]: | 56 | [rsync]: https://git.samba.org/rsync.git |
17 | [gitolite]: | 57 | [gitolite]: http://gitolite.com |
58 | [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 | |||
261 | 261 | ||
262 | config :: Configuration | 262 | config :: Configuration |
263 | config = defaultConfiguration { providerDirectory = "provider" | 263 | config = defaultConfiguration { providerDirectory = "provider" |
264 | , deployCommand = "rsync -av --progress -c --delete-delay -m _site/ gkleen@ymir.yggdrasil.li:/srv/www/dirty-haskell.org/" | 264 | , deployCommand = "rsync -av --progress -c --delete-delay -m _site/ /srv/www/dirty-haskell.org/" |
265 | } | 265 | } |