aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix102
1 files changed, 58 insertions, 44 deletions
diff --git a/flake.nix b/flake.nix
index 4f69fe8..50f9efc 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,6 +1,5 @@
1{ 1{
2 inputs = { 2 inputs = {
3
4 nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; 3 nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
5 4
6 gitignore = { 5 gitignore = {
@@ -9,55 +8,70 @@
9 }; 8 };
10 9
11 rust-overlay = { 10 rust-overlay = {
12 url = "github:oxalica/rust-overlay"; 11 url = "github:oxalica/rust-overlay";
13 inputs.nixpkgs.follows = "nixpkgs"; 12 inputs.nixpkgs.follows = "nixpkgs";
14 }; 13 };
15
16 }; 14 };
17 15
18 outputs = 16 outputs = {
19 { self 17 self,
20 , nixpkgs 18 nixpkgs,
21 , gitignore 19 gitignore,
22 , rust-overlay 20 rust-overlay,
23 }: 21 }: let
24 let 22 inherit (gitignore.lib) gitignoreSource;
25 inherit (gitignore.lib) gitignoreSource; 23
26 24 supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
27 supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; 25 forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
28 forAllSystems = nixpkgs.lib.genAttrs supportedSystems; 26 nixpkgsFor = forAllSystems (system:
29 nixpkgsFor = forAllSystems (system:
30 import nixpkgs { 27 import nixpkgs {
31 inherit system; 28 inherit system;
32 overlays = [rust-overlay.overlays.default]; 29 overlays = [rust-overlay.overlays.default self.overlays.default];
33 }); 30 });
31 in {
32 overlays.default = final: prev: {
33 tbsp = with final; let
34 pname = "tbsp";
35 packageMeta = (lib.importTOML ./Cargo.toml).package;
36 rustPlatform = makeRustPlatform {
37 inherit (final) cargo rustc;
38 };
39 in
40 rustPlatform.buildRustPackage {
41 inherit pname;
42 inherit (packageMeta) version;
34 43
35 in 44 src = self;
36 { 45 cargoLock.lockFile = ./Cargo.lock;
37 46
38 devShell = forAllSystems (system: 47 meta = with lib; {
39 let 48 description = "tree-based source processing language";
40 pkgs = nixpkgsFor."${system}"; 49 homepage = "https://git.peppe.rs/languages/tbsp/about";
41 in 50 license = licenses.mit;
42 pkgs.mkShell { 51 };
43 nativeBuildInputs = [ 52 };
44 pkgs.cargo-watch
45 pkgs.bacon
46 pkgs.rustfmt
47 pkgs.cargo
48
49 pkgs.rust-bin.nightly.latest.default
50 pkgs.rust-bin.nightly.latest.rust-analyzer
51 pkgs.lld
52 pkgs.trunk
53
54
55 pkgs.mermaid-cli
56 ];
57 RUST_LOG = "info";
58 RUST_BACKTRACE = 1;
59 });
60 }; 53 };
61}
62 54
55 defaultPackage = forAllSystems (system: nixpkgsFor."${system}".tbsp);
56 formatter = forAllSystems (system: nixpkgsFor."${system}".alejandra);
63 57
58 devShell = forAllSystems (system: let
59 pkgs = nixpkgsFor."${system}";
60 in
61 pkgs.mkShell {
62 nativeBuildInputs = [
63 pkgs.cargo-watch
64 pkgs.bacon
65 pkgs.rustfmt
66 pkgs.cargo
67
68 pkgs.rust-bin.nightly.latest.default
69 pkgs.rust-bin.nightly.latest.rust-analyzer
70
71 pkgs.mermaid-cli
72 ];
73 RUST_LOG = "info";
74 RUST_BACKTRACE = 1;
75 });
76 };
77}