{
description = "RocketCar is an online training tool for Rocket League car control";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, crane, flake-utils, fenix, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
fenix.overlays.default
];
};
craneLib = crane.lib.${system}.overrideToolchain
fenix.packages.${system}.stable.toolchain;
windowsToolchain = with fenix.packages.${system};
combine [
stable.rustc
stable.cargo
targets.x86_64-pc-windows-gnu.stable.rust-std
];
windowsCraneLib = (crane.mkLib pkgs).overrideToolchain windowsToolchain;
buildInputs = with pkgs; [
# Add additional build inputs here
alsa-lib
udev
libxkbcommon
wayland
vulkan-loader
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
];
nativeBuildInputs = with pkgs; [
pkg-config
];
commonArgs = {
inherit buildInputs nativeBuildInputs;
src = ./.;
};
# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
# Additional arguments specific to this derivation can be added here.
# Be warned that using `//` will not do a deep copy of nested
# structures
pname = "rocketcar";
});
rocketcar = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
postInstall = ''
cp -r assets $out/bin
'';
});
rocketcar-windows = windowsCraneLib.buildPackage {
src = ./.;
strictDeps = true;
doCheck = false;
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
depsBuildBuild = with pkgs; [
pkgsCross.mingwW64.stdenv.cc
pkgsCross.mingwW64.windows.pthreads
];
installPhase = ''
cp -r assets $out/bin
'';
};
in
{
checks = {
inherit rocketcar;
};
packages.default = rocketcar;
packages.rocketcar-windows = rocketcar-windows;
apps.default = flake-utils.lib.mkApp {
drv = rocketcar;
};
devShells.default = pkgs.mkShell {
inherit buildInputs;
nativeBuildInputs = nativeBuildInputs ++ [
(fenix.packages.${system}.stable.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
])
];
inputsFrom = builtins.attrValues self.checks;
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
};
});
}