mirror of
https://github.com/deepseek-ai/3FS
synced 2025-06-26 18:16:45 +00:00
4.7 KiB
4.7 KiB
3FS Nix Package and NixOS Module
This directory contains a Nix flake for building and deploying 3FS (Fire-Flyer File System) on NixOS systems.
Features
- Complete Package: Builds 3FS with all dependencies including RDMA support, FoundationDB integration, and FUSE 3
- NixOS Module: Provides systemd services for all 3FS components (meta, storage, mgmtd, monitor, fuse)
- Development Shell: Includes all build tools and dependencies for 3FS development
- Integration Tests: NixOS VM tests to validate the complete system
Quick Start
Building the Package
- First build (will fail with hash mismatch):
nix build .#3fs
-
Update the hash in
package.nixwith the correct one from the error message -
Rebuild:
nix build .#3fs
Using in NixOS
Add to your flake.nix:
{
inputs = {
threefs.url = "github:deepseek-ai/3fs";
};
outputs = { self, nixpkgs, threefs, ... }: {
nixosConfigurations.myserver = nixpkgs.lib.nixosSystem {
modules = [
threefs.nixosModules.default
{
services."3fs" = {
enable = true;
meta.enable = true;
storage.enable = true;
mgmtd.enable = true;
};
}
];
};
};
}
Development Environment
Enter the development shell:
nix develop
This provides:
- Clang 14 with C++20 support
- CMake and build tools
- All 3FS dependencies
- Rust toolchain
- Debug tools (gdb, valgrind, perf)
NixOS Module Options
Basic Configuration
services."3fs" = {
enable = true;
# User and group for services
user = "threefs";
group = "threefs";
# Directories
configDir = "/etc/3fs";
dataDir = "/var/lib/3fs";
# FoundationDB cluster file
foundationdb.clusterFile = "/etc/foundationdb/fdb.cluster";
};
Service Configuration
Metadata Service
services."3fs".meta = {
enable = true;
config = {
# Additional meta configuration
};
};
Storage Service
services."3fs".storage = {
enable = true;
targets = [
"/var/lib/3fs/storage/target1"
"/var/lib/3fs/storage/target2"
];
config = {
# Additional storage configuration
};
};
Management Daemon
services."3fs".mgmtd = {
enable = true;
config = {
# Additional mgmtd configuration
};
};
Monitor Collector
services."3fs".monitor = {
enable = true;
config = {
# Additional monitor configuration
};
};
FUSE Client
services."3fs".fuse = {
enable = true;
mountPoint = "/mnt/3fs";
config = {
# Additional FUSE configuration
};
};
Testing
Run Package Tests
./test-build.sh
Run Integration Tests
nix build .#checks.x86_64-linux.integration-test
Manual Testing
- Start FoundationDB:
sudo systemctl start foundationdb
- Initialize 3FS cluster:
3fs-admin init-cluster
- Start 3FS services:
sudo systemctl start 3fs-mgmtd
sudo systemctl start 3fs-meta
sudo systemctl start 3fs-storage
- Mount filesystem:
sudo systemctl start 3fs-fuse
Package Contents
The package includes:
-
Binaries:
admin- Administrative CLI toolmeta_main- Metadata servicestorage_main- Storage servicemgmtd_main- Management daemonmonitor_collector_main- Metrics collectorhf3fs_fuse_main- FUSE filesystem client
-
Libraries: All required shared libraries in
/lib -
Configuration: Default configuration files in
/etc/3fs -
Headers: Development headers in
/include/3fs
Troubleshooting
Build Issues
- Hash mismatch: Update the SHA256 hash in
package.nix - Missing dependencies: Check that all system libraries are available
- Compilation errors: Ensure you're using Clang 14 or newer
Runtime Issues
- Service fails to start: Check logs with
journalctl -u 3fs-<service> - FoundationDB connection: Ensure FDB cluster file is correct
- FUSE mount fails: Check that FUSE 3 is installed and kernel module is loaded
Architecture
The Nix package handles:
- Complex Dependencies: Automatically builds custom jemalloc, handles RDMA libraries
- Third-party Libraries: Uses system libraries where possible, builds others from source
- Rust Components: Properly integrates Cargo builds for Rust components
- Service Management: Complete systemd integration with proper dependencies
- Configuration: Manages TOML configuration files for all components
Contributing
When modifying the package:
- Update version in
package.nix - Test build locally
- Run integration tests
- Update documentation
License
MIT License (same as 3FS project)