From d103d017874fe49e576ecebf866ab9282017c8ee Mon Sep 17 00:00:00 2001 From: Simon Scatton Date: Wed, 27 May 2026 14:47:00 +0200 Subject: [PATCH 1/4] feat(build): add simple nix flake with formatter for nix code --- flake.lock | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 42 ++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..039c07ccf --- /dev/null +++ b/flake.lock @@ -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": 1779560665, + "narHash": "sha256-tpyBcxPpcQb8ukyNF7DoCwfSY3VPsxHoYwj00Cayv5o=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "64c08a7ca051951c8eae34e3e3cb1e202fe36786", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "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": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1775636079, + "narHash": "sha256-pc20NRoMdiar8oPQceQT47UUZMBTiMdUuWrYu2obUP0=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "790751ff7fd3801feeaf96d7dc416a8d581265ba", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..4abd2ff10 --- /dev/null +++ b/flake.nix @@ -0,0 +1,42 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +{ + description = "OpenShell development environment"; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + { + flake-utils, + nixpkgs, + treefmt-nix, + ... + }: + flake-utils.lib.eachSystem [ "x86_64-linux" ] ( + system: + let + pkgs = import nixpkgs { + inherit system; + }; + treefmtEval = treefmt-nix.lib.evalModule pkgs { + projectRootFile = "flake.nix"; + programs.nixfmt.enable = true; + }; + in + { + devShells.default = pkgs.mkShell { + packages = [ ]; + }; + + formatter = treefmtEval.config.build.wrapper; + } + ); +} From 4c2162a4dca4c5371e8a71b4cad731ba306f420a Mon Sep 17 00:00:00 2001 From: Simon Scatton Date: Wed, 27 May 2026 14:59:43 +0200 Subject: [PATCH 2/4] feat(flake): setup rust toolchain, able to build and run unit tests --- flake.lock | 21 +++++++++++++++++++++ flake.nix | 21 ++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/flake.lock b/flake.lock index 039c07ccf..7b9881771 100644 --- a/flake.lock +++ b/flake.lock @@ -38,9 +38,30 @@ "inputs": { "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay", "treefmt-nix": "treefmt-nix" } }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1779851998, + "narHash": "sha256-UkkMh3bX9QW4Luqkm98nUaOqKWrU6i65mUnph3WeSSw=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "6cddd512fa2bf7231f098d3a2f92f6e4cff71e0a", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index 4abd2ff10..f5393ceca 100644 --- a/flake.nix +++ b/flake.nix @@ -7,6 +7,10 @@ inputs = { flake-utils.url = "github:numtide/flake-utils"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; treefmt-nix = { url = "github:numtide/treefmt-nix"; inputs.nixpkgs.follows = "nixpkgs"; @@ -17,6 +21,7 @@ { flake-utils, nixpkgs, + rust-overlay, treefmt-nix, ... }: @@ -25,7 +30,9 @@ let pkgs = import nixpkgs { inherit system; + overlays = [ (import rust-overlay) ]; }; + rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; treefmtEval = treefmt-nix.lib.evalModule pkgs { projectRootFile = "flake.nix"; programs.nixfmt.enable = true; @@ -33,7 +40,19 @@ in { devShells.default = pkgs.mkShell { - packages = [ ]; + packages = with pkgs; [ + rustToolchain + # Required to find packages + pkg-config + # Required for bindgen generation. + llvmPackages.libclang + # system dependency for openshell-prover + z3 + ]; + + env = { + LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; + }; }; formatter = treefmtEval.config.build.wrapper; From 4517ae3679f77652e9c05441a9732f30c9556f8a Mon Sep 17 00:00:00 2001 From: Simon Scatton Date: Wed, 27 May 2026 16:13:25 +0200 Subject: [PATCH 3/4] feat(flake): add support for arm linux and macos --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index f5393ceca..13c4857bc 100644 --- a/flake.nix +++ b/flake.nix @@ -25,7 +25,7 @@ treefmt-nix, ... }: - flake-utils.lib.eachSystem [ "x86_64-linux" ] ( + flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ] ( system: let pkgs = import nixpkgs { From 95a4bcb7c80a37cb8b2a752be69ea383fc6e7e41 Mon Sep 17 00:00:00 2001 From: Simon Scatton Date: Wed, 27 May 2026 16:35:51 +0200 Subject: [PATCH 4/4] feat(toolchain): add rust-src and rust-analyzer to the toolchain --- rust-toolchain.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 26a307fdf..13beef5d1 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -3,3 +3,4 @@ [toolchain] channel = "1.95.0" +components = [ "rustfmt", "rust-src", "rust-analyzer" ]