feat: add nix flake with fenix rust toolchain

Configure hermetic development environment:

- fenix toolchain from rust-toolchain.toml
- clangStdenv for Tree-sitter C grammar compilation
- Multi-platform devShells (x86_64/aarch64, linux/darwin)
- Generated flake.lock with pinned inputs
This commit is contained in:
Timothy DeHerrera
2026-01-24 18:48:14 -07:00
parent 0be71ca374
commit f4201e95ba
4 changed files with 120 additions and 0 deletions

1
.envrc Normal file
View File

@@ -0,0 +1 @@
use flake

1
.gitignore vendored
View File

@@ -3,4 +3,5 @@ target
# Local Netlify folder
.netlify
.direnv
target/

66
flake.lock generated Normal file
View File

@@ -0,0 +1,66 @@
{
"nodes": {
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1769237067,
"narHash": "sha256-o2UfbFRcL/UClXaDI8NR3WAulOoda55rdw0oVXAst0A=",
"owner": "nix-community",
"repo": "fenix",
"rev": "93523fa073f781d3d02d326cdbb85f8709b00c40",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1769268028,
"narHash": "sha256-mAdJpV0e5IGZjnE4f/8uf0E4hQR7ptRP00gnZKUOdMo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ab9fbbcf4858bd6d40ba2bbec37ceb4ab6e1f562",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"fenix": "fenix",
"nixpkgs": "nixpkgs"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1769166439,
"narHash": "sha256-HjSoNRYe8tPdzfhJ0IBQrrJATOrtVKOHvk8OoTew1Do=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "39018acf3477a26f4e6d2ead6a48954d623adcaa",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

52
flake.nix Normal file
View File

@@ -0,0 +1,52 @@
{
description = "nrd.sh - bespoke static site compiler";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
fenix,
}:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn system);
in
{
devShells = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
fenixPkgs = fenix.packages.${system};
toolchain = fenixPkgs.fromToolchainFile { file = ./rust-toolchain.toml; sha256 = "sha256-vra6TkHITpwRyA5oBKAHSX0Mi6CBDNQD+ryPSpxFsfg=";};
in
{
default = pkgs.mkShell.override { stdenv = pkgs.clangStdenv; } {
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
packages =
[
toolchain
fenixPkgs.default.rustfmt
pkgs.pkg-config
]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.apple-sdk
pkgs.libiconv
];
};
}
);
};
}