-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
executable file
·134 lines (116 loc) · 3.37 KB
/
Copy pathflake.nix
File metadata and controls
executable file
·134 lines (116 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{
description = "The Llama Programming Language";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
};
outputs = {
self,
nixpkgs,
flake-utils,
rust-overlay,
crane,
advisory-db,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {inherit system overlays;};
inherit (pkgs) lib;
craneLib =
(crane.mkLib pkgs)
.overrideToolchain
(pkgs.rust-bin.stable.latest.default.override
{extensions = ["rust-src" "rust-analyzer"];});
src = craneLib.cleanCargoSource ./.;
commonArgs = {
inherit src;
strictDeps = true;
buildInputs = [];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
individualCrateArgs =
commonArgs
// {
inherit cargoArtifacts;
inherit (craneLib.crateNameFromCargoToml {inherit src;}) version;
doCheck = true;
};
llamacFileset = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./Cargo.toml
./Cargo.lock
./crates/llamac_ast
./crates/llamac_codegen_r6rs
./crates/llamac_parser
./crates/llamac_sexpr_fmt
./crates/llamac_typecheck
./crates/llamac_typed_ast
./crates/llamac_utils
./crates/llamac
];
};
llamac = craneLib.buildPackage (individualCrateArgs
// {
pname = "llamac";
cargoExtraArgs = "-p llamac";
buildInputs = [pkgs.racket];
src = llamacFileset;
});
in {
checks = {
inherit llamac;
llama-workspace-clippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
}
);
llama-workspace-doc = craneLib.cargoDoc (commonArgs
// {
inherit cargoArtifacts;
env.RUSTDOCFLAGS = "--deny warnings";
});
llama-workspace-fmt = craneLib.cargoFmt {inherit src;};
llama-workspace-toml-fmt = craneLib.taploFmt {
src = pkgs.lib.sources.sourceFilesBySuffices src [".toml"];
};
llama-workspace-audit = craneLib.cargoAudit {inherit src advisory-db;};
llama-workspace-deny = craneLib.cargoDeny {inherit src;};
};
packages = {
inherit llamac;
default = llamac;
};
apps = {
llamac = flake-utils.lib.mkApp {
drv = llamac;
};
};
devShells.default = let
# Idk if this is the right way to be doing this but idc
devShell =
if pkgs.stdenv.targetPlatform.isDarwin
then craneLib.devShell
else
craneLib.devShell.override {
mkShell = pkgs.mkShell.override {stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv;};
};
in
devShell {
checks = self.checks.${system};
packages = [pkgs.taplo];
};
});
}