commit 35c58975a52fdbf674b8993a5f840e57bc9d7d49
parent faaff5a65035d3b69c357f1c9611c25f34356853
Author: triesap <tyson@radroots.org>
Date: Tue, 31 Mar 2026 15:38:00 +0000
build: add standalone nix command surface
Diffstat:
| A | docs/nix.md | | | 20 | ++++++++++++++++++++ |
| A | flake.lock | | | 48 | ++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | flake.nix | | | 136 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
3 files changed, 204 insertions(+), 0 deletions(-)
diff --git a/docs/nix.md b/docs/nix.md
@@ -0,0 +1,20 @@
+# 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
+nix run .#release-acceptance
+```
+
+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,136 @@
+{
+ description = "myc";
+
+ 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 --locked
+ '';
+ fmt = mkApp "fmt" ''
+ cargo fmt --all --check
+ '';
+ release-acceptance = mkApp "release-acceptance" ''
+ ./scripts/release-acceptance.sh
+ '';
+ test = mkApp "test" ''
+ cargo test --locked
+ '';
+ }
+ );
+
+ 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:-}"
+ '';
+ };
+ }
+ );
+ };
+}