-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
201 lines (166 loc) · 5.48 KB
/
flake.nix
File metadata and controls
201 lines (166 loc) · 5.48 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
{
description = "Bunsenite: Nickel configuration file parser with multi-language FFI bindings";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, rust-overlay, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" "rust-analyzer" "clippy" "rustfmt" ];
targets = [ "wasm32-unknown-unknown" ];
};
# Build inputs common to all derivations
commonBuildInputs = with pkgs; [
rustToolchain
pkg-config
openssl
];
# Development tools
devTools = with pkgs; [
just
cargo-edit
cargo-audit
cargo-outdated
cargo-tarpaulin
cargo-deny
wasm-pack
jq
];
in
{
# Development shell
devShells.default = pkgs.mkShell {
buildInputs = commonBuildInputs ++ devTools;
shellHook = ''
echo "🔧 Bunsenite Development Environment"
echo ""
echo "Rust version: $(rustc --version)"
echo "Cargo version: $(cargo --version)"
echo ""
echo "Available commands:"
echo " just --list List all build recipes"
echo " just build Build release binaries"
echo " just test Run test suite"
echo " just check Run all quality checks"
echo " just rsr-check Verify RSR compliance"
echo ""
echo "RSR Compliance: Bronze Tier"
echo "TPCF Perimeter: 3 (Community Sandbox)"
echo "License: Dual PMPL-1.0 + Palimpsest 0.8"
echo ""
'';
# Environment variables
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
RUST_BACKTRACE = "1";
};
# Package derivation
packages.default = pkgs.rustPlatform.buildRustPackage rec {
pname = "bunsenite";
version = "1.0.0";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = commonBuildInputs;
buildInputs = with pkgs; [
openssl
];
# Run tests during build
checkPhase = ''
cargo test --release
'';
doCheck = true;
meta = with pkgs.lib; {
description = "Nickel configuration file parser with multi-language FFI bindings";
homepage = "https://github.com/hyperpolymath/bunsenite";
license = with licenses; [ mit ]; # Dual PMPL-1.0 + Palimpsest
maintainers = [ "Campaign for Cooler Coding and Programming" ];
platforms = platforms.all;
};
};
# WASM package
packages.wasm = pkgs.stdenv.mkDerivation {
pname = "bunsenite-wasm";
version = "1.0.0";
src = ./.;
nativeBuildInputs = with pkgs; [
rustToolchain
wasm-pack
];
buildPhase = ''
wasm-pack build --target web --out-dir pkg --release
'';
installPhase = ''
mkdir -p $out
cp -r pkg/* $out/
'';
meta = with pkgs.lib; {
description = "Bunsenite WebAssembly module";
homepage = "https://github.com/hyperpolymath/bunsenite";
license = with licenses; [ mit ];
};
};
# CI check (runs all quality checks)
packages.ci-check = pkgs.writeShellScriptBin "ci-check" ''
set -e
echo "Running CI checks..."
echo "1. Format check..."
cargo fmt --all -- --check
echo "2. Clippy..."
cargo clippy --all-targets --all-features -- -D warnings
echo "3. Test suite..."
cargo test --all-features
echo "4. Unsafe code check..."
if grep -r "unsafe" src/; then
echo "ERROR: Found unsafe code!"
exit 1
fi
echo "5. RSR compliance..."
just rsr-check
echo "✓ All CI checks passed!"
'';
# Apps
apps.default = flake-utils.lib.mkApp {
drv = self.packages.${system}.default;
};
# Formatter
formatter = pkgs.nixpkgs-fmt;
# Checks (run with `nix flake check`)
checks = {
# Build check
build = self.packages.${system}.default;
# Format check
format = pkgs.runCommand "check-format" {
buildInputs = [ rustToolchain ];
} ''
cd ${./.}
cargo fmt --all -- --check
touch $out
'';
# Clippy check
clippy = pkgs.runCommand "check-clippy" {
buildInputs = [ rustToolchain ];
} ''
cd ${./.}
cargo clippy --all-targets --all-features -- -D warnings
touch $out
'';
# Test check
test = pkgs.runCommand "check-tests" {
buildInputs = [ rustToolchain ];
} ''
cd ${./.}
cargo test --all-features
touch $out
'';
};
}
);
}