Nixify build for Chord Drill Sergeant

Thankfully @tazjin builds Gemma (an Elm project) with Nix, so I could reference
Gemma's default.nix to help me with mine. Elm problematically attempts to
HTTP-fetch a list of packages to verify my project's dependencies. Because Nix
builds derivations in a sandbox without network access, I need to use some
escape hatches (i.e. NIX_REDIRECTS, LD_PRELOAD,
SYSTEM_CERTIFICATE_PATH). Welp... it's packaged now...

I'm also pointing learnpianochords.app to this project's index.html. It will be
live soon! :)

TODO(wpcarro): Rename "Chord Drill Sergeant" -> "Learn Piano Chords" (KISS)
This commit is contained in:
William Carroll 2020-04-17 15:08:38 +01:00
parent bdb16c11ba
commit 277ad983d4
3 changed files with 30 additions and 1 deletions

View file

@ -177,6 +177,11 @@ in {
enableACME = true;
root = briefcase.website.sandbox;
};
"learnpianochords.app" = {
addSSL = true;
enableACME = true;
root = briefcase.website.sandbox.chord-drill-sergeant;
};
};
};

View file

@ -0,0 +1,24 @@
{ pkgs, ... }:
pkgs.stdenv.mkDerivation {
name = "learn-piano-chords";
src = ./.;
buildInputs = with pkgs; [
elmPackages.elm
nodejs
];
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = "0diya7q8ird56jsbf2p49fyvldsay6m9z251zr2rq1i4qs7idy0j";
phases = [ "unpackPhase" "buildPhase" ];
buildPhase = ''
export NIX_REDIRECTS=/etc/protocols=${pkgs.iana-etc}/etc/protocols
export LD_PRELOAD=${pkgs.libredirect}/lib/libredirect.so
export SYSTEM_CERTIFICATE_PATH=${pkgs.cacert}/etc/ssl/certs
mkdir -p $out
cp index.html $out
elm make src/Main.elm --optimize --output=$out/elm.js
npx tailwindcss build index.css -o $out/output.css
'';
}

View file

@ -123,7 +123,7 @@ init =
, whitelistedKeys = keys
, selectedChord = Nothing
, isPaused = True
, tempo = 30
, tempo = 20
, firstNote = firstNote
, lastNote = lastNote
, view = Preferences