-
Notifications
You must be signed in to change notification settings - Fork 12
/
flake.nix
100 lines (86 loc) · 3.21 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
};
outputs = { self, flake-utils, rust-overlay, crane, advisory-db, nixpkgs, }:
let
perSystemOutputs = flake-utils.lib.eachDefaultSystem (system:
let
pkgs = (import nixpkgs) {
inherit system;
overlays = [ (import rust-overlay) ];
};
inherit (pkgs) lib callPackage;
rustToolchain = callPackage ./nix/toolchain.nix { };
darwinFrameworks = with pkgs.darwin.apple_sdk.frameworks; [
Security
SystemConfiguration
];
devTools = [ rustToolchain ];
dependencies = with pkgs;
[ libiconv ]
++ lib.lists.optionals stdenv.isDarwin darwinFrameworks;
nativeBuildInputs = with pkgs; [ pkg-config ] ++ dependencies;
buildEnvVars = {
NIX_LDFLAGS = [ "-L" "${pkgs.libiconv}/lib" ];
OPENSSL_NO_VENDOR = 1;
};
buffrs = callPackage ./nix/buffrs.nix {
inherit crane advisory-db buildEnvVars nativeBuildInputs
rustToolchain;
buildInputs = [ rustToolchain ];
};
app = flake-utils.lib.mkApp { drv = buffrs.package; };
in {
# NB: if this does not build and you need to modify the file,
# please ensure you also make the corresponding changes in the devshell
packages.default = buffrs.package;
apps.default = app;
lib.vendorDependencies =
pkgs.callPackage ./nix/cache.nix { buffrs = buffrs.package; };
devShells.default = pkgs.mkShell ({
nativeBuildInputs = nativeBuildInputs ++ [ pkgs.protobuf ];
buildInputs = devTools ++ dependencies;
} // buildEnvVars);
formatter = with pkgs;
writeShellApplication {
name = "nixfmt-nix-files";
runtimeInputs = [ fd nixfmt-classic ];
text = "fd \\.nix\\$ --hidden --type f | xargs nixfmt";
};
checks = ({
nix-files-are-formatted = pkgs.stdenvNoCC.mkDerivation {
name = "fmt-check";
dontBuild = true;
src = ./.;
doCheck = true;
nativeBuildInputs = with pkgs; [ fd nixfmt-classic ];
checkPhase = ''
set -e
# find all nix files, and verify that they're formatted correctly
fd \.nix\$ --hidden --type f | xargs nixfmt -c
'';
installPhase = ''
mkdir "$out"
'';
};
} // buffrs.checks);
overlays.default = (_final: _prev: { buffrs = app; });
});
in perSystemOutputs // {
overlays.default = (final: _prev: {
buffrs = perSystemOutputs.packages.${final.stdenv.system}.default;
});
};
}