-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
205 lines (191 loc) · 7.12 KB
/
Copy pathflake.nix
File metadata and controls
205 lines (191 loc) · 7.12 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
202
203
204
205
{
description = "BlocksenseOS - Confidential Computing Operating System";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
nixpkgs-unstable,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;};
unstablePkgs = import nixpkgs-unstable {inherit system;};
# Define Linux-specific packages that aren't available on all platforms
linuxOnlyPackages = pkgs.lib.optionals pkgs.stdenv.isLinux [
pkgs.tpm2-tools
pkgs.qemu
pkgs.gdb
pkgs.netcat-gnu
];
in {
devShells.default = pkgs.mkShell {
buildInputs = with pkgs;
[
git
figlet
just # Command runner for common tasks
ruby # For the test script
# Build tools
cmake
cargo
rustc
clippy # Rust linting tool
rustfmt # Rust formatting tool
# C++ development tools
clang-tools # Includes clang-format for C++ linting
# Modern C++ async I/O library
asio # Standalone ASIO for coroutines and async networking
# Attestation libraries
openssl
# Additional tools for development
pkg-config
gcc
# Nix tools
nixfmt-rfc-style
alejandra # Nix formatter
# Configuration and data tools
dhall # Dhall configuration language
dhall-json # Dhall to JSON conversion (needed for act token script)
# GitHub Actions and CI tools
act # Run GitHub Actions locally
jq # JSON processor for dependency checks
# Networking tools for CI tests
netcat-gnu # For testing echo services
curl # For HTTP endpoint testing
# Security audit tools
cargo-audit
cargo-deny
cargo-outdated
# Additional security tools for comprehensive auditing
semgrep # Static analysis security scanner
bandit # Python security linter (in case we add Python scripts)
shellcheck # Shell script analysis
# Performance testing tools
hey # HTTP load testing tool
# Documentation tools
mdbook # For generating documentation
# Supply chain security tools
cargo-cyclonedx # SBOM generation for Rust projects
cyclonedx-cli # CycloneDX CLI tool for SBOM analysis
unstablePkgs.trivy # Use latest Trivy version from unstable to fix AWS policy parsing issues
cosign # Container signing
syft # SBOM generation alternative
# Repository packaging tools
repomix # AI-friendly repository packaging
]
++ linuxOnlyPackages; # Add Linux-specific packages conditionally
shellHook = ''
figlet "BlocksenseOS"
echo "TEE-enabled confidential computing environment"
echo "Available commands:"
echo " just --list # Show all available Just commands"
echo " just build-all # Build all services"
echo " just test # Run all tests"
echo " just ci-full # Run full CI pipeline locally"
echo " just run-github-workflows # Run GitHub workflows locally"
echo " just dev # Enter development shell"
echo " repomix # Package repository for AI analysis"
echo ""
echo "Direct Nix commands:"
echo " nix build .#cpp-echo-service"
echo " nix build .#rust-echo-service"
echo " nix build .#attestation-agent"
'';
};
packages = {
cpp-echo-service = pkgs.stdenv.mkDerivation {
pname = "cpp-echo-service";
version = "0.2.0";
src = ./services/cpp-echo;
nativeBuildInputs = [pkgs.cmake pkgs.pkg-config];
buildInputs = [pkgs.asio pkgs.openssl];
configurePhase = ''
cmake -B build -S . -DCMAKE_INSTALL_PREFIX=$out
'';
buildPhase = ''
cmake --build build
'';
installPhase = ''
cmake --install build
'';
};
rust-echo-service = pkgs.rustPlatform.buildRustPackage {
pname = "rust-echo-service";
version = "0.1.0";
src = ./services/rust-echo;
cargoLock = {
lockFile = ./services/rust-echo/Cargo.lock;
};
};
attestation-agent = pkgs.rustPlatform.buildRustPackage {
pname = "attestation-agent";
version = "0.1.0";
src = ./attestation-agent;
cargoLock = {
lockFile = ./attestation-agent/Cargo.lock;
};
buildInputs = [pkgs.openssl];
nativeBuildInputs = [pkgs.pkg-config];
};
derivation-hasher = pkgs.rustPlatform.buildRustPackage {
pname = "derivation-hasher";
version = "0.1.0";
src = ./derivation-hasher;
cargoLock = {
lockFile = ./derivation-hasher/Cargo.lock;
};
};
rust-client = pkgs.rustPlatform.buildRustPackage {
pname = "rust-client";
version = "0.1.0";
src = ./clients/rust-client;
cargoLock = {
lockFile = ./clients/rust-client/Cargo.lock;
};
buildInputs = [pkgs.openssl];
nativeBuildInputs = [pkgs.pkg-config];
};
# VM image for local testing
blocksenseOS-vm = self.nixosConfigurations.blocksenseOS.config.system.build.vm;
# ISO image for deployment
blocksenseOS-iso = self.nixosConfigurations.blocksenseOS-iso.config.system.build.isoImage;
};
})
// {
# NixOS configurations at flake root level
nixosConfigurations.blocksenseOS = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./nixos-modules/base.nix
./nixos-modules/security.nix
./nixos-modules/services.nix
{
_module.args.self = self;
}
];
};
# ISO image configuration with installation-cd profile
nixosConfigurations.blocksenseOS-iso = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
./nixos-modules/base.nix
./nixos-modules/security.nix
./nixos-modules/services.nix
{
_module.args.self = self;
isoImage.makeEfiBootable = true;
isoImage.makeUsbBootable = true;
# Override SSH settings for installation media
services.openssh.settings.PermitRootLogin = nixpkgs.lib.mkForce "yes";
# Disable wireless to avoid conflict with NetworkManager
networking.wireless.enable = nixpkgs.lib.mkForce false;
}
];
};
};
}