radrootsd

JSON-RPC bridge for Radroots event publishing
git clone https://radroots.dev/git/radrootsd.git
Log | Files | Refs | README | LICENSE

commit da316347842757d2f7868597042175842e737772
parent 41738647a5e46671eb9c0d9dd22b8a7b7fc9c077
Author: triesap <tyson@radroots.org>
Date:   Tue, 31 Mar 2026 15:37:59 +0000

build: add standalone nix command surface

Diffstat:
Adocs/nix.md | 19+++++++++++++++++++
Aflake.lock | 48++++++++++++++++++++++++++++++++++++++++++++++++
Aflake.nix | 133+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 200 insertions(+), 0 deletions(-)

diff --git a/docs/nix.md b/docs/nix.md @@ -0,0 +1,19 @@ +# Nix + +This repository uses Nix as the canonical local development and validation environment. + +## Enter The Shell + +```bash +nix develop +``` + +## Command Map + +```bash +nix run .#fmt +nix run .#check +nix run .#test +``` + +Use `nix develop` before running narrower ad hoc cargo commands from this repo root. diff --git a/flake.lock b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1774799055, + "narHash": "sha256-Tsq9BCz0q47ej1uFF39m4tuhcwru/ls6vCCJzutEpaw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "107cba9eb4a8d8c9f8e9e61266d78d340867913a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1774926780, + "narHash": "sha256-JMdDYn0F+swYBILlpCeHDbCSyzqkeSGNxZ/Q5J584jM=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "962a0934d0e32f42d1b5e49186f9595f9b178d2d", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix @@ -0,0 +1,133 @@ +{ + description = "radrootsd"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + { nixpkgs, rust-overlay, ... }: + let + systems = [ + "aarch64-darwin" + "aarch64-linux" + "x86_64-darwin" + "x86_64-linux" + ]; + forAllSystems = + f: + nixpkgs.lib.genAttrs systems ( + system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ rust-overlay.overlays.default ]; + }; + rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + basePackages = + [ + pkgs.git + rustToolchain + pkgs.clang + pkgs.llvmPackages.libclang + pkgs.libsodium + pkgs.openssl + pkgs.pkg-config + pkgs.sqlite + ] + ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ + pkgs.darwin.libiconv + ]; + libraryPath = pkgs.lib.makeLibraryPath basePackages; + includePath = pkgs.lib.makeSearchPathOutput "dev" "include" basePackages; + darwinLdFlags = pkgs.lib.optionalString pkgs.stdenv.isDarwin "-L${pkgs.darwin.libiconv}/lib"; + darwinRustFlags = pkgs.lib.optionalString pkgs.stdenv.isDarwin "-L native=${pkgs.darwin.libiconv}/lib"; + mkApp = + name: text: + let + script = pkgs.writeShellApplication { + inherit name; + runtimeInputs = basePackages; + text = '' + set -euo pipefail + repo_root="$(git rev-parse --show-toplevel)" + cd "$repo_root" + export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib" + export LIBRARY_PATH="${libraryPath}:''${LIBRARY_PATH:-}" + export DYLD_FALLBACK_LIBRARY_PATH="${libraryPath}:''${DYLD_FALLBACK_LIBRARY_PATH:-}" + export LDFLAGS="${darwinLdFlags} ''${LDFLAGS:-}" + export NIX_LDFLAGS="${darwinLdFlags} ''${NIX_LDFLAGS:-}" + export RUSTFLAGS="${darwinRustFlags} ''${RUSTFLAGS:-}" + export CPATH="${includePath}:''${CPATH:-}" + ${text} + ''; + }; + in + { + type = "app"; + program = "${script}/bin/${name}"; + }; + in + f { + inherit + basePackages + darwinLdFlags + darwinRustFlags + includePath + libraryPath + mkApp + pkgs + rustToolchain + ; + } + ); + in + { + apps = forAllSystems ( + { mkApp, ... }: + rec { + default = check; + check = mkApp "check" '' + cargo metadata --format-version 1 --no-deps + cargo check + ''; + fmt = mkApp "fmt" '' + cargo fmt --all --check + ''; + test = mkApp "test" '' + cargo test + ''; + } + ); + + devShells = forAllSystems ( + { + basePackages, + darwinLdFlags, + darwinRustFlags, + includePath, + libraryPath, + pkgs, + ... + }: + { + default = pkgs.mkShell { + packages = basePackages; + shellHook = '' + export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib" + export LIBRARY_PATH="${libraryPath}:''${LIBRARY_PATH:-}" + export DYLD_FALLBACK_LIBRARY_PATH="${libraryPath}:''${DYLD_FALLBACK_LIBRARY_PATH:-}" + export LDFLAGS="${darwinLdFlags} ''${LDFLAGS:-}" + export NIX_LDFLAGS="${darwinLdFlags} ''${NIX_LDFLAGS:-}" + export RUSTFLAGS="${darwinRustFlags} ''${RUSTFLAGS:-}" + export CPATH="${includePath}:''${CPATH:-}" + ''; + }; + } + ); + }; +}