131
flake.nix
131
flake.nix
@@ -14,126 +14,49 @@
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
utils.url = github:numtide/flake-utils;
|
||||
flake-parts.url = github:hercules-ci/flake-parts;
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, utils, crane, rust-overlay, }:
|
||||
utils.lib.eachDefaultSystem
|
||||
(
|
||||
system:
|
||||
outputs = inputs@{ self, nixpkgs, crane, rust-overlay, flake-parts }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"i686-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
|
||||
imports = [
|
||||
./nix
|
||||
];
|
||||
|
||||
perSystem = { self', system, ... }:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ rust-overlay.overlays.default ];
|
||||
};
|
||||
|
||||
runtimeDependencies = with pkgs; [
|
||||
freetype
|
||||
fontconfig
|
||||
vulkan-loader
|
||||
];
|
||||
|
||||
xorgInputs = with pkgs; (with xorg; [
|
||||
libX11
|
||||
libXcursor
|
||||
libXrandr
|
||||
libXi
|
||||
]) ++ [
|
||||
# libxkbcommon
|
||||
# wayland
|
||||
];
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
cmake
|
||||
openssl.dev
|
||||
fontconfig.dev
|
||||
pkg-config
|
||||
]
|
||||
++ lib.optionals (with stdenv.hostPlatform; (isx86 || isi686 || isAarch64)) [ mold ]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ];
|
||||
|
||||
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain;
|
||||
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
|
||||
|
||||
src = craneLib.cleanCargoSource (craneLib.path ./.);
|
||||
filterWgsl = path: _: builtins.match ".*\.wgsl$" path != null;
|
||||
filterSrc = path: type:
|
||||
(filterWgsl path type) || (craneLib.filterCargoSources path type);
|
||||
|
||||
commonArgs = {
|
||||
inherit src nativeBuildInputs;
|
||||
buildInputs = xorgInputs;
|
||||
doCheck = false;
|
||||
src = pkgs.lib.cleanSourceWith {
|
||||
src = craneLib.path ./.;
|
||||
filter = filterSrc;
|
||||
};
|
||||
|
||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||
|
||||
torana = craneLib.buildPackage (commonArgs // {
|
||||
inherit cargoArtifacts runtimeDependencies;
|
||||
nativeBuildInputs = nativeBuildInputs ++ [ pkgs.autoPatchelfHook ];
|
||||
});
|
||||
|
||||
commonArgsWeb = {
|
||||
inherit src;
|
||||
cargoExtraArgs = "--target wasm32-unknown-unknown";
|
||||
doCheck = false;
|
||||
};
|
||||
|
||||
cargoArtifactsWeb = craneLib.buildDepsOnly commonArgsWeb;
|
||||
|
||||
toranaWeb = craneLib.buildPackage (commonArgsWeb // {
|
||||
inherit cargoArtifactsWeb;
|
||||
});
|
||||
|
||||
in
|
||||
rec {
|
||||
packages = {
|
||||
inherit torana toranaWeb toolchain;
|
||||
default = torana;
|
||||
|
||||
# not using flake checks to run them individually
|
||||
checks = {
|
||||
clippy = craneLib.cargoClippy (commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
});
|
||||
|
||||
fmt = craneLib.cargoFmt {
|
||||
inherit src;
|
||||
};
|
||||
|
||||
doc = craneLib.cargoDoc (commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
});
|
||||
|
||||
nextest = craneLib.cargoNextest (commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
partitions = 1;
|
||||
partitionType = "count";
|
||||
});
|
||||
};
|
||||
|
||||
_module.args = {
|
||||
inherit src craneLib toolchain pkgs;
|
||||
};
|
||||
|
||||
devShells = rec {
|
||||
torana = with pkgs;
|
||||
mkShell {
|
||||
name = "torana";
|
||||
nativeBuildInputs = nativeBuildInputs ++
|
||||
(with pkgs; [ wasm-bindgen toolchain ]);
|
||||
|
||||
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath
|
||||
(xorgInputs ++ runtimeDependencies);
|
||||
};
|
||||
|
||||
default = torana;
|
||||
|
||||
toranaWeb = with pkgs;
|
||||
mkShell {
|
||||
name = "toranaWeb";
|
||||
nativeBuildInputs = with pkgs; [
|
||||
wasm-bindgen-cli
|
||||
];
|
||||
};
|
||||
};
|
||||
formatter = pkgs.nixpkgs-fmt;
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user