This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
default.nix
78 lines (68 loc) · 1.75 KB
/
default.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
{ system ? builtins.currentSystem
, inputs ? import ./flake.lock.nix { }
}:
let
nixpkgs = import inputs.nixpkgs {
inherit system;
config = { };
overlays = [
(final: prev: {
fenix = import inputs.fenix {
pkgs = prev;
rust-analyzer-src = throw "not used";
};
})
];
};
rustToolchain = with nixpkgs.fenix;
combine [
minimal.rustc
minimal.cargo
targets."wasm32-unknown-unknown".latest.rust-std
];
# This is a magic shell that can be both built and loaded as a nix-shell.
mkShell = { name ? "shell", packages ? [ ], shellHook ? "" }:
let
drv = nixpkgs.buildEnv {
inherit name;
# TODO: also add the shellHook as an activation script?
paths = packages;
};
in
drv.overrideAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs ++ packages;
inherit shellHook;
});
cargoToml = with builtins; (fromTOML (readFile ./Cargo.toml));
in
rec {
inherit nixpkgs;
nixpkgs-fmt = nixpkgs.pkgs.rustPlatform.buildRustPackage {
inherit (cargoToml.package) name version;
src = nixpkgs.lib.cleanSource ./.;
doCheck = true;
cargoLock.lockFile = ./Cargo.lock;
};
# This used to be the output when we were using flake-compat.
defaultNix = nixpkgs-fmt;
devShell = mkShell {
packages = [
nixpkgs.cargo-fuzz
nixpkgs.gitAndTools.git-extras
nixpkgs.gitAndTools.pre-commit
nixpkgs.mdsh
nixpkgs.openssl
nixpkgs.pkgconfig
nixpkgs.stdenv.cc
nixpkgs.wasm-pack
rustToolchain
]
++ nixpkgs.lib.optionals nixpkgs.stdenv.isDarwin [
nixpkgs.darwin.apple_sdk.frameworks.Security
]
;
shellHook = ''
export PATH=$PWD/target/debug:$PATH
'';
};
}