aboutsummaryrefslogtreecommitdiff
path: root/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix150
1 files changed, 48 insertions, 102 deletions
diff --git a/default.nix b/default.nix
index b0cb35c..60e879b 100644
--- a/default.nix
+++ b/default.nix
@@ -1,114 +1,60 @@
let
- pkgs = import (fetchTarball
- "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz") { };
- dicts = rec {
- mkDict = let
- prefix =
- "https://raw.githubusercontent.com/wooorm/dictionaries/61016e00e276f9bf5e52cbc6c02a45f2e49b2c7e/dictionaries";
- in { lang, dicSHA256, affSHA256 }:
- let
- dic = builtins.fetchurl {
- url = "${prefix}/${lang}/index.dic";
- sha256 = dicSHA256;
- };
- aff = builtins.fetchurl {
- url = "${prefix}/${lang}/index.aff";
- sha256 = affSHA256;
- };
- in pkgs.stdenv.mkDerivation {
- name = "songbooks-dict-${lang}";
- builder = builtins.toFile "builder.sh" ''
- source $stdenv/setup
- install -dm755 $out/share/hunspell
- install -m644 ${dic} $out/share/hunspell/${lang}.dic
- install -m644 ${aff} $out/share/hunspell/${lang}.aff
- runHook postInstall
- '';
- };
- en = mkDict {
- lang = "en";
- dicSHA256 = "1k4660ccwwpwac0rc7b8ih3vd24kxgvljkrakv2l1f72yfpw3bp2";
- affSHA256 = "0yvc2fhc03y0y1gwjyb20ifcrxnzm3ama1fri9r5gna092fz3qca";
- };
- pt = mkDict {
- lang = "pt";
- dicSHA256 = "1z0kfxv8m361xhp4zwdlsn2ib8q3rnljj0b2s4482alyxpd00h9x";
- affSHA256 = "1ssj1g7qwh0lv3ajzvchwsfr7cgzrlqms28m1j3gm1y2avi50qhw";
- };
- fr = mkDict {
- lang = "fr";
- dicSHA256 = "10p6jlk9j117mjd1z3dp3vfszcvxqha11kfvksqhvrq4ld9xwzbn";
- affSHA256 = "0d6k608h7gm1za3vdq1fhlwqzz2zxg1z0bx1bfvi0spg4a2mn09p";
- };
- };
- myHunspell = (pkgs.hunspellWithDicts (with dicts; [ en pt fr ]));
-in rec {
- utils = import ./utils.nix {
- pkgs = pkgs;
- src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
- baseName = "website";
- };
+ niv-sources = import ./nix/sources.nix;
+ pkgs = import niv-sources.nixpkgs { };
+ src = pkgs.nix-gitignore.gitignoreSource [ "!.git" ] ./.;
+ utils-i18n = pkgs.callPackage ./utils-i18n.nix { };
+
jekyllEnv = pkgs.bundlerEnv {
name = "jekyll-env";
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
gemset = ./gemset.nix;
};
- subtasks = rec {
- hunspellCheck = utils.baseTask.overrideAttrs (baseAttrs: {
- name = "${baseAttrs.name}-hunspell";
- buildInputs = baseAttrs.buildInputs ++ [ myHunspell ];
- buildPhase = ''
- patchShebangs .
- ./spelling/check-spelling.sh "${subtasks.docs}"
- touch $out
- '';
- });
- assertContent = utils.baseTask.overrideAttrs (baseAttrs: {
- name = "${baseAttrs.name}-assert-content";
- buildInputs = baseAttrs.buildInputs ++ [ pkgs.jq ];
- buildPhase = ''
- patchShebangs .
- ./scripts/assert-content.sh "${subtasks.docs}/site.json"
- touch $out
- '';
- });
- docs = utils.baseTask.overrideAttrs (baseAttrs: {
- name = "${baseAttrs.name}-docs";
- buildInputs = [ jekyllEnv ];
- buildPhase = ''
- patchShebangs .
- jekyll build -d $out
- '';
- });
- };
- test = utils.test [
- utils.formatNix
- (utils.shellcheck null)
- (utils.fixme [
- "utils.nix"
- "TODOs.org"
- "_pastebins/"
- "_posts/"
- "_tils/"
- "drafts/"
- "templates/"
- ])
- subtasks.hunspellCheck
- subtasks.assertContent
- subtasks.docs
+ projectBuildInputs = with pkgs; [
+ jekyllEnv
+
+ nixfmt
+ git
+ shellcheck
+ jq
+ niv
+ (hunspellWithDicts (with utils-i18n.dicts; [ en pt fr ]))
];
- shell = pkgs.mkShell rec {
- name = "website-shell";
- buildInputs = [ jekyllEnv myHunspell ];
+in rec {
+ site = pkgs.stdenv.mkDerivation {
+ inherit src;
+ name = "website-site";
+ phases = [ "unpackPhase" "buildPhase" ];
+ buildInputs = [ jekyllEnv ];
+ buildPhase = ''
+ patchShebangs .
+ jekyll build -d $out
+ '';
};
- publishScript = utils.overwritingPublishScript {
- docsDerivation = subtasks.docs;
- overwrite = true;
+ test = pkgs.stdenv.mkDerivation {
+ inherit src;
+ name = "website-test";
+ phases = [ "unpackPhase" "buildPhase" ];
+ buildInputs = projectBuildInputs;
+ buildPhase = ''
+ patchShebangs .
+ ./tests.sh
+ touch $out
+ '';
};
- fastPublishScript = utils.overwritingPublishScript {
- docsDerivation = subtasks.docs;
- overwrite = false;
+ shell = pkgs.mkShell rec {
+ name = "website-shell";
+ buildInputs = projectBuildInputs;
};
- site = subtasks.docs;
+ publishScript = pkgs.writeShellScriptBin "publish.sh" ''
+ set -euo pipefail
+ SERVER_URL='root@euandre.org'
+ REMOTE_PATH='/home/user-data/www/default/'
+ OUT_DOCS='${site}'
+ ${pkgs.openssh}/bin/ssh -o StrictHostKeyChecking=no "$SERVER_URL" rm -rf "$REMOTE_PATH/*"
+ ${pkgs.rsync}/bin/rsync -avzP \
+ --rsh="ssh -o StrictHostKeyChecking=no" \
+ "$OUT_DOCS/" \
+ "$SERVER_URL:$REMOTE_PATH"
+ '';
}