-
Notifications
You must be signed in to change notification settings - Fork 83
/
flake.nix
101 lines (87 loc) · 3.25 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
{
inputs = {
nixpkgs = { url = "github:nixos/nixpkgs/nixos-23.11"; };
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flakebox = {
url = "github:dpc/flakebox?rev=226d584e9a288b9a0471af08c5712e7fac6f87dc";
inputs.nixpkgs.follows = "nixpkgs";
inputs.fenix.follows = "fenix";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flakebox, fenix, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
lib = pkgs.lib;
flakeboxLib =
flakebox.lib.${system} { config.flakebox.init.enable = false; };
rustSrc = flakeboxLib.filterSubPaths {
root = builtins.path {
name = "gossip";
path = ./.;
};
paths = [ "Cargo.toml" "Cargo.lock" ".cargo" "src" ];
};
toolchainArgs = let llvmPackages = pkgs.llvmPackages_11;
in {
extraRustFlags = "--cfg tokio_unstable";
components = [ "rustc" "cargo" "clippy" "rust-analyzer" "rust-src" ];
args = {
nativeBuildInputs = [ ]
++ lib.optionals (!pkgs.stdenv.isDarwin) [ ];
};
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
stdenv = pkgs.clang11Stdenv;
clang = llvmPackages.clang;
libclang = llvmPackages.libclang.lib;
clang-unwrapped = llvmPackages.clang-unwrapped;
};
# all standard toolchains provided by flakebox
toolchainsStd = flakeboxLib.mkStdFenixToolchains toolchainArgs;
toolchainsNative = (pkgs.lib.getAttrs [ "default" ] toolchainsStd);
toolchainNative =
flakeboxLib.mkFenixMultiToolchain { toolchains = toolchainsNative; };
commonArgs = {
buildInputs = [ ] ++ lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
pkgs.darwin.apple_sdk.frameworks.OpenGL
pkgs.darwin.apple_sdk.frameworks.AppKit
];
nativeBuildInputs = [ pkgs.pkg-config ];
};
outputs = (flakeboxLib.craneMultiBuild { toolchains = toolchainsStd; })
(craneLib':
let
craneLib = (craneLib'.overrideArgs {
pname = "flexbox-multibuild";
src = rustSrc;
}).overrideArgs commonArgs;
in rec {
workspaceDeps = craneLib.buildWorkspaceDepsOnly { };
workspaceBuild =
craneLib.buildWorkspace { cargoArtifacts = workspaceDeps; };
gossip = craneLib.buildPackageGroup {
pname = "gossip";
packages = [ "gossip-bin" "gossip-lib" ];
mainProgram = "gossip-bin";
};
});
in {
legacyPackages = outputs;
packages = { default = outputs.gossip; };
devShells = flakeboxLib.mkShells {
packages = [ ];
buildInputs = commonArgs.buildInputs;
nativeBuildInputs = [ ];
shellHook = ''
export RUSTFLAGS="--cfg tokio_unstable"
export RUSTDOCFLAGS="--cfg tokio_unstable"
export RUST_LOG="info"
'';
};
});
}