diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..0b6568c5f --- /dev/null +++ b/flake.lock @@ -0,0 +1,96 @@ +{ + "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": 1747542820, + "narHash": "sha256-GaOZntlJ6gPPbbkTLjbd8BMWaDYafhuuYRNrxCGnPJw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "292fa7d4f6519c074f0a50394dbbe69859bb6043", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1747622321, + "narHash": "sha256-W0dYIWgsUu6rvOJRtKLhKskkv0VhQhJYGNIq+gGUc8g=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "bd030fd9983f7fddf87be1c64aa3064c8afa24c4", + "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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..1fbe1045d --- /dev/null +++ b/flake.nix @@ -0,0 +1,62 @@ +{ + description = "Honeycomb development & build environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay.url = "github:oxalica/rust-overlay"; + }; + + outputs = { self, nixpkgs, flake-utils, rust-overlay }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ rust-overlay.overlays.default ]; + }; + + # Rust toolchain with extensions + rustToolchain = pkgs.rust-bin.stable.latest.default.override { + extensions = [ "rust-src" ]; + }; + + # Platform-specific build inputs + linuxBuildInputs = with pkgs; [ + xorg.libX11 + xorg.libXcursor + xorg.libXi + libxkbcommon + xorg.libxcb + libudev-zero + vulkan-loader + glfw + ]; + + buildInputs = with pkgs; [ + hwloc.dev + ] ++ (if pkgs.stdenv.isLinux then linuxBuildInputs else []); + + # Platform-specific LD_LIBRARY_PATH + ldLibraryPath = pkgs.lib.makeLibraryPath ( + [ pkgs.hwloc.lib ] ++ + (if pkgs.stdenv.isLinux then linuxBuildInputs else []) + ); + + in + { + devShells.default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + rustToolchain + cargo + rust-analyzer + pkg-config + ]; + + buildInputs = buildInputs; + + shellHook = '' + export LD_LIBRARY_PATH=${ldLibraryPath}:$LD_LIBRARY_PATH + ''; + }; + }); +} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index a0adf5176..000000000 --- a/shell.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ pkgs ? import {} }: - -pkgs.mkShell { - buildInputs = with pkgs; [ - # Rust - rustup - # Render tool libs - xorg.libX11 - xorg.libXcursor - xorg.libXi - libxkbcommon - xorg.libxcb - libudev-zero - ]; - - # Render tool libs - LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${ - with pkgs; - pkgs.lib.makeLibraryPath [ - xorg.libX11 - xorg.libXcursor - xorg.libXi - libxkbcommon - xorg.libxcb - pkgs.vulkan-loader - pkgs.glfw - ] - }"; - - # Shell hook to set up the environment - shellHook = '' - # Initialize rustup if not already done - if [ ! -d "$HOME/.rustup" ]; then - rustup default stable - rustup component add rust-analyzer - fi - ''; -}