aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.build.yml12
-rw-r--r--Makefile79
-rw-r--r--TODOs.org3
-rw-r--r--default.nix55
-rw-r--r--env.sh2
-rw-r--r--shell.nix1
6 files changed, 52 insertions, 100 deletions
diff --git a/.build.yml b/.build.yml
index 712fbbf..479e6af 100644
--- a/.build.yml
+++ b/.build.yml
@@ -1,4 +1,6 @@
image: debian/stretch
+packages:
+ - curl
triggers:
- condition: failure
action: email
@@ -8,9 +10,11 @@ sources:
secrets:
- 7159f943-811f-402d-bb6d-37cd764dc728
tasks:
- - build: |
- cd website/
- make build
+ - setup : |
+ curl https://nixos.org/nix/install | sh
+ echo '. $HOME/.nix-profile/etc/profile.d/nix.sh' >> $HOME/.buildenv
- publish: |
cd website/
- make publish
+ nix-build -A publishScript
+ source env.sh
+ ./result/bin/publish.sh
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 2f88ee5..0000000
--- a/Makefile
+++ /dev/null
@@ -1,79 +0,0 @@
-SHELL := /usr/bin/env bash
-.DEFAULT_GOAL := help
-.RECIPEPREFIX +=
-
-## Build full website.
-build:
- nix-build
-.PHONY: build
-
-## Remove all files not tracked by git.
-clean:
- git clean -fdx
-.PHONY: clean
-
-## Sync all static files to server with rsync.
-publish:
- rsync --verbose --copy-links --progress --stats --update --recursive result/ root@euandre.org:/home/user-data/www/default
-.PHONY: publish
-
-## Create a new pastebin file from the template.
-pastebin:
- @./pastebin/new.sh
-.PHONY: pastebin
-
-# Taken from https://gist.github.com/klmr/575726c7e05d8780505a
-
-# Inspired by <http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html>
-# sed script explained:
-# /^##/:
-# * save line in hold space
-# * purge line
-# * Loop:
-# * append newline + line to hold space
-# * go to next line
-# * if line starts with doc comment, strip comment character off and loop
-# * remove target prerequisites
-# * append hold space (+ newline) to line
-# * replace newline plus comments by `---`
-# * print line
-# Separate expressions are necessary because labels cannot be delimited by
-# semicolon; see <http://stackoverflow.com/a/11799865/1968>
-help:
- @echo "$$(tput bold)Available rules:$$(tput sgr0)"
- @echo
- @sed -n -e "/^## / { \
- h; \
- s/.*//; \
- :doc" \
- -e "H; \
- n; \
- s/^## //; \
- t doc" \
- -e "s/:.*//; \
- G; \
- s/\\n## /---/; \
- s/\\n/ /g; \
- p; \
- }" ${MAKEFILE_LIST} \
- | LC_ALL='C' sort --ignore-case \
- | awk -F '---' \
- -v ncol=$$(tput cols) \
- -v indent=19 \
- -v col_on="$$(tput setaf 6)" \
- -v col_off="$$(tput sgr0)" \
- '{ \
- printf "%s%*s%s ", col_on, -indent, $$1, col_off; \
- n = split($$2, words, " "); \
- line_length = ncol - indent; \
- for (i = 1; i <= n; i++) { \
- line_length -= length(words[i]) + 1; \
- if (line_length <= 0) { \
- line_length = ncol - indent - length(words[i]) - 1; \
- printf "\n%*s ", -indent, " "; \
- } \
- printf "%s ", words[i]; \
- } \
- printf "\n"; \
- }' \
-| more $(shell test $(shell uname) == Darwin && echo '--no-init --raw-control-chars')
diff --git a/TODOs.org b/TODOs.org
index 574bd2f..7cd1688 100644
--- a/TODOs.org
+++ b/TODOs.org
@@ -5,3 +5,6 @@ https://joelkuiper.eu/spellcheck_emacs
=rsync= isn't sending new versions of existing files to the server.
** TODO Add articles teaser to homepage
https://jaspervdj.be/hakyll/tutorials/using-teasers-in-hakyll.html
+* CI
+** Improvements
+*** Use NixOS instead of Debian?
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"
'';
}
diff --git a/env.sh b/env.sh
new file mode 100644
index 0000000..c212ec3
--- /dev/null
+++ b/env.sh
@@ -0,0 +1,2 @@
+export SERVER_URL=root@euandre.org
+export DOCS_SERVER_PATH="/home/user-data/www/default/"
diff --git a/shell.nix b/shell.nix
new file mode 100644
index 0000000..af299aa
--- /dev/null
+++ b/shell.nix
@@ -0,0 +1 @@
+(import ./default.nix).shell