Added nix flake for nix package manager compatibility. (#248)

* Added nix flake for nix package manager compatibility.

Co-authored-by: llamato <llamato@users.noreply.github.com>
Co-authored-by: enweave <enweave@gmail.com>
Co-authored-by: Quinten Muyllaert <72012305+QuintenMuyllaert@users.noreply.github.com>
This commit is contained in:
Llamato
2025-10-23 14:52:20 +02:00
committed by GitHub
parent d8fdd8cda1
commit 90f1dbd1ee
3 changed files with 79 additions and 0 deletions

View File

@@ -358,6 +358,8 @@ Files
- ``Makefile`` - make(1) file
- ``README`` - This file
- ``*.h`` and ``*.c`` - C code of F3
- ``flake.nix`` - nix package manager configuration allowing automatic building and or installation of repository contents.
- ``flake.lock`` - specifies build dependency package versions so the nix package manager can build f3
Bash scripts
------------

27
flake.lock generated Normal file
View File

@@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1759977445,
"narHash": "sha256-LYr4IDfuihCkFAkSYz5//gT2r1ewcWBYgd5AxPzPLIo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2dad7af78a183b6c486702c18af8a9544f298377",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

50
flake.nix Normal file
View File

@@ -0,0 +1,50 @@
{
description = "F3 - Fight flash fraud";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = { self, nixpkgs }: {
packages = nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" ] (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
f3 = pkgs.stdenv.mkDerivation {
pname = "f3";
version = builtins.head (builtins.match ''.*#define[[:space:]]+F3_STR_VERSION[[:space:]]+"([0-9.]+)".*'' (builtins.readFile (self + "/version.h")));
src = ./.;
nativeBuildInputs = [ pkgs.clang ];
buildInputs = [ pkgs.libusb1 pkgs.parted];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
make install PREFIX=$out
make install-extra PREFIX=$out
runHook postInstall
'';
meta = with pkgs.lib; {
description = "F3 - Fight flash fraud";
license = licenses.gpl3;
maintainers = [ maintainers.llamato ];
platforms = platforms.unix;
};
};
devShells.${system}.default = pkgs.mkShell {
buildInputs = with pkgs; [
cmake
gcc
gdb
];
};
});
defaultPackage = {
x86_64-linux = self.packages.x86_64-linux.f3;
aarch64-linux = self.packages.aarch64-linux.f3;
};
};
}