summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix51
1 files changed, 51 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..28b7a60
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,51 @@
1{
2 description = "build rust binaries";
3
4 outputs = { self, nixpkgs }:
5 let
6 supportedSystems = [ "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ];
7 forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
8 nixpkgsFor = forAllSystems (system: import nixpkgs {
9 inherit system;
10 overlays = [ self.overlays.default ];
11 });
12 in
13 {
14
15 overlays.default = final: prev: {
16 rust-bin =
17 let
18 packageMeta = (final.lib.importTOML ./Cargo.toml).package;
19 in
20 final.rustPlatform.buildRustPackage {
21 pname = packageMeta.name;
22 inherit (packageMeta) version;
23 src = self;
24 cargoLock.lockFile = ./Cargo.lock;
25 };
26 };
27
28 packages = forAllSystems (system: {
29 inherit (nixpkgsFor."${system}") rust-bin;
30 });
31
32 defaultPackage = forAllSystems (system: self.packages."${system}".rust-bin);
33
34 devShell = forAllSystems (system:
35 let
36 pkgs = nixpkgsFor."${ system}";
37 in
38 pkgs.mkShell {
39 nativeBuildInputs = [
40 pkgs.rustc
41 pkgs.cargo
42 pkgs.rustfmt
43 pkgs.rust-analyzer
44 pkgs.cargo-watch
45 ];
46 RUST_BACKTRACE = 1;
47 }
48 );
49
50 };
51}