-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
186 lines (165 loc) · 6.3 KB
/
flake.nix
File metadata and controls
186 lines (165 loc) · 6.3 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
{
description = "Singularity Analysis Engine development environment";
# Configure binary caches for faster builds
nixConfig = {
extra-substituters = [
"https://mikkihugo.cachix.org"
"https://cache.nixos.org"
];
extra-trusted-public-keys = [
"mikkihugo.cachix.org-1:TJ+vwFP1XImrAATJbqWLaEvtzuWpui9hw5stDdeOTAE="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
nixpkgs,
rust-overlay,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {
inherit system overlays;
};
# Rust toolchain - latest stable
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = ["rust-src" "rust-analyzer"];
};
# Build inputs for the project
buildInputs = with pkgs; [
# Rust and cargo tools
rustToolchain
cargo-edit # cargo add/rm/upgrade
cargo-watch # cargo watch for auto-recompilation
cargo-audit # security audit
cargo-outdated # check for outdated dependencies
cargo-tarpaulin # code coverage
cargo-nextest # better test runner
cargo-machete # find unused dependencies
cargo-deny # lint dependencies
cargo-release # release automation
cargo-udeps # find unused dependencies (build-time)
cargo-expand # expand macros
cargo-bloat # find what takes space in binary
cargo-geiger # detect unsafe usage
cargo-fuzz # fuzz testing
cargo-llvm-lines # count LLVM IR lines
sccache # compilation cache
# Node.js for additional tooling (jscpd can be installed via npm)
nodejs
# Elixir and Erlang
beam.packages.erlang_28.elixir_1_19 # Elixir 1.19 with Erlang/OTP 28
beam.packages.erlang_28.erlang
beam.packages.erlang_28.rebar3
beam.packages.erlang_28.hex
# Elixir tools from Nix (pre-built, no compilation needed)
beam.packages.erlang_28.elixir-ls # Language server
# Build dependencies for NIFs
pkg-config
openssl
# Development tools
git
gnumake
just # command runner (modern make alternative)
gcc
libiconv
# Security and quality scanning
gitleaks # secret scanning
shellcheck # shell script linting
# Optional: useful for development
jq
ripgrep
fd
bat
eza
tokei # code statistics
];
# Set up environment variables
shellHook = ''
echo "🚀 Singularity Analysis Engine Development Environment"
echo ""
echo "📦 Versions:"
echo " • Rust: $(rustc --version | cut -d' ' -f2)"
echo " • Cargo: $(cargo --version | cut -d' ' -f2)"
echo " • Elixir: $(elixir --version | grep Elixir | cut -d' ' -f2)"
echo " • Erlang/OTP: $(erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell | tr -d '\"')"
echo ""
echo "🛠️ Rust Quality Tools:"
echo " • cargo-audit, cargo-deny, cargo-geiger (security)"
echo " • cargo-nextest, cargo-tarpaulin (testing & coverage)"
echo " • cargo-outdated, cargo-udeps, cargo-machete (dependencies)"
echo " • cargo-bloat, cargo-llvm-lines (performance analysis)"
echo " • cargo-expand, cargo-fuzz (advanced)"
echo ""
echo "💜 Elixir Quality Tools:"
echo " • credo, dialyzer, doctor (code quality)"
echo " • sobelow, mix_audit (security)"
echo " • excoveralls (coverage)"
echo ""
echo "🔒 Security & General:"
echo " • gitleaks (secret scanning)"
echo " • shellcheck (shell script linting)"
echo " • tokei (code statistics)"
echo " • jscpd (install: npm install -g jscpd)"
echo ""
echo "🚀 Quick Commands:"
echo " • make help - Show all available targets"
echo " • make quality - Run all quality checks"
echo " • make security - Security scans"
echo " • make test - Run all tests"
echo " • make coverage - Generate coverage reports"
echo " • See QUALITY.md for detailed documentation"
echo ""
# Set up Rust environment
export RUST_SRC_PATH="${rustToolchain}/lib/rustlib/src/rust/library"
export RUST_BACKTRACE=1
# Set up build cache
export SCCACHE_DIR="$PWD/.sccache"
export RUSTC_WRAPPER="${pkgs.sccache}/bin/sccache"
# Elixir/Erlang environment
export ERL_AFLAGS="-kernel shell_history enabled"
export HEX_HOME="$PWD/.hex"
export MIX_HOME="$PWD/.mix"
# Create local directories if they don't exist
mkdir -p .sccache .hex .mix
# Install local hex and rebar if not present
if ! compgen -G "$MIX_HOME/archives/hex-*" > /dev/null; then
echo "📥 Installing local hex..."
mix local.hex --force --if-missing
fi
if ! compgen -G "$MIX_HOME/elixir/*/rebar3" > /dev/null; then
echo "📥 Installing local rebar..."
mix local.rebar --force --if-missing
fi
'';
in {
devShells.default = pkgs.mkShell {
inherit buildInputs;
inherit shellHook;
# Additional environment variables
RUST_LOG = "debug";
CARGO_HOME = "$PWD/.cargo";
};
# Also provide a minimal shell without the startup message
devShells.minimal = pkgs.mkShell {
inherit buildInputs;
shellHook = ''
export RUST_SRC_PATH="${rustToolchain}/lib/rustlib/src/rust/library"
export RUST_BACKTRACE=1
export SCCACHE_DIR="$PWD/.sccache"
export RUSTC_WRAPPER="${pkgs.sccache}/bin/sccache"
export ERL_AFLAGS="-kernel shell_history enabled"
export HEX_HOME="$PWD/.hex"
export MIX_HOME="$PWD/.mix"
export RUST_LOG="debug"
export CARGO_HOME="$PWD/.cargo"
mkdir -p .sccache .hex .mix .cargo
'';
};
});
}