unified nix build

This commit is contained in:
Cadey Ratio 2020-11-07 12:29:47 -05:00
parent 4d837da7a7
commit 80cd181f0a
2 changed files with 39 additions and 8 deletions

View File

@ -9,12 +9,10 @@ let
src = builtins.filterSource
(path: type: type != "directory" || builtins.baseNameOf path != "target")
./.;
in {
backend = naersk.buildPackage {
name = "mi_backend";
inherit src;
buildInputs = with pkgs; [ openssl pkg-config sqlite libsodium ];
SODIUM_USE_PKG_CONFIG = "1";
SODIUM_SHARED = "1";
};
in naersk.buildPackage {
name = "mi_backend";
inherit src;
buildInputs = with pkgs; [ openssl pkg-config sqlite libsodium ];
SODIUM_USE_PKG_CONFIG = "1";
SODIUM_SHARED = "1";
}

33
default.nix Normal file
View File

@ -0,0 +1,33 @@
{ sources ? import ./nix/sources.nix, pkgs ? import sources.nixpkgs { } }:
with pkgs;
let
backend = pkgs.callPackage ./backend { inherit sources pkgs; };
frontend = pkgs.callPackage ./frontend { inherit sources pkgs; };
gruvbox = pkgs.callPackage sources.gruvbox-css { };
in stdenv.mkDerivation {
pname = "mi";
version = "${backend.version}";
phases = "installPhase";
installPhase = ''
# service binary
mkdir -p $out/bin
for file in ${backend}/bin/*; do
ln -s ${backend}/bin/$(${coreutils}/bin/basename $file) $out/bin/$(${coreutils}/bin/basename $file)
done
# frontend JS
mkdir -p $out/public/js
ln -s ${frontend}/Main.js $out/public/js/Main.js
# static files
cp -vrf ${./static}/* $out/public
mkdir -p $out/public/css
ln -s ${gruvbox}/gruvbox.css $out/public/css/gruvbox.css
# migrations
ln -s ${./backend/migrations} $out/migrations
'';
}