diff --git a/flake.lock b/flake.lock index 8273930..32b8283 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1717469187, - "narHash": "sha256-UVvFGiWFGPfVXG7Xr6HPKChx9hhtzkGaGAS/Ph1Khjg=", + "lastModified": 1720025378, + "narHash": "sha256-zlIdj0oLvMEHlllP/7tvY+kE987xsN4FPux6WHSOh00=", "owner": "ipetkov", "repo": "crane", - "rev": "7e86136dc729cdf237aa59a5a02687bc0d1144b6", + "rev": "087e08a41009bf083d51ab35d8e30b1b7eafa7b0", "type": "github" }, "original": { @@ -40,11 +40,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1717196966, - "narHash": "sha256-yZKhxVIKd2lsbOqYd5iDoUIwsRZFqE87smE2Vzf6Ck0=", + "lastModified": 1719848872, + "narHash": "sha256-H3+EC5cYuq+gQW8y0lSrrDZfH71LB4DAf+TDFyvwCNA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "57610d2f8f0937f39dbd72251e9614b1561942d8", + "rev": "00d80d13810dbfea8ab4ed1009b09100cca86ba8", "type": "github" }, "original": { @@ -64,19 +64,16 @@ }, "rust-overlay": { "inputs": { - "flake-utils": [ - "flake-utils" - ], "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1717467480, - "narHash": "sha256-9Fbar+ycxdfZ6HbwOCgD+jWG3du/12TFisKRQm4Zhfc=", + "lastModified": 1719973106, + "narHash": "sha256-IGCdN/m7DfwUfxZjFnlTiTtpwSHCb01P/LWavAKD2jw=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "260ff391290a2b23958d04db0d3e7015c8417401", + "rev": "fb733500aead50880b9b301f34a0061bf997d6f2", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 4dfb232..aa52a9a 100644 --- a/flake.nix +++ b/flake.nix @@ -10,48 +10,58 @@ url = "github:oxalica/rust-overlay"; inputs = { nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; }; }; }; - outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }: - flake-utils.lib.eachDefaultSystem (localSystem: + outputs = + { + self, + nixpkgs, + crane, + flake-utils, + rust-overlay, + ... + }: + flake-utils.lib.eachDefaultSystem ( + localSystem: let pkgs = import nixpkgs { inherit localSystem; overlays = [ (import rust-overlay) ]; }; - inherit (pkgs) lib; - - rustToolchain = - pkgs.pkgsBuildHost.rust-bin.stable.latest.default.override { - targets = [ "wasm32-unknown-unknown" ]; - }; + rustToolchain = pkgs.pkgsBuildHost.rust-bin.stable.latest.default.override { + targets = [ "wasm32-unknown-unknown" ]; + }; craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; commonArgs = { - src = lib.cleanSource ./.; + src = pkgs.lib.cleanSource ./.; strictDeps = true; - buildInputs = lib.optionals pkgs.stdenv.isLinux (with pkgs; [ - alsa-lib - alsa-lib.dev - libxkbcommon - udev - vulkan-loader - wayland - xorg.libX11 - xorg.libXcursor - xorg.libXi - xorg.libXrandr - ]) ++ lib.optionals pkgs.stdenv.isDarwin - (with pkgs; [ pkgs.darwin.apple_sdk.frameworks.Cocoa ]); - - nativeBuildInputs = with pkgs; + buildInputs = + pkgs.lib.optionals pkgs.stdenv.isLinux ( + with pkgs; + [ + alsa-lib + alsa-lib.dev + libxkbcommon + udev + vulkan-loader + wayland + xorg.libX11 + xorg.libXcursor + xorg.libXi + xorg.libXrandr + ] + ) + ++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs; [ darwin.apple_sdk.frameworks.Cocoa ]); + + nativeBuildInputs = + with pkgs; [ binaryen cargo-auditable @@ -60,64 +70,99 @@ trunk wasm-bindgen-cli wasm-tools - ] ++ lib.optionals (!pkgs.stdenv.isDarwin) - (with pkgs; [ alsa-lib alsa-lib.dev ]); + ] + ++ lib.optionals (!stdenv.isDarwin) [ + alsa-lib + alsa-lib.dev + ]; }; commonShell = { checks = self.checks.${localSystem}; - packages = with pkgs; [ cargo-rdme cargo-watch rust-analyzer ]; + packages = with pkgs; [ + cargo-rdme + cargo-watch + rust-analyzer + ]; LD_LIBRARY_PATH = (pkgs.lib.makeLibraryPath commonArgs.buildInputs); }; - cargoArtifacts = - craneLib.buildDepsOnly (commonArgs // { pname = "deps"; }); - - cargoArtifactsWasm = craneLib.buildDepsOnly (commonArgs // { - pname = "deps-wasm"; - doCheck = false; - }); - - cargoClippy = craneLib.cargoClippy (commonArgs // { - inherit cargoArtifacts; - pname = "clippy"; - }); - - cargoDoc = craneLib.cargoDoc (commonArgs // { - inherit cargoArtifacts; - pname = "doc"; - }); - - bevy_gltf_kun = craneLib.buildPackage (commonArgs // { - inherit cargoArtifacts; - pname = "bevy_gltf_kun"; - cargoExtraArgs = "-p bevy_gltf_kun"; - }); - - gltf_kun = craneLib.buildPackage (commonArgs // { - inherit cargoArtifacts; - pname = "gltf_kun"; - cargoExtraArgs = "-p gltf_kun --all-features"; - }); - - web = craneLib.buildTrunkPackage (commonArgs // { - inherit cargoArtifactsWasm; - pname = "bevy_example"; - cargoExtraArgs = "-p bevy_example --target wasm32-unknown-unknown"; - trunkExtraBuildArgs = "--public-url gltf_kun"; - - src = lib.cleanSourceWith { - src = ./.; - filter = path: type: - (lib.hasSuffix ".html" path) || (lib.hasInfix "/assets/" path) - || (craneLib.filterCargoSources path type); - }; - - wasm-bindgen-cli = pkgs.wasm-bindgen-cli; - }); - in { - checks = { inherit gltf_kun bevy_gltf_kun web cargoClippy cargoDoc; }; + cargoArtifacts = craneLib.buildDepsOnly (commonArgs // { pname = "deps"; }); + + cargoArtifactsWasm = craneLib.buildDepsOnly ( + commonArgs + // { + pname = "deps-wasm"; + doCheck = false; + } + ); + + cargoClippy = craneLib.cargoClippy ( + commonArgs + // { + inherit cargoArtifacts; + pname = "clippy"; + } + ); + + cargoDoc = craneLib.cargoDoc ( + commonArgs + // { + inherit cargoArtifacts; + pname = "doc"; + } + ); + + bevy_gltf_kun = craneLib.buildPackage ( + commonArgs + // { + inherit cargoArtifacts; + pname = "bevy_gltf_kun"; + cargoExtraArgs = "-p bevy_gltf_kun"; + } + ); + + gltf_kun = craneLib.buildPackage ( + commonArgs + // { + inherit cargoArtifacts; + pname = "gltf_kun"; + cargoExtraArgs = "-p gltf_kun --all-features"; + } + ); + + web = craneLib.buildTrunkPackage ( + commonArgs + // { + inherit cargoArtifactsWasm; + pname = "bevy_example"; + cargoExtraArgs = "-p bevy_example --target wasm32-unknown-unknown"; + trunkExtraBuildArgs = "--public-url gltf_kun"; + + src = pkgs.lib.cleanSourceWith { + src = ./.; + filter = + path: type: + (pkgs.lib.hasSuffix ".html" path) + || (pkgs.lib.hasInfix "/assets/" path) + || (craneLib.filterCargoSources path type); + }; + + wasm-bindgen-cli = pkgs.wasm-bindgen-cli; + } + ); + in + { + checks = { + inherit + gltf_kun + bevy_gltf_kun + web + cargoClippy + cargoDoc + ; + }; apps = { generate-readme = flake-utils.lib.mkApp { @@ -138,10 +183,17 @@ default = pkgs.symlinkJoin { name = "all"; - paths = [ bevy_gltf_kun gltf_kun web ]; + paths = [ + bevy_gltf_kun + gltf_kun + web + ]; }; }; devShells.default = craneLib.devShell commonShell; - }); + + formatter = pkgs.nixfmt-rfc-style; + } + ); }