- Remove gitlinks (160000 mode) for chainfire, flaredb, iam - Add workspace contents as regular tracked files - Update flake.nix to use simple paths instead of builtins.fetchGit This resolves the nix build failure where submodule directories appeared empty in the nix store. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
347 lines
14 KiB
Nix
347 lines
14 KiB
Nix
{
|
|
description = "PlasmaCloud - Japanese Cloud Platform";
|
|
|
|
# ============================================================================
|
|
# INPUTS: External dependencies
|
|
# ============================================================================
|
|
inputs = {
|
|
# Use unstable nixpkgs for latest packages
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
# Rust overlay for managing Rust toolchains
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
# Flake utilities for multi-system support
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
};
|
|
|
|
# ============================================================================
|
|
# OUTPUTS: What this flake provides
|
|
# ============================================================================
|
|
outputs = { self, nixpkgs, rust-overlay, flake-utils }:
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
# Apply rust-overlay to get rust-bin attribute
|
|
overlays = [ (import rust-overlay) ];
|
|
|
|
pkgs = import nixpkgs {
|
|
inherit system overlays;
|
|
};
|
|
|
|
# Local workspace sources (regular directories, not submodules)
|
|
chainfireSrc = ./chainfire;
|
|
flaredbSrc = ./flaredb;
|
|
iamSrc = ./iam;
|
|
|
|
# Rust toolchain configuration
|
|
# Using stable channel with rust-src (for rust-analyzer) and rust-analyzer
|
|
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
|
|
extensions = [ "rust-src" "rust-analyzer" ];
|
|
};
|
|
|
|
# Common build inputs needed by all Rust packages
|
|
commonBuildInputs = with pkgs; [
|
|
rocksdb # RocksDB storage engine
|
|
openssl # TLS/SSL support
|
|
];
|
|
|
|
# Common native build inputs (build-time only)
|
|
commonNativeBuildInputs = with pkgs; [
|
|
pkg-config # For finding libraries
|
|
protobuf # Protocol Buffers compiler
|
|
rustToolchain
|
|
];
|
|
|
|
# Common environment variables for building
|
|
commonEnvVars = {
|
|
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
|
PROTOC = "${pkgs.protobuf}/bin/protoc";
|
|
ROCKSDB_LIB_DIR = "${pkgs.rocksdb}/lib";
|
|
};
|
|
|
|
# Helper function to build a Rust workspace package
|
|
# Parameters:
|
|
# name: package name (e.g., "chainfire-server")
|
|
# workspaceDir: path to workspace directory (e.g., ./chainfire)
|
|
# mainCrate: optional main crate name if different from workspace
|
|
# description: package description for meta
|
|
buildRustWorkspace = { name, workspaceDir, mainCrate ? null, description ? "" }:
|
|
pkgs.rustPlatform.buildRustPackage ({
|
|
pname = name;
|
|
version = "0.1.0";
|
|
src = workspaceDir;
|
|
|
|
cargoLock = {
|
|
lockFile = "${workspaceDir}/Cargo.lock";
|
|
};
|
|
|
|
nativeBuildInputs = commonNativeBuildInputs;
|
|
buildInputs = commonBuildInputs;
|
|
|
|
# Set environment variables for build
|
|
inherit (commonEnvVars) LIBCLANG_PATH PROTOC ROCKSDB_LIB_DIR;
|
|
|
|
# Enable cargo tests during build
|
|
doCheck = true;
|
|
|
|
# Test flags: run tests for the main crate only
|
|
cargoTestFlags = pkgs.lib.optionals (mainCrate != null) [ "-p" mainCrate ];
|
|
|
|
# Metadata for the package
|
|
meta = with pkgs.lib; {
|
|
description = description;
|
|
homepage = "https://github.com/yourorg/plasmacloud";
|
|
license = licenses.asl20; # Apache 2.0
|
|
maintainers = [ ];
|
|
platforms = platforms.linux;
|
|
};
|
|
|
|
# Build only the server binary if mainCrate is specified
|
|
# This avoids building test binaries and examples
|
|
} // pkgs.lib.optionalAttrs (mainCrate != null) {
|
|
cargoBuildFlags = [ "-p" mainCrate ];
|
|
});
|
|
|
|
in
|
|
{
|
|
# ======================================================================
|
|
# DEVELOPMENT SHELL: Drop-in replacement for shell.nix
|
|
# ======================================================================
|
|
devShells.default = pkgs.mkShell {
|
|
name = "cloud-dev";
|
|
|
|
buildInputs = with pkgs; [
|
|
# Rust toolchain (replaces rustup/cargo/rustc from shell.nix)
|
|
rustToolchain
|
|
|
|
# Protocol Buffers
|
|
protobuf
|
|
|
|
# LLVM/Clang (for bindgen/clang-sys)
|
|
llvmPackages.libclang
|
|
llvmPackages.clang
|
|
|
|
# Build essentials
|
|
pkg-config
|
|
openssl
|
|
|
|
# Development tools
|
|
git
|
|
|
|
# For RocksDB (chainfire dependency)
|
|
rocksdb
|
|
];
|
|
|
|
# Environment variables for clang-sys and other build tools
|
|
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
|
PROTOC = "${pkgs.protobuf}/bin/protoc";
|
|
ROCKSDB_LIB_DIR = "${pkgs.rocksdb}/lib";
|
|
|
|
shellHook = ''
|
|
echo "Cloud Platform Development Environment"
|
|
echo "======================================="
|
|
echo "Rust: $(rustc --version)"
|
|
echo "Protoc: $(protoc --version)"
|
|
echo "Clang: $(clang --version | head -1)"
|
|
echo ""
|
|
echo "Environment variables set:"
|
|
echo " LIBCLANG_PATH=$LIBCLANG_PATH"
|
|
echo " PROTOC=$PROTOC"
|
|
echo " ROCKSDB_LIB_DIR=$ROCKSDB_LIB_DIR"
|
|
echo ""
|
|
echo "Available workspaces:"
|
|
echo " - chainfire (distributed KV store)"
|
|
echo " - flaredb (time-series database)"
|
|
echo " - iam (identity & access management)"
|
|
echo " - plasmavmc (VM control plane)"
|
|
echo " - novanet (SDN controller)"
|
|
echo " - flashdns (DNS server)"
|
|
echo " - fiberlb (load balancer)"
|
|
echo " - lightningstor (block storage)"
|
|
echo " - k8shost (kubernetes hosting)"
|
|
'';
|
|
};
|
|
|
|
# ======================================================================
|
|
# PACKAGES: Buildable artifacts from each workspace
|
|
# ======================================================================
|
|
packages = {
|
|
# --------------------------------------------------------------------
|
|
# Chainfire: Distributed Key-Value Store with Raft consensus
|
|
# --------------------------------------------------------------------
|
|
chainfire-server = buildRustWorkspace {
|
|
name = "chainfire-server";
|
|
workspaceDir = chainfireSrc;
|
|
mainCrate = "chainfire-server";
|
|
description = "Distributed key-value store with Raft consensus and gossip protocol";
|
|
};
|
|
|
|
# --------------------------------------------------------------------
|
|
# FlareDB: Time-Series Database with Raft consensus
|
|
# --------------------------------------------------------------------
|
|
flaredb-server = buildRustWorkspace {
|
|
name = "flaredb-server";
|
|
workspaceDir = flaredbSrc;
|
|
mainCrate = "flaredb-server";
|
|
description = "Distributed time-series database with Raft consensus for metrics and events";
|
|
};
|
|
|
|
# --------------------------------------------------------------------
|
|
# IAM: Identity and Access Management Service
|
|
# --------------------------------------------------------------------
|
|
iam-server = buildRustWorkspace {
|
|
name = "iam-server";
|
|
workspaceDir = iamSrc;
|
|
mainCrate = "iam-server";
|
|
description = "Identity and access management service with RBAC and multi-tenant support";
|
|
};
|
|
|
|
# --------------------------------------------------------------------
|
|
# PlasmaVMC: Virtual Machine Control Plane
|
|
# --------------------------------------------------------------------
|
|
plasmavmc-server = buildRustWorkspace {
|
|
name = "plasmavmc-server";
|
|
workspaceDir = ./plasmavmc;
|
|
mainCrate = "plasmavmc-server";
|
|
description = "Virtual machine control plane for managing compute instances";
|
|
};
|
|
|
|
# --------------------------------------------------------------------
|
|
# NovaNet: Software-Defined Networking Controller
|
|
# --------------------------------------------------------------------
|
|
novanet-server = buildRustWorkspace {
|
|
name = "novanet-server";
|
|
workspaceDir = ./novanet;
|
|
mainCrate = "novanet-server";
|
|
description = "Software-defined networking controller with OVN integration";
|
|
};
|
|
|
|
# --------------------------------------------------------------------
|
|
# FlashDNS: High-Performance DNS Server
|
|
# --------------------------------------------------------------------
|
|
flashdns-server = buildRustWorkspace {
|
|
name = "flashdns-server";
|
|
workspaceDir = ./flashdns;
|
|
mainCrate = "flashdns-server";
|
|
description = "High-performance DNS server with pattern-based reverse DNS";
|
|
};
|
|
|
|
# --------------------------------------------------------------------
|
|
# FiberLB: Layer 4/7 Load Balancer
|
|
# --------------------------------------------------------------------
|
|
fiberlb-server = buildRustWorkspace {
|
|
name = "fiberlb-server";
|
|
workspaceDir = ./fiberlb;
|
|
mainCrate = "fiberlb-server";
|
|
description = "Layer 4/7 load balancer for distributing traffic across services";
|
|
};
|
|
|
|
# --------------------------------------------------------------------
|
|
# LightningStor: Block Storage Service
|
|
# --------------------------------------------------------------------
|
|
lightningstor-server = buildRustWorkspace {
|
|
name = "lightningstor-server";
|
|
workspaceDir = ./lightningstor;
|
|
mainCrate = "lightningstor-server";
|
|
description = "Distributed block storage service for persistent volumes";
|
|
};
|
|
|
|
# --------------------------------------------------------------------
|
|
# k8shost: Kubernetes Hosting Component
|
|
# --------------------------------------------------------------------
|
|
k8shost-server = buildRustWorkspace {
|
|
name = "k8shost-server";
|
|
workspaceDir = ./k8shost;
|
|
mainCrate = "k8shost-server";
|
|
description = "Lightweight Kubernetes hosting with multi-tenant isolation";
|
|
};
|
|
|
|
# --------------------------------------------------------------------
|
|
# Default package: Build all servers
|
|
# --------------------------------------------------------------------
|
|
default = pkgs.symlinkJoin {
|
|
name = "plasmacloud-all";
|
|
paths = [
|
|
self.packages.${system}.chainfire-server
|
|
self.packages.${system}.flaredb-server
|
|
self.packages.${system}.iam-server
|
|
self.packages.${system}.plasmavmc-server
|
|
self.packages.${system}.novanet-server
|
|
self.packages.${system}.flashdns-server
|
|
self.packages.${system}.fiberlb-server
|
|
self.packages.${system}.lightningstor-server
|
|
self.packages.${system}.k8shost-server
|
|
];
|
|
};
|
|
};
|
|
|
|
# ======================================================================
|
|
# APPS: Runnable applications from packages
|
|
# ======================================================================
|
|
apps = {
|
|
chainfire-server = flake-utils.lib.mkApp {
|
|
drv = self.packages.${system}.chainfire-server;
|
|
};
|
|
|
|
flaredb-server = flake-utils.lib.mkApp {
|
|
drv = self.packages.${system}.flaredb-server;
|
|
};
|
|
|
|
iam-server = flake-utils.lib.mkApp {
|
|
drv = self.packages.${system}.iam-server;
|
|
};
|
|
|
|
plasmavmc-server = flake-utils.lib.mkApp {
|
|
drv = self.packages.${system}.plasmavmc-server;
|
|
};
|
|
|
|
novanet-server = flake-utils.lib.mkApp {
|
|
drv = self.packages.${system}.novanet-server;
|
|
};
|
|
|
|
flashdns-server = flake-utils.lib.mkApp {
|
|
drv = self.packages.${system}.flashdns-server;
|
|
};
|
|
|
|
fiberlb-server = flake-utils.lib.mkApp {
|
|
drv = self.packages.${system}.fiberlb-server;
|
|
};
|
|
|
|
lightningstor-server = flake-utils.lib.mkApp {
|
|
drv = self.packages.${system}.lightningstor-server;
|
|
};
|
|
|
|
k8shost-server = flake-utils.lib.mkApp {
|
|
drv = self.packages.${system}.k8shost-server;
|
|
};
|
|
};
|
|
}
|
|
) // {
|
|
# ========================================================================
|
|
# NIXOS MODULES: System-level service modules (non-system-specific)
|
|
# ========================================================================
|
|
nixosModules.default = import ./nix/modules;
|
|
|
|
nixosModules.plasmacloud = import ./nix/modules;
|
|
|
|
# ========================================================================
|
|
# OVERLAY: Provides PlasmaCloud packages to nixpkgs
|
|
# ========================================================================
|
|
# Usage in NixOS configuration:
|
|
# nixpkgs.overlays = [ inputs.plasmacloud.overlays.default ];
|
|
overlays.default = final: prev: {
|
|
chainfire-server = self.packages.${final.system}.chainfire-server;
|
|
flaredb-server = self.packages.${final.system}.flaredb-server;
|
|
iam-server = self.packages.${final.system}.iam-server;
|
|
plasmavmc-server = self.packages.${final.system}.plasmavmc-server;
|
|
novanet-server = self.packages.${final.system}.novanet-server;
|
|
flashdns-server = self.packages.${final.system}.flashdns-server;
|
|
fiberlb-server = self.packages.${final.system}.fiberlb-server;
|
|
lightningstor-server = self.packages.${final.system}.lightningstor-server;
|
|
k8shost-server = self.packages.${final.system}.k8shost-server;
|
|
};
|
|
};
|
|
}
|