-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
111 lines (107 loc) · 3.07 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
{
inputs = {
# cargo2nix.url = "github:cargo2nix/cargo2nix/unstable";
# nixpkgs.follows = "cargo2nix/nixpkgs";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
devshell.url = "github:numtide/devshell";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs =
{
self,
crane,
flake-utils,
devshell,
nixpkgs,
rust-overlay,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
# cargo2nix.overlays.default
devshell.overlays.default
(import rust-overlay)
];
};
extraBuildInputs =
with pkgs;
[
libiconv
pkg-config
]
++ (
if stdenv.isDarwin then
with darwin.apple_sdk.frameworks;
[
IOKit
Security
CoreServices
SystemConfiguration
]
else
[
gcc
openssl
]
);
in
{
devShells.default = pkgs.devshell.mkShell {
imports = map pkgs.devshell.importTOML [ ./devshell.toml ];
packages = with pkgs; [ (rust-bin.stable.latest.complete) ] ++ extraBuildInputs;
env = [
{
name = "PKG_CONFIG_PATH";
value = "${pkgs.openssl.dev}/lib/pkgconfig";
}
];
};
packages =
let
craneLib = crane.mkLib nixpkgs.legacyPackages.${system};
sqlxFilter =
path: _type:
null != builtins.match ".*sql$" path
|| null != builtins.match ".*json$" path
|| null != builtins.match ".*env$" path;
common = {
version = "0.1";
# src = craneLib.path ./.;
src = pkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
filter = path: type: (sqlxFilter path type) || (craneLib.filterCargoSources path type);
};
strictDeps = true;
buildInputs = extraBuildInputs;
nativeBuildInputs = with pkgs; [ pkg-config ];
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
doCheck = false;
};
cargoArtifacts = craneLib.buildDepsOnly common;
in
rec {
webman-cli = craneLib.buildPackage (
common
// {
pname = "webman-cli";
cargoExtraArgs = "-p webman-cli";
}
);
webman-server = craneLib.buildPackage (
common
// {
pname = "webman-server";
cargoExtraArgs = "-p webman-server";
}
);
default = webman-cli;
};
}
);
}