-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
64 lines (57 loc) · 1.51 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
60
61
62
63
64
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.nix-filter.url = "github:numtide/nix-filter";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = {
self,
nixpkgs,
nix-filter,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem
(system: let
pkgs = import nixpkgs {
inherit system;
};
src = nix-filter.lib.filter {
root = ./.;
include = [
"public"
"src"
./package.json
./package-lock.json
./tsconfig.json
];
};
mkFrontend = REACT_APP_SERVER_URL:
pkgs.buildNpmPackage {
inherit REACT_APP_SERVER_URL src;
pname = "patron-ui";
version = "0.1.0";
npmDepsHash = "sha256-51VY9tb/e8xx2EQxh8ewyfdBi2NfdBoilshaOf1ABLw=";
installPhase = ''
cp -r build $out
'';
};
in {
formatter = pkgs.alejandra;
lib = {
inherit mkFrontend;
};
packages = {
development = mkFrontend "http://localhost:3000";
production = mkFrontend "https://api.patron.works";
};
apps.default = flake-utils.lib.mkApp {
drv = let
root = self.packages.${system}.development;
in pkgs.writeShellScriptBin "dev-server" ''
${pkgs.lib.getExe pkgs.static-web-server} \
--port 8080 \
--root ${root} \
--page-fallback ${root}/index.html \
--log-level info
'';
};
});
}