← back to Exo
nix: convert to flake-parts
f8112fdf257150330342ffd0f51e05339dfa55af · 2026-01-13 11:50:05 +0000 · Jake Hillion
Preparing to add a flake-parts module for Rust builds. The flake-utils
library doesn't support the module system needed for cleanly separating
the Rust build configuration.
Converted from flake-utils to flake-parts, switching to the treefmt-nix
flakeModule import pattern. The devShell and formatter outputs remain
functionally equivalent.
Test plan:
- Ran `nix flake check` successfully
- Verified `nix develop` provides the same environment
Files touched
Diff
commit f8112fdf257150330342ffd0f51e05339dfa55af
Author: Jake Hillion <jake@hillion.co.uk>
Date: Tue Jan 13 11:50:05 2026 +0000
nix: convert to flake-parts
Preparing to add a flake-parts module for Rust builds. The flake-utils
library doesn't support the module system needed for cleanly separating
the Rust build configuration.
Converted from flake-utils to flake-parts, switching to the treefmt-nix
flakeModule import pattern. The devShell and formatter outputs remain
functionally equivalent.
Test plan:
- Ran `nix flake check` successfully
- Verified `nix develop` provides the same environment
---
flake.lock | 37 ++++--------
flake.nix | 198 ++++++++++++++++++++++++++++++-------------------------------
2 files changed, 111 insertions(+), 124 deletions(-)
diff --git a/flake.lock b/flake.lock
index 869ba848..49c4ca69 100644
--- a/flake.lock
+++ b/flake.lock
@@ -21,21 +21,23 @@
"type": "github"
}
},
- "flake-utils": {
+ "flake-parts": {
"inputs": {
- "systems": "systems"
+ "nixpkgs-lib": [
+ "nixpkgs"
+ ]
},
"locked": {
- "lastModified": 1731533236,
- "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
- "owner": "numtide",
- "repo": "flake-utils",
- "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
+ "lastModified": 1768135262,
+ "narHash": "sha256-PVvu7OqHBGWN16zSi6tEmPwwHQ4rLPU9Plvs8/1TUBY=",
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
+ "rev": "80daad04eddbbf5a4d883996a73f3f542fa437ac",
"type": "github"
},
"original": {
- "owner": "numtide",
- "repo": "flake-utils",
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
"type": "github"
}
},
@@ -58,7 +60,7 @@
"root": {
"inputs": {
"fenix": "fenix",
- "flake-utils": "flake-utils",
+ "flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"treefmt-nix": "treefmt-nix"
}
@@ -80,21 +82,6 @@
"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"
- }
- },
"treefmt-nix": {
"inputs": {
"nixpkgs": [
diff --git a/flake.nix b/flake.nix
index 86fdb2e1..4a4765d7 100644
--- a/flake.nix
+++ b/flake.nix
@@ -3,13 +3,17 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
- flake-utils.url = "github:numtide/flake-utils";
- # Provides Rust dev-env integration:
+
+ flake-parts = {
+ url = "github:hercules-ci/flake-parts";
+ inputs.nixpkgs-lib.follows = "nixpkgs";
+ };
+
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
- # Provides formatting infrastructure:
+
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
@@ -17,117 +21,113 @@
};
nixConfig = {
- # nix community cachix
extra-trusted-public-keys = "exo.cachix.org-1:okq7hl624TBeAR3kV+g39dUFSiaZgLRkLsFBCuJ2NZI=";
extra-substituters = "https://exo.cachix.org";
};
outputs =
inputs:
- let
+ inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-darwin"
"aarch64-linux"
];
- fenixToolchain = system: inputs.fenix.packages.${system}.complete;
- in
- inputs.flake-utils.lib.eachSystem systems (
- system:
- let
- pkgs = import inputs.nixpkgs {
- inherit system;
- overlays = [ inputs.fenix.overlays.default ];
- };
- treefmtEval = inputs.treefmt-nix.lib.evalModule pkgs {
- projectRootFile = "flake.nix";
- programs = {
- nixpkgs-fmt.enable = true;
- ruff-format = {
- enable = true;
- excludes = [ "rust/exo_pyo3_bindings/exo_pyo3_bindings.pyi" ];
- };
- rustfmt = {
- enable = true;
- package = (fenixToolchain system).rustfmt;
- };
- prettier = {
- enable = true;
- includes = [ "*.ts" ];
+
+ imports = [
+ inputs.treefmt-nix.flakeModule
+ ];
+
+ perSystem =
+ { config, inputs', pkgs, lib, ... }:
+ let
+ fenixToolchain = inputs'.fenix.packages.complete;
+ in
+ {
+ treefmt = {
+ projectRootFile = "flake.nix";
+ programs = {
+ nixpkgs-fmt.enable = true;
+ ruff-format = {
+ enable = true;
+ excludes = [ "rust/exo_pyo3_bindings/exo_pyo3_bindings.pyi" ];
+ };
+ rustfmt = {
+ enable = true;
+ package = fenixToolchain.rustfmt;
+ };
+ prettier = {
+ enable = true;
+ includes = [ "*.ts" ];
+ };
+ swift-format.enable = true;
};
- swift-format.enable = true;
};
- };
- in
- {
- formatter = treefmtEval.config.build.wrapper;
- checks.formatting = treefmtEval.config.build.check inputs.self;
- checks.lint = pkgs.runCommand "lint-check" { } ''
- export RUFF_CACHE_DIR="$TMPDIR/ruff-cache"
- ${pkgs.ruff}/bin/ruff check ${inputs.self}/
- touch $out
- '';
-
- devShells.default = pkgs.mkShell {
- packages =
- with pkgs;
- [
- # FORMATTING
- treefmtEval.config.build.wrapper
- # PYTHON
- python313
- uv
- ruff
- basedpyright
-
- # RUST
- ((fenixToolchain system).withComponents [
- "cargo"
- "rustc"
- "clippy"
- "rustfmt"
- "rust-src"
- ])
- rustup # Just here to make RustRover happy
-
- # NIX
- nixpkgs-fmt
-
- # SVELTE
- nodejs
-
- # MISC
- just
- jq
- ]
- ++ (pkgs.lib.optionals pkgs.stdenv.isLinux [
- # IFCONFIG
- unixtools.ifconfig
-
- # Build dependencies for Linux
- pkg-config
- openssl
- ])
- ++ (pkgs.lib.optionals pkgs.stdenv.isDarwin [
- # MACMON
- macmon
- ]);
-
- shellHook = ''
- # PYTHON
- export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.python313}/lib"
- ${pkgs.lib.optionalString pkgs.stdenv.isLinux ''
- # Build environment for Linux
- export PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
- export LD_LIBRARY_PATH="${pkgs.openssl.out}/lib:$LD_LIBRARY_PATH"
- ''}
- echo
- echo "🍎🍎 Run 'just <recipe>' to get started"
- just --list
+ checks.lint = pkgs.runCommand "lint-check" { } ''
+ export RUFF_CACHE_DIR="$TMPDIR/ruff-cache"
+ ${pkgs.ruff}/bin/ruff check ${inputs.self}/
+ touch $out
'';
+ devShells.default = with pkgs; pkgs.mkShell {
+ packages =
+ [
+ # FORMATTING
+ config.treefmt.build.wrapper
+
+ # PYTHON
+ python313
+ uv
+ ruff
+ basedpyright
+
+ # RUST
+ (fenixToolchain.withComponents [
+ "cargo"
+ "rustc"
+ "clippy"
+ "rustfmt"
+ "rust-src"
+ ])
+ rustup # Just here to make RustRover happy
+
+ # NIX
+ nixpkgs-fmt
+
+ # SVELTE
+ nodejs
+
+ # MISC
+ just
+ jq
+ ]
+ ++ (pkgs.lib.optionals pkgs.stdenv.isLinux [
+ # IFCONFIG
+ unixtools.ifconfig
+
+ # Build dependencies for Linux
+ pkg-config
+ openssl
+ ])
+ ++ (pkgs.lib.optionals pkgs.stdenv.isDarwin [
+ # MACMON
+ macmon
+ ]);
+
+ shellHook = ''
+ # PYTHON
+ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.python313}/lib"
+ ${lib.optionalString pkgs.stdenv.isLinux ''
+ # Build environment for Linux
+ export PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
+ export LD_LIBRARY_PATH="${pkgs.openssl.out}/lib:$LD_LIBRARY_PATH"
+ ''}
+ echo
+ echo "🍎🍎 Run 'just <recipe>' to get started"
+ just --list
+ '';
+ };
};
- }
- );
+ };
}
← e388f594 docs: add AGENTS.md for AI coding agents guidance (#1132)
·
back to Exo
·
up the rlimit (#1148) 47ceb54b →