2020-11-07 17:29:47 +00:00
|
|
|
{ sources ? import ./nix/sources.nix, pkgs ? import sources.nixpkgs { } }:
|
|
|
|
with pkgs;
|
|
|
|
let
|
2020-11-17 19:05:59 +00:00
|
|
|
backend = callPackage ./backend { inherit sources pkgs; };
|
|
|
|
frontend = callPackage ./sina { inherit sources pkgs; };
|
|
|
|
gruvbox = callPackage sources.gruvbox-css { };
|
2020-11-07 17:29:47 +00:00
|
|
|
|
2020-11-17 19:05:59 +00:00
|
|
|
composite = stdenv.mkDerivation {
|
|
|
|
pname = "mi";
|
|
|
|
version = "${backend.version}";
|
|
|
|
phases = "installPhase";
|
2020-11-07 17:29:47 +00:00
|
|
|
|
2020-11-17 19:05:59 +00:00
|
|
|
installPhase = ''
|
|
|
|
# service binary
|
|
|
|
mkdir -p $out/bin
|
2020-11-07 17:29:47 +00:00
|
|
|
|
2020-11-17 19:05:59 +00:00
|
|
|
for file in ${backend}/bin/*; do
|
|
|
|
ln -s ${backend}/bin/$(basename $file) $out/bin/$(basename $file)
|
|
|
|
done
|
2020-11-07 17:29:47 +00:00
|
|
|
|
2020-11-17 19:05:59 +00:00
|
|
|
# static files
|
|
|
|
mkdir -p $out/public/
|
|
|
|
cp -vrf ${./static}/* $out/public
|
2020-11-07 17:29:47 +00:00
|
|
|
|
2020-11-17 19:05:59 +00:00
|
|
|
# frontend JS
|
2020-11-17 19:54:31 +00:00
|
|
|
rm $out/public/elm.js ||:
|
2020-11-17 19:05:59 +00:00
|
|
|
ln -s ${frontend}/Main.min.js $out/public/elm.js
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
wrapper = writeScriptBin "mi-backend" ''
|
|
|
|
#!${pkgs.stdenv.shell}
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
export RUST_LOG=info
|
|
|
|
export DATABASE_URL=./mi.db
|
|
|
|
export ROCKET_DATABASES='{ main_data = { url = "./mi.db" } }';
|
|
|
|
${composite}/bin/migrate_database
|
2021-01-06 20:52:14 +00:00
|
|
|
${composite}/bin/bridgy_migrate || true
|
2020-11-17 19:05:59 +00:00
|
|
|
export ROCKET_ASSET_PATH=${composite}/public
|
|
|
|
exec ${composite}/bin/mi
|
2020-11-07 17:29:47 +00:00
|
|
|
'';
|
2020-11-17 19:05:59 +00:00
|
|
|
in symlinkJoin {
|
|
|
|
name = "mi";
|
|
|
|
paths = [ wrapper composite ];
|
2020-11-07 17:29:47 +00:00
|
|
|
}
|