Skip to content

Commit

Permalink
flake update
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Jul 3, 2024
1 parent e19c3e6 commit f1bef80
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 89 deletions.
21 changes: 9 additions & 12 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

206 changes: 129 additions & 77 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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;
}
);
}

0 comments on commit f1bef80

Please sign in to comment.