aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix101
1 files changed, 101 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..3f416a9
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,101 @@
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 = "2021-12-01";
37 channel = "nightly";
38 sha256 = "DhIP1w63/hMbWlgElJGBumEK/ExFWCdLaeBV5F8uWHc="; # 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 prompt = with final;
48 let
49 pname = "prompt";
50 packageMeta = (lib.importTOML ./bin/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 buildInputs = [
60 final.openssl
61 final.pkgconfig
62 ];
63
64 src = gitignoreSource ./.;
65 cargoLock.lockFile = ./Cargo.lock;
66 };
67
68 };
69
70 packages = forAllSystems (system: {
71 inherit (nixpkgsFor."${system}") prompt;
72 });
73
74 defaultPackage =
75 forAllSystems (system: self.packages."${system}".prompt);
76
77 devShell = forAllSystems (system:
78 let
79 pkgs = nixpkgsFor."${system}";
80 toolchain = (rustChannel pkgs).withComponents [
81 "rustc"
82 "cargo"
83 "rust-std"
84 "rustfmt"
85 "clippy"
86 "rust-src"
87 ];
88 inherit (fenix.packages."${system}") rust-analyzer;
89 in
90 pkgs.mkShell {
91 nativeBuildInputs = [
92 pkgs.bacon
93 rust-analyzer
94 toolchain
95 ];
96 RUST_LOG = "info";
97 RUST_BACKTRACE = 1;
98 });
99
100 };
101}