diff options
author | EuAndreh <eu@euandre.org> | 2018-12-24 07:33:40 -0200 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2018-12-24 07:33:40 -0200 |
commit | 3ae13a308db8e1408d50975d6cd2c20dcaea2eb0 (patch) | |
tree | 247dd699d000406cf3e023452b4c0421ad26dcb2 /default.nix | |
parent | Remove =all= target from Makefile. (diff) | |
download | euandre.org-3ae13a308db8e1408d50975d6cd2c20dcaea2eb0.tar.gz euandre.org-3ae13a308db8e1408d50975d6cd2c20dcaea2eb0.tar.xz |
Build and publish website using Nix; remove Makefile.
Diffstat (limited to 'default.nix')
-rw-r--r-- | default.nix | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/default.nix b/default.nix index 0d7fee0..7b297d2 100644 --- a/default.nix +++ b/default.nix @@ -1,11 +1,9 @@ let pkgsOriginal = import <nixpkgs> {}; - pkgsSrc = pkgsOriginal.fetchzip { - url = "https://github.com/NixOS/nixpkgs/archive/18.03.zip"; - sha256 = "0hk4y2vkgm1qadpsm4b0q1vxq889jhxzjx3ragybrlwwg54mzp4f"; - }; - pkgs = import (pkgsSrc) {}; - stdenv = pkgs.stdenv; + pkgs = import (pkgsOriginal.fetchzip { + url = "https://github.com/NixOS/nixpkgs/archive/dd6b4b7078d89decabefc6b1a698327db132fbfe.zip"; + sha256 = "1cs5vibi2gab8i9m317v1b1spvmm2ppad8pxpkkp64fp1s3q6zy9"; + }) {}; # Taken from: # http://www.cs.yale.edu/homes/lucas.paul/posts/2017-04-10-hakyll-on-nix.html @@ -21,17 +19,40 @@ let ghc -O2 -dynamic --make Main.hs -o $out/bin/build-site ''; }; -in stdenv.mkDerivation rec { - name = "euandreh-website"; - src = ./site; - phases = "unpackPhase buildPhase"; - buildInputs = [ websiteBuilder ]; - buildPhase = '' - export LOCALE_ARCHIVE="${pkgs.glibcLocales}/lib/locale/locale-archive"; - export LANG=en_US.UTF-8 - build-site build +in with pkgs; with pkgs.stdenv; rec { + build = mkDerivation rec { + name = "website"; + src = ./site; + phases = "unpackPhase buildPhase"; + buildInputs = [ websiteBuilder ]; + buildPhase = '' + export LOCALE_ARCHIVE="${pkgs.glibcLocales}/lib/locale/locale-archive"; + export LANG=en_US.UTF-8 + build-site build - mkdir $out - cp -r _site/* $out + mkdir $out + cp -r _site/* $out + ''; + }; + shell = mkShell rec { + # See also the reference documentation: + # https://nixos.org/nixpkgs/manual/#sec-pkgs-mkShell + name = "website-shell"; + buildInputs = [ + websiteBuilder + (pkgs.haskellPackages.ghcWithPackages (p: with p; [ hakyll ])) + ]; + }; + publishScript = pkgs.writeShellScriptBin "publish.sh" '' + set -euo pipefail + ${pkgs.rsync}/bin/rsync --verbose \ + --copy-links \ + --progress \ + --stats \ + --update \ + --recursive \ + --rsh="ssh -o StrictHostKeyChecking=no" \ + ${build}/ \ + "$SERVER_URL:$DOCS_SERVER_PATH" ''; } |