diff options
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..dcdf3b7 --- /dev/null +++ b/flake.nix | |||
@@ -0,0 +1,67 @@ | |||
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 { inherit system; }); | ||
31 | |||
32 | chanspec = { | ||
33 | date = "2022-02-06"; | ||
34 | channel = "nightly"; | ||
35 | sha256 = "oKkTWopCDx4tphzTtRn+zDDtvmIZrL/H44tV2ruSfDw="; # set zeros after modifying channel or date | ||
36 | }; | ||
37 | rustChannel = p: (fenix.overlay p p).fenix.toolchainOf chanspec; | ||
38 | |||
39 | in | ||
40 | { | ||
41 | |||
42 | |||
43 | devShell = forAllSystems (system: | ||
44 | let | ||
45 | pkgs = nixpkgsFor."${system}"; | ||
46 | toolchain = (rustChannel pkgs).withComponents [ | ||
47 | "rustc" | ||
48 | "cargo" | ||
49 | "rust-std" | ||
50 | "rustfmt" | ||
51 | "clippy" | ||
52 | "rust-src" | ||
53 | ]; | ||
54 | inherit (fenix.packages."${system}") rust-analyzer; | ||
55 | in | ||
56 | pkgs.mkShell { | ||
57 | nativeBuildInputs = [ | ||
58 | pkgs.bacon | ||
59 | pkgs.cargo-insta | ||
60 | rust-analyzer | ||
61 | toolchain | ||
62 | ]; | ||
63 | RUST_LOG = "info"; | ||
64 | RUST_BACKTRACE = 1; | ||
65 | }); | ||
66 | }; | ||
67 | } | ||