-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
89 lines (71 loc) · 2.68 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
{
description = "abq";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
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};
certFilter = path: _type: (builtins.match ".*abq_utils/data/cert/server.crt$" path) != null;
certOrCargo = path: type:
(certFilter path type) || (craneLib.filterCargoSources path type);
assertVersion = version: pkg: (
assert (pkgs.lib.assertMsg (builtins.toString pkg.version == version) ''
Expecting version of ${pkg.name} to be ${version} but got ${pkg.version};
'');
pkg
);
buildInputs =
if pkgs.stdenv.isDarwin then [
(assertVersion "50" pkgs.libiconv)
(assertVersion "11.0.0" pkgs.darwin.apple_sdk.frameworks.Security)
] else [ ];
nativeBuildInputs = [ (assertVersion "2.40.1" pkgs.git) ];
abq =
craneLib.buildPackage
{
cargoToml = ./crates/abq_cli/Cargo.toml;
src = nixpkgs.lib.cleanSourceWith {
src = ./.;
filter = certOrCargo;
};
buildInputs = buildInputs;
nativeBuildInputs = nativeBuildInputs;
doCheck = false;
NIX_ABQ_VERSION = "0.${self.lastModifiedDate}.0+g${self.shortRev or "dirty"}";
};
in
{
checks = {
inherit abq;
};
packages.default = abq;
apps.default = flake-utils.lib.mkApp {
drv = abq;
};
# note, we have a dev shell working, but rust-analyzer doesn't totally work because of
# https://github.com/rust-lang/rust-analyzer/issues/13393
# so I wouldn't recommend using the nix dev shell until that's fixed
devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues self.checks;
# see: https://discourse.nixos.org/t/rust-src-not-found-and-other-misadventures-of-developing-rust-on-nixos/11570/3
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
# Extra inputs can be added here
nativeBuildInputs = with pkgs; [
(assertVersion "1.69.0" cargo)
(assertVersion "1.69.0" rustc)
(assertVersion "2023-05-15" rust-analyzer)
] ++ nativeBuildInputs ++ buildInputs;
};
formatter = pkgs.nixpkgs-fmt;
});
}