-
Notifications
You must be signed in to change notification settings - Fork 5
/
flake.nix
62 lines (54 loc) · 1.54 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, crane, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
craneLib = crane.lib.${system};
my-crate = craneLib.buildPackage {
src = craneLib.cleanCargoSource (craneLib.path ./.);
buildInputs = [
pkgs.openssl
pkgs.zlib
pkgs.sqlite
pkgs.gcc
pkgs.pkg-config
pkgs.diesel-cli
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.libiconv
];
};
in
{
packages.default = my-crate;
devShells.default = craneLib.devShell {
inputsFrom = [ my-crate ];
packages = [
pkgs.cargo-audit
pkgs.cargo-watch
pkgs.openssl
pkgs.zlib
pkgs.sqlite
pkgs.gcc
pkgs.pkg-config
pkgs.rust-analyzer
pkgs.diesel-cli
];
shellHook = ''
export LD_LIBRARY_PATH=${pkgs.openssl}/lib:$LD_LIBRARY_PATH
export DATABASE_URL=database.db
# Only copy config.yaml to if it doesn't already exist
[ ! -e local.config.yaml ] && cp config.yaml local.config.yaml
'';
};
});
}