From c535a9c375077a533bed28a9166f1d1bf3ca04ec Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Fri, 4 Oct 2024 16:36:55 +0200 Subject: [PATCH] Add flake --- flake.lock | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 73 +++++++++++++++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..507056d --- /dev/null +++ b/flake.lock @@ -0,0 +1,131 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1722113426, + "narHash": "sha256-Yo/3loq572A8Su6aY5GP56knpuKYRvM2a1meP9oJZCw=", + "owner": "numtide", + "repo": "devshell", + "rev": "67cce7359e4cd3c45296fb4aaf6a19e2a9c757ae", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1722073938, + "narHash": "sha256-OpX0StkL8vpXyWOGUD6G+MA26wAXK6SpT94kLJXo6B4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e36e9f57337d0ff0cf77aceb58af4c805472bfae", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1728031656, + "narHash": "sha256-JXumn7X+suKEcehp4rchSvBzIboqyybQ5bLK4wk7gQU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "eeeb90a1dd3c9bea3afdbc76fd34d0fb2a727c7a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1718428119, + "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devshell": "devshell", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1728008962, + "narHash": "sha256-MjGMCVKqafsrqLQYJHHKXJkvocTjkxKjadBfN952/Zw=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "862d0c1e5fe2348a22044f225afef39b75df8cf0", + "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 0000000..e5417e4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,73 @@ +{ + description = "Rust Environment"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.devshell.url = "github:numtide/devshell"; + inputs.rust-overlay.url = "github:oxalica/rust-overlay"; + + outputs = { + self, + lib, + nixpkgs, + flake-utils, + devshell, + rust-overlay, + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; # For clion + overlays = [ + devshell.overlays.default + rust-overlay.overlays.default + ]; + }; + + # Includes cargo, rustc, rustfmt + rust-stable = pkgs.rust-bin.stable.latest.default.override { + extensions = ["rust-src"]; # Include the rust stdlib source for intellij + }; + in { + devShell = pkgs.devshell.mkShell { + name = "Rust Environment"; + + packages = with pkgs; [ + gcc14 + rust-stable + # rust-analyzer # System install + + # Bevy Dependencies: https://github.com/bevyengine/bevy/blob/release-0.14.2/docs/linux_dependencies.md#nix + pkg-config + udev + alsa-lib + vulkan-loader + libxkbcommon + wayland + ]; + + env = [ + # Allow for intellij to find the stdlib + { + name = "RUST_SRC_PATH"; + value = "${rust-stable}/lib/rustlib/src/rust/library"; + } + + # Use this if the rust binary needs additional libraries + { + name = "LD_LIBRARY_PATH"; + value = lib.makeLibraryPath self.packages; + # value = "${pkgs.xorg.libX11}/lib:${pkgs.xorg.libXcursor}/lib:${pkgs.xorg.libXrandr}/lib:${pkgs.xorg.libXi}/lib:${pkgs.libGL}/lib"; + } + ]; + + commands = [ + # { + # name = "ide"; + # help = "Run clion for project"; + # command = "clion &>/dev/null ./ &"; + # } + ]; + }; + }); +}