-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
170 lines (150 loc) · 4.4 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
{
description = "A basic flake with a shell";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.android-nixpkgs.url = "github:tadfisher/android-nixpkgs";
inputs.naersk.url = "github:nix-community/naersk";
inputs.rust-overlay.url = "github:oxalica/rust-overlay";
outputs = {
self,
nixpkgs,
flake-utils,
android-nixpkgs,
rust-overlay,
naersk,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
config = {
android_sdk.accept_license = true;
};
overlays = [
(import rust-overlay)
(final: prev: {
rust-bin-wasm = prev.rust-bin.stable.latest.default.override {
targets = ["wasm32-unknown-unknown"];
};
})
(final: prev: {
rustPlatformWithWasm = prev.callPackage ({
makeRustPlatform,
rust-bin-wasm,
}:
makeRustPlatform {
rustc = rust-bin-wasm;
cargo = rust-bin-wasm;
}) {};
})
];
};
openapi-generator-cli = pkgs.fetchurl {
url = "https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.4.0/openapi-generator-cli-6.4.0.jar";
sha256 = "sha256-Na6tMA4MlGn72dMM9G9BU4l9yygpEgkcpOySEtzp0VE=";
};
naersk' = pkgs.callPackage naersk {
cargo = pkgs.rust-bin-wasm;
rustc = pkgs.rust-bin-wasm;
};
web = {
pkgs,
rustPlatformWithWasm,
trunk,
stdenv,
cargo,
wasm-bindgen-cli,
...
}:
stdenv.mkDerivation {
pname = "kabalist-web";
version = "master";
cargoDeps = rustPlatformWithWasm.importCargoLock {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = [
trunk
wasm-bindgen-cli
rustPlatformWithWasm.cargoSetupHook
rustPlatformWithWasm.cargoBuildHook
];
src = ./.;
XDG_CACHE_HOME = "/build/cache";
TRUNK_TOOLS_WASM_BINDGEN = "0.2.84";
buildPhase = ''
runHook preBuild
cd web
trunk build --release
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -R dist $out
runHook postInstall
'';
};
webPkg = pkgs.callPackage web {};
serverPkg = naersk'.buildPackage {
cargoBuildOptions = opts: opts ++ ["--package=kabalist_api"];
root = ./.;
postInstall = ''
mkdir -p $out/share
cp -r api/public $out/share
'';
};
in {
nixosModule = import ./nixos/kabalist.nix {
kabalist-web = webPkg;
kabalist-server = serverPkg;
};
packages = {
cli = naersk'.buildPackage {
cargoBuildOptions = opts: opts ++ ["--package=kabalist_cli"];
root = ./.;
postInstall = ''
mv $out/bin/kabalist_cli $out/bin/kabalist
'';
};
admin = naersk'.buildPackage {
cargoBuildOptions = opts: opts ++ ["--package=kb_admin"];
root = ./.;
};
server = serverPkg;
web = webPkg;
};
devShell = with pkgs;
mkShell rec {
nativeBuildInputs = [pkgs.bashInteractive];
DATABASE_URL = "postgres://traxys/list?host=/var/run/postgresql";
KABALIST_DATABASE_URL = DATABASE_URL;
LIST_URL = "http://localhost:8080";
buildInputs = [
# Flutter
(android-nixpkgs.sdk."${system}" (sdkPkgs:
with sdkPkgs; [
cmdline-tools-latest
build-tools-29-0-2
platform-tools
platforms-android-30
platforms-android-31
emulator
]))
flutter
jdk8
dart
(pkgs.writeShellApplication {
name = "openapi-generator-cli";
text = ''
${pkgs.jdk11}/bin/java -jar ${openapi-generator-cli} "$@"
'';
})
# Rust
rust-bin-wasm
# Web
trunk
wasm-bindgen-cli
# Docker
docker-compose
];
};
});
}