bevy-playground/flake.nix

105 lines
2.8 KiB
Nix
Raw Normal View History

2023-12-19 10:35:34 -06:00
{
2024-07-30 10:06:09 -05:00
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
git-hooks.url = "github:cachix/git-hooks.nix";
git-hooks.inputs.nixpkgs.follows = "nixpkgs";
};
2023-12-19 10:35:34 -06:00
outputs = {
self,
2024-07-30 10:06:09 -05:00
git-hooks,
2023-12-19 10:35:34 -06:00
nixpkgs,
}: let
2023-12-19 11:17:49 -06:00
inherit (self) outputs;
2024-07-30 10:06:09 -05:00
inherit (outputs) overlays;
systems = ["aarch64-linux" "aarch64-darwin" "x86_64-darwin" "x86_64-linux"];
forSystems = nixpkgs.lib.genAttrs systems;
pkgsFor = system: (import nixpkgs {inherit system;}).extend overlays.default;
genPkgs = func: (forSystems (system: func (pkgsFor system)));
2024-07-30 11:55:22 -05:00
buildTimeDeps = pkgs:
with pkgs; [
pkg-config
clang
mold
wayland
clang
2024-07-30 11:55:22 -05:00
];
linkTimeDeps = pkgs:
with pkgs; [
mold
wayland
clang
udev
alsa-lib
vulkan-loader
libxkbcommon
2024-07-30 11:55:22 -05:00
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
];
2023-12-19 10:35:34 -06:00
in {
2024-07-30 11:16:36 -05:00
checks = genPkgs (pkgs: {
git-hooks = git-hooks.lib.${pkgs.system}.run {
2024-07-30 10:06:09 -05:00
src = ./.;
hooks = {
alejandra.enable = true;
2024-07-30 11:16:36 -05:00
# NOTE: These do not work well with `nix flake check` due to pure environments
# https://github.com/cachix/git-hooks.nix/issues/452
# cargo-check.enable = true;
# clippy = {
# enable = true;
# packageOverrides.cargo = pkgs.cargo;
# packageOverrides.clippy = pkgs.rustPackages.clippy;
# };
rustfmt = {
enable = true;
packageOverrides.rustfmt = pkgs.rustfmt;
};
2024-07-30 10:06:09 -05:00
};
};
2024-07-30 11:16:36 -05:00
build = outputs.packages.${pkgs.system}.default;
2024-07-30 10:06:09 -05:00
});
packages = genPkgs (pkgs: {
kodotag = pkgs.rustPlatform.buildRustPackage {
pname = "kodotag";
version = "0.1.0";
2024-07-30 11:55:22 -05:00
nativeBuildInputs = buildTimeDeps pkgs;
buildInputs = linkTimeDeps pkgs;
2024-07-30 10:06:09 -05:00
src = ./.;
hash = pkgs.lib.fakeHash;
2024-07-30 11:46:52 -05:00
# cargoHash = pkgs.lib.fakeHash;
cargoHash = "sha256-pXyMRYFpG9hr0itt5izAF+HDAL6m7ktHAnV7sPSwzp4=";
2024-07-30 11:16:36 -05:00
# a hack to avoid using mold as our linker when building with nix
postUnpack = ''
ls -la
rm -r ./*/.cargo
'';
2023-12-19 10:35:34 -06:00
};
2024-07-30 10:06:09 -05:00
default = outputs.packages.${pkgs.system}.kodotag;
2023-12-19 10:35:34 -06:00
});
2024-07-30 10:06:09 -05:00
2024-07-30 11:16:36 -05:00
devShells = genPkgs (pkgs: {
default = pkgs.mkShell {
inherit (self.checks.${pkgs.system}.git-hooks) shellHook;
inputsFrom = [outputs.packages.${pkgs.system}.default];
packages = with pkgs; [
rustPackages.clippy
rust-analyzer
rustfmt
];
2024-07-30 11:55:22 -05:00
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (linkTimeDeps pkgs);
2024-07-30 11:16:36 -05:00
};
});
2024-07-30 10:06:09 -05:00
overlays = {
default = final: prev: {};
};
formatter = genPkgs (p: p.alejandra);
2023-12-19 10:35:34 -06:00
};
}