diff options
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..38bc205 --- /dev/null +++ b/flake.nix | |||
@@ -0,0 +1,97 @@ | |||
1 | { | ||
2 | inputs = { | ||
3 | |||
4 | nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; | ||
5 | |||
6 | fenix = { | ||
7 | url = "github:nix-community/fenix"; | ||
8 | inputs.nixpkgs.follows = "nixpkgs"; | ||
9 | }; | ||
10 | |||
11 | gitignore = { | ||
12 | url = "github:hercules-ci/gitignore.nix"; | ||
13 | inputs.nixpkgs.follows = "nixpkgs"; | ||
14 | }; | ||
15 | |||
16 | }; | ||
17 | |||
18 | outputs = | ||
19 | { self | ||
20 | , nixpkgs | ||
21 | , fenix | ||
22 | , gitignore | ||
23 | }: | ||
24 | let | ||
25 | inherit (gitignore.lib) gitignoreSource; | ||
26 | |||
27 | supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; | ||
28 | forAllSystems = nixpkgs.lib.genAttrs supportedSystems; | ||
29 | nixpkgsFor = forAllSystems (system: | ||
30 | import nixpkgs { | ||
31 | inherit system; | ||
32 | overlays = [ self.overlay ]; | ||
33 | }); | ||
34 | |||
35 | chanspec = { | ||
36 | date = "2022-02-06"; | ||
37 | channel = "nightly"; | ||
38 | sha256 = "oKkTWopCDx4tphzTtRn+zDDtvmIZrL/H44tV2ruSfDw="; # set zeros after modifying channel or date | ||
39 | }; | ||
40 | rustChannel = p: (fenix.overlay p p).fenix.toolchainOf chanspec; | ||
41 | |||
42 | in | ||
43 | { | ||
44 | |||
45 | overlay = final: prev: { | ||
46 | |||
47 | eva = with final; | ||
48 | let | ||
49 | pname = "eva"; | ||
50 | packageMeta = (lib.importTOML ./Cargo.toml).package; | ||
51 | rustPlatform = makeRustPlatform { | ||
52 | inherit (rustChannel final) cargo rustc; | ||
53 | }; | ||
54 | in | ||
55 | rustPlatform.buildRustPackage { | ||
56 | inherit pname; | ||
57 | inherit (packageMeta) version; | ||
58 | |||
59 | src = gitignoreSource ./.; | ||
60 | cargoLock.lockFile = ./Cargo.lock; | ||
61 | }; | ||
62 | |||
63 | }; | ||
64 | |||
65 | packages = forAllSystems (system: { | ||
66 | inherit (nixpkgsFor."${system}") eva; | ||
67 | }); | ||
68 | |||
69 | defaultPackage = | ||
70 | forAllSystems (system: self.packages."${system}".eva); | ||
71 | |||
72 | devShell = forAllSystems (system: | ||
73 | let | ||
74 | pkgs = nixpkgsFor."${system}"; | ||
75 | toolchain = (rustChannel pkgs).withComponents [ | ||
76 | "rustc" | ||
77 | "cargo" | ||
78 | "rust-std" | ||
79 | "rustfmt" | ||
80 | "clippy" | ||
81 | "rust-src" | ||
82 | ]; | ||
83 | inherit (fenix.packages."${system}") rust-analyzer; | ||
84 | in | ||
85 | pkgs.mkShell { | ||
86 | nativeBuildInputs = [ | ||
87 | pkgs.bacon | ||
88 | pkgs.cargo-insta | ||
89 | rust-analyzer | ||
90 | toolchain | ||
91 | ]; | ||
92 | RUST_LOG = "info"; | ||
93 | RUST_BACKTRACE = 1; | ||
94 | }); | ||
95 | |||
96 | }; | ||
97 | } | ||