-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
117 lines (117 loc) · 3.62 KB
/
flake.nix
File metadata and controls
117 lines (117 loc) · 3.62 KB
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
{
description = "Immigrant: Database schema description language";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-25.11";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
shelly.url = "github:CertainLach/shelly";
};
outputs =
inputs@{
nixpkgs,
flake-parts,
shelly,
rust-overlay,
crane,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [ shelly.flakeModule ];
perSystem =
{
config,
system,
pkgs,
lib,
...
}:
let
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain rust;
sharedDeps = with pkgs; [
# PG parser
rustPlatform.bindgenHook
cmake
libpq
];
in
rec {
_module.args.pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
packages = let
root = ./.;
src = lib.fileset.toSource {
inherit root;
fileset = lib.fileset.unions [
(craneLib.fileset.commonCargoSources root)
(lib.fileset.fileFilter (file: file.hasExt "schema") root)
];
};
in {
default = packages.immigrant;
immigrant = craneLib.buildPackage {
pname = "immigrant";
inherit src;
strictDeps = true;
nativeBuildInputs = sharedDeps;
};
immigrant-web = let
craneLibWasm = craneLib.overrideToolchain (rust.override {
targets = [ "wasm32-unknown-unknown" ];
});
cargoArtifacts = craneLibWasm.buildDepsOnly {
inherit src;
pname = "immigrant-web-deps";
doCheck = false;
cargoExtraArgs = "--lib -p immigrant-web --target wasm32-unknown-unknown";
nativeBuildInputs = sharedDeps;
};
wasmLib = craneLibWasm.buildPackage {
inherit src cargoArtifacts;
pname = "immigrant-web";
doCheck = false;
cargoExtraArgs = "--lib -p immigrant-web --target wasm32-unknown-unknown";
nativeBuildInputs = sharedDeps;
installPhaseCommand = ''
mkdir -p $out/lib
cp target/wasm32-unknown-unknown/release/immigrant_web.wasm $out/lib/
'';
};
in pkgs.stdenv.mkDerivation {
pname = "immigrant-web";
version = "0.2.0";
dontUnpack = true;
nativeBuildInputs = [ pkgs.wasm-bindgen-cli ];
buildPhase = ''
wasm-bindgen ${wasmLib}/lib/immigrant_web.wasm \
--out-dir $out \
--target web \
--out-name web
'';
installPhase = "true";
};
};
shelly.shells.default = {
factory = craneLib.devShell;
packages =
with pkgs;
[
cargo-edit
just
]
++ sharedDeps;
};
formatter = pkgs.nixfmt;
};
};
}