From 3296a0a4bae8da176910f315cf9225bb17169986 Mon Sep 17 00:00:00 2001 From: awtterpip Date: Mon, 15 Apr 2024 15:02:22 -0500 Subject: [PATCH] update flake.nix --- flake.lock | 99 +++++++++++++++++++++-------- flake.nix | 149 ++++++++++++++++++++++---------------------- rust-toolchain.toml | 4 -- 3 files changed, 146 insertions(+), 106 deletions(-) delete mode 100644 rust-toolchain.toml diff --git a/flake.lock b/flake.lock index 120eaa0..05fdd44 100644 --- a/flake.lock +++ b/flake.lock @@ -2,9 +2,7 @@ "nodes": { "fenix": { "inputs": { - "nixpkgs": [ - "nixpkgs" - ], + "nixpkgs": "nixpkgs", "rust-analyzer-src": "rust-analyzer-src" }, "locked": { @@ -21,18 +19,82 @@ "type": "github" } }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1698420672, + "narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=", + "owner": "nix-community", + "repo": "naersk", + "rev": "aeb58d5e8faead8980a807c840232697982d47b9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1711001935, - "narHash": "sha256-URtGpHue7HHZK0mrHnSf8wJ6OmMKYSsoLmJybrOLFSQ=", + "lastModified": 1712963716, + "narHash": "sha256-WKm9CvgCldeIVvRz87iOMi8CFVB1apJlkUT4GGvA0iM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "cfd6b5fc90b15709b780a5a1619695a88505a176", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 0, + "narHash": "sha256-vMZ5603yU0wxgyQeHJryOI+O61yrX2AHwY6LOFyV1gM=", + "path": "/nix/store/450afzqlzzgw6wnyc3dwysf3i5yxyqkr-source", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1713128889, + "narHash": "sha256-aB90ZqzosyRDpBh+rILIcyP5lao8SKz8Sr2PSWvZrzk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "20f77aa09916374aa3141cbc605c955626762c9a", + "rev": "2748d22b45a99fb2deafa5f11c7531c212b2cefa", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -40,8 +102,9 @@ "root": { "inputs": { "fenix": "fenix", - "nixpkgs": "nixpkgs", - "utils": "utils" + "flake-utils": "flake-utils", + "naersk": "naersk", + "nixpkgs": "nixpkgs_3" } }, "rust-analyzer-src": { @@ -75,24 +138,6 @@ "repo": "default", "type": "github" } - }, - "utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index db1b68e..58749d8 100644 --- a/flake.nix +++ b/flake.nix @@ -1,93 +1,92 @@ { - description = "bevy xr flake"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - # eachDefaultSystem and other utility functions - utils.url = "github:numtide/flake-utils"; - # Replacement for rustup - fenix = { - url = "github:nix-community/fenix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + fenix.url = "github:nix-community/fenix"; + flake-utils.url = "github:numtide/flake-utils"; + naersk.url = "github:nix-community/naersk"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; }; outputs = { self, - nixpkgs, - utils, fenix, + flake-utils, + naersk, + nixpkgs, }: - # This helper function abstracts over the host platform. - # See https://github.com/numtide/flake-utils#eachdefaultsystem--system---attrs - utils.lib.eachDefaultSystem ( + flake-utils.lib.eachDefaultSystem ( system: let pkgs = nixpkgs.legacyPackages.${system}; - # Brings in the rust toolchain from the standard file - # that rustup/cargo uses. - rustToolchain = fenix.packages.${system}.fromToolchainFile { - file = ./rust-toolchain.toml; - sha256 = "sha256-+syqAd2kX8KVa8/U2gz3blIQTTsYYt3U63xBWaGOSc8="; - }; + rustToolchain = with fenix.packages.${system}; + combine [ + (stable.withComponents [ + "rustc" + "cargo" + "rustfmt" + "clippy" + "rust-src" + ]) + + targets.wasm32-unknown-unknown.stable.rust-std + ]; rustPlatform = pkgs.makeRustPlatform { inherit (rustToolchain) cargo rustc; }; - in - # See https://nixos.wiki/wiki/Flakes#Output_schema - { - # `nix develop` pulls all of this in to become your shell. - devShells.default = pkgs.mkShell rec { - nativeBuildInputs = with pkgs; [ - rustToolchain - pkg-config + in { + devShells.default = pkgs.mkShell rec { + # build dependencies + nativeBuildInputs = with pkgs; [ + rustToolchain + pkg-config - # Common cargo tools we often use - cargo-deny - cargo-expand - cargo-binutils - # cmake for openxr - cmake + # Common cargo tools we often use + cargo-deny + cargo-expand + cargo-binutils + + # cmake for openxr + cmake + ]; + + # runtime dependencies + buildInputs = + [ + pkgs.zstd + ] + ++ pkgs.lib.optionals pkgs.stdenv.isLinux (with pkgs; [ + # bevy dependencies + udev + alsa-lib + # vulkan + vulkan-loader + vulkan-headers + vulkan-tools + vulkan-validation-layers + # x11 + xorg.libX11 + xorg.libXcursor + xorg.libXi + xorg.libXrandr + # wayland + libxkbcommon + wayland + # xr + openxr-loader + libGL + ]) + ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ + pkgs.darwin.apple_sdk.frameworks.Cocoa + rustPlatform.bindgenHook + # # This is missing on mac m1 nix, for some reason. + # # see https://stackoverflow.com/a/69732679 + pkgs.libiconv ]; - # see https://github.com/NixOS/nixpkgs/blob/95b81c96f863ca8911dffcda45d1937efcd66a4b/pkgs/games/jumpy/default.nix#L60C5-L60C38 - buildInputs = - [ - pkgs.zstd - ] - ++ pkgs.lib.optionals pkgs.stdenv.isLinux (with pkgs; [ - # bevy dependencies - udev - alsa-lib - # vulkan - vulkan-loader - vulkan-headers - vulkan-tools - vulkan-validation-layers - # x11 - xorg.libX11 - xorg.libXcursor - xorg.libXi - xorg.libXrandr - # wayland - libxkbcommon - wayland - # xr - openxr-loader - libGL - ]) - ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ - pkgs.darwin.apple_sdk.frameworks.Cocoa - rustPlatform.bindgenHook - # # This is missing on mac m1 nix, for some reason. - # # see https://stackoverflow.com/a/69732679 - pkgs.libiconv - ]; - - LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs; - # this is most likely not needed. for some reason shadows flicker without it. - AMD_VULKAN_ICD = "RADV"; - }; - # This only formats the nix files. - formatter = pkgs.nixpkgs-fmt; - } + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs; + # this is most likely not needed. for some reason shadows flicker without it. + AMD_VULKAN_ICD = "RADV"; + }; + # This only formats the nix files. + formatter = pkgs.nixpkgs-fmt; + } ); } diff --git a/rust-toolchain.toml b/rust-toolchain.toml deleted file mode 100644 index fba7d7e..0000000 --- a/rust-toolchain.toml +++ /dev/null @@ -1,4 +0,0 @@ -[toolchain] -channel = "1.77.0" -components = ["rust-src", "rust-analyzer"] -profile = "default" \ No newline at end of file