forked from frero/hanabi
100 lines
2.2 KiB
Nix
100 lines
2.2 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
};
|
|
|
|
outputs = { self, nixpkgs }:
|
|
let
|
|
inherit (nixpkgs) lib;
|
|
|
|
systems = [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
"x86_64-darwin"
|
|
"aarch64-darwin"
|
|
"armv7l-linux"
|
|
];
|
|
|
|
forAllSystems = f: lib.genAttrs systems (system: f system nixpkgs.legacyPackages.${system});
|
|
in {
|
|
apps = let
|
|
mkApp = program: description: {
|
|
type = "app";
|
|
program = toString program;
|
|
meta = {
|
|
inherit description;
|
|
};
|
|
};
|
|
in forAllSystems (system: pkgs: {
|
|
default = self.apps.${system}.hanabi;
|
|
hanabi = mkApp (lib.getExe self.packages.${system}.hanabi) "Run the hanabi executable";
|
|
});
|
|
|
|
devShells = forAllSystems (system: pkgs: {
|
|
default = pkgs.mkShell {
|
|
nativeBuildInputs = with pkgs; [
|
|
odin
|
|
nushell
|
|
];
|
|
};
|
|
});
|
|
|
|
overlays = {
|
|
default = self.overlays.hanabi;
|
|
hanabi = final: prev: {
|
|
inherit (self.packages.${prev.stdenv.hostPlatform.system}) hanabi;
|
|
};
|
|
};
|
|
|
|
packages = forAllSystems (system: pkgs: {
|
|
default = self.packages.${system}.hanabi;
|
|
hanabi = pkgs.stdenv.mkDerivation {
|
|
name = "hanabi";
|
|
version = "unstable";
|
|
src = ./src;
|
|
|
|
nativeBuildInputs = with pkgs; [ odin ];
|
|
|
|
buildPhase = let
|
|
optionFormat = optionName: {
|
|
option = "-${optionName}";
|
|
sep = ":";
|
|
explicitBool = true;
|
|
};
|
|
|
|
buildOpts = lib.cli.toCommandLineShell optionFormat {
|
|
build-mode = "exe";
|
|
out = "hanabi";
|
|
o = "speed";
|
|
lto = "thin";
|
|
};
|
|
in ''
|
|
runHook preBuild
|
|
|
|
odin build . ${buildOpts}
|
|
|
|
runHook postBuild
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
install -Dm555 hanabi -t "$out/bin"
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
meta = {
|
|
license = lib.licenses.agpl3Only;
|
|
homepage = "https://git.pvv.ntnu.no/frero/hanabi";
|
|
mainProgram = "hanabi";
|
|
};
|
|
};
|
|
});
|
|
|
|
checks = forAllSystems (system: pkgs: {
|
|
inherit (self.packages.${system}) hanabi;
|
|
});
|
|
};
|
|
}
|