Add Nix flake and direnv

Dev shell for x86_64-linux, aarch64-linux and aarch64-darwin. The toolchain
comes from rust-toolchain.toml with rust-src and rust-analyzer, and .envrc
loads the make-style .env.
This commit is contained in:
Matthew Wilding
2026-10-08 12:33:49 +08:00
parent a2f4e0b857
commit 1b8c4df703
4 changed files with 159 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
# .env is make syntax (unquoted values with spaces), so direnv's dotenv rejects it.
if [[ -f .env ]]; then
watch_file .env
while IFS='=' read -r key value; do
[[ $key =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]] && export "$key=$value"
done < .env
fi
use flake
+5
View File
@@ -14,3 +14,8 @@ iw4l.community.*.tmp
# Agent working memory. None of it is the product: the artifacts, the externals,
# the agent clones and the RE tooling and its bases all stay on this machine.
/context/
# Nix / direnv
.direnv/
result
result-*
Generated
+82
View File
@@ -0,0 +1,82 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1791260994,
"narHash": "sha256-Miqqk/ammqnTUxaoCyvtwoPeLbI1ksFyLxi/CazZpWY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "151fa4e8ddfdd8dd25d945ad94ed54a13de9f6e4",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1791361643,
"narHash": "sha256-HMdfSb1ONHs1RbSkQtCXm+tWEsTikisWWtXDnv0aQ+I=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "8afee9fa8caa877a4feb65adc33e8d72f3747dc9",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
+64
View File
@@ -0,0 +1,64 @@
{
description = "iw4L development shell";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
rust-overlay,
flake-utils,
}:
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ] (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
toolchain = (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override {
extensions = [
"rust-src"
"rust-analyzer"
];
};
runtimeLibs = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux (
with pkgs;
[
alsa-lib
libxkbcommon
udev
vulkan-loader
wayland
libx11
libxcursor
libxi
libxrandr
]
);
in
{
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
toolchain
pkg-config
cmake
clang
git
];
buildInputs = runtimeLibs;
LD_LIBRARY_PATH = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux (
pkgs.lib.makeLibraryPath runtimeLibs
);
};
}
);
}