forked from BobaBoard/boba-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
59 lines (52 loc) · 1.99 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... } @ inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in {
packages = rec {
bobaserver-assets = pkgs.yarn2nix-moretea.mkYarnPackage {
name="boba-server";
version="0.0.1";
src = ./.;
dontFixup = true;
doDist = false;
buildPhase = ''
yarn build
'';
installPhase = ''
mkdir -p $out/libexec/bobaserver
mv node_modules $out/libexec/bobaserver/
mv deps $out/libexec/bobaserver/
'';
};
bobadatabase-init = pkgs.writeShellApplication {
name = "bobadatabase-init";
runtimeInputs = [ pkgs.postgresql_12 ];
text = ''
${bobaserver-assets}/libexec/bobaserver/deps/bobaserver/db/00-init_tables.sh ${bobaserver-assets}/libexec/bobaserver/deps/bobaserver/db/
'';
};
bobadatabase-seed = pkgs.writeShellApplication {
name = "bobadatabase-seed";
runtimeInputs = [ pkgs.postgresql_12 ];
text = ''
${bobaserver-assets}/libexec/bobaserver/deps/bobaserver/db/10-init_data.sh ${bobaserver-assets}/libexec/bobaserver/deps/bobaserver/db/
'';
};
# TODO: swap with wrapProgram
bobaserver = pkgs.writeShellScriptBin "bobaserver" ''
export NODE_PATH=${bobaserver-assets}/libexec/bobaserver/node_modules
export DEBUG=bobaserver:*,-*info
export NODE_ENV=production
exec ${pkgs.nodejs}/bin/node -r dotenv/config ${bobaserver-assets}/libexec/bobaserver/node_modules/bobaserver/dist/server/index.js
'';
default = bobaserver;
};
}
);
}