Skip to content

Instantly share code, notes, and snippets.

@cleverca22
Last active August 20, 2022 11:51
Show Gist options
  • Save cleverca22/53eaea9a0f141f17d7fef17aa51d2703 to your computer and use it in GitHub Desktop.
Save cleverca22/53eaea9a0f141f17d7fef17aa51d2703 to your computer and use it in GitHub Desktop.
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
inherit (lib) optional optionals;
erlang = pkgs.beam.interpreters.erlangR24;
elixir = pkgs.beam.packages.erlangR24.elixir_1_13;
nodejs = pkgs.nodejs-18_x;
sass_version = "1.53.0";
sass_src = fetchurl {
url = "https://github.com/sass/dart-sass/releases/download/${sass_version}/dart-sass-${sass_version}-linux-x64.tar.gz";
sha256 = "MXSHrU96WHQMNgxKPPyHdIl8+wXI2KL7cNvDsWZoZKI=";
};
in
lib.fix (self: {
app = stdenv.mkDerivation {
name = "frontend";
buildInputs = [
cacert
erlang
elixir
file
nodejs
rebar3
inotify-tools
cargo
imagemagick
texlive.combined.scheme-full
];
shellHook = ''
: ''${PGPORT:=5432}
: ''${PGDATABASE:=questionaires_dev}
# this allows mix to work on the local directory
mkdir -p .nix-mix
mkdir -p .nix-hex
export MIX_HOME=$PWD/.nix-mix
export HEX_HOME=$PWD/.nix-hex
export PATH=$MIX_HOME/bin:$PATH
export PATH=$HEX_HOME/bin:$PATH
export LANG=en_US.UTF-8
export ERL_AFLAGS="-kernel shell_history enabled"
if [ ! -d .sass ]; then
echo "Unpack sass..."
mkdir .sass
tar -C .sass -xf ${sass_src}
fi
export LD_LIBRARY_PATH=$PWD/.sass/dart-sass/
export MIX_SASS_PATH=$PWD/.sass/dart-sass/sass
export MIX_SASS_VERSION=${sass_version}
export RUSTLER_NIF_VERSION=2.14
createdb -Upostgres $PGDATABASE 2>/dev/null
if [ $? -eq 0 ]; then
echo "importing test/questionaires.sql..."
psql -Upostgres $PGDATABASE < test/questionaires.sql
fi
alias psql="psql -Upostgres $PGDATABASE"
unset SSH_ASKPASS
'';
};
dockerImage = dockerTools.buildLayeredImage {
name = "frontend";
tag = environment;
maxLayers = 100;
config = { Cmd = [ startRunit ]; };
contents = [ self.foo ];
};
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment