flake.nix: init #2

Merged
frero merged 2 commits from oysteikt/hanabee:flake-nix into main 2026-06-07 12:16:03 +02:00
3 changed files with 128 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
# Nix
result
result-*
Generated
+27
View File
@@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1780243769,
"narHash": "sha256-x5UQuRsH3MqI0U9afaXSNqzTPSeZlRLvFAav2Ux1pNw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "331800de5053fcebacf6813adb5db9c9dca22a0c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
+98
View File
@@ -0,0 +1,98 @@
{
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
];
};
});
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;
});
};
}