blob: 2d2514d7cbe37660b2585f9319d6390c5d39431c (
plain)
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
202
203
|
# Flake Migration Complete
**Date:** November 4, 2025
**Change:** Migrated from shell.nix to flake.nix
## What Changed
### Files Modified
1. **Created: grasp-audit/flake.nix**
- Based on ../ngit/flake.nix
- Uses rust-overlay for Rust toolchain
- Includes devShell and package outputs
- Properly configured with dependencies
2. **Removed: grasp-audit/shell.nix**
- Old Nix shell configuration
- Replaced by flake.nix
3. **Updated Documentation:**
- grasp-audit/README.md
- grasp-audit/QUICK_START.md
- NEXT_SESSION_QUICKSTART.md
- SMOKE_TEST_REPORT.md
- FILES_CREATED.md
All references to `nix-shell` changed to `nix develop`.
## New Flake Configuration
```nix
{
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; };
manifest = pkgs.lib.importTOML ./Cargo.toml;
in with pkgs; {
devShells.default = mkShell {
nativeBuildInputs = [
rust-bin.stable.latest.default
pkg-config
gitlint
];
buildInputs = [
openssl
];
shellHook = ''
echo "π¦ GRASP Audit development environment loaded"
# ... helpful messages ...
export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc}
'';
};
packages.default = pkgs.rustPlatform.buildRustPackage {
pname = manifest.package.name;
version = manifest.package.version;
src = ./.;
cargoLock = { lockFile = ./Cargo.lock; };
buildInputs = [ openssl ];
nativeBuildInputs = [ pkg-config ];
doCheck = false;
};
});
}
```
## Flake Validation
```bash
$ cd grasp-audit && nix flake show
git+file:///persistent/dcdev/clones/ngit-grasp?dir=grasp-audit
ββββdevShells
β ββββaarch64-darwin
β β ββββdefault: omitted (use '--all-systems' to show)
β ββββaarch64-linux
β β ββββdefault: omitted (use '--all-systems' to show)
β ββββx86_64-darwin
β β ββββdefault: omitted (use '--all-systems' to show)
β ββββx86_64-linux
β ββββdefault: development environment 'nix-shell'
ββββpackages
ββββaarch64-darwin
β ββββdefault: omitted (use '--all-systems' to show)
ββββaarch64-linux
β ββββdefault: omitted (use '--all-systems' to show)
ββββx86_64-darwin
β ββββdefault: omitted (use '--all-systems' to show)
ββββx86_64-linux
ββββdefault: package 'grasp-audit-0.1.0'
```
β
Flake is valid and provides:
- Dev shell for all major systems
- Package output for grasp-audit binary
## Usage
### Old Way (shell.nix)
```bash
cd grasp-audit
nix-shell
cargo build
```
### New Way (flake.nix)
```bash
cd grasp-audit
nix develop
cargo build
```
### Additional Flake Commands
```bash
# Show flake outputs
nix flake show
# Check flake validity
nix flake check
# Build the package directly
nix build
# Run without installing
nix run
# Update flake inputs
nix flake update
```
## Benefits of Flakes
1. **Reproducibility:** Locked inputs ensure consistent builds
2. **Multi-output:** Both dev shell and package in one file
3. **Standard:** Follows modern Nix best practices
4. **Composability:** Can be used as input to other flakes
5. **Better UX:** `nix develop` is clearer than `nix-shell`
## Updated Quick Start
```bash
# 1. Enter dev environment
cd grasp-audit
nix develop
# 2. Build
cargo build
# 3. Test
cargo test --lib
# 4. Run example
cargo run --example simple_audit
```
## Documentation Updates
All documentation has been updated to use `nix develop` instead of `nix-shell`:
- β
grasp-audit/README.md
- β
grasp-audit/QUICK_START.md
- β
NEXT_SESSION_QUICKSTART.md
- β
SMOKE_TEST_REPORT.md
- β
FILES_CREATED.md
## Next Steps
The flake is ready to use. Next session can:
1. **Enter dev environment:**
```bash
cd grasp-audit
nix develop
```
2. **Build and test:**
```bash
cargo build
cargo test --lib
```
3. **Continue with integration tests** (once relay is set up)
## Status
- β
Flake created and validated
- β
Documentation updated
- β
Old shell.nix removed
- β
Git tracking enabled
- π§ Dev environment ready (first run will download dependencies)
- π§ Build pending (waiting for nix develop to complete)
---
**Migration Complete:** shell.nix β flake.nix β
|