66 lines
1.8 KiB
Nix
66 lines
1.8 KiB
Nix
{
|
|
description = "py2fa-gtk packaged the Nix way";
|
|
|
|
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
|
|
|
|
outputs = { self, nixpkgs }:
|
|
let
|
|
system = "x86_64-linux";
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
pythonEnv = pkgs.python312.withPackages (ps: with ps; [
|
|
cryptography
|
|
opencv-python
|
|
pygobject3
|
|
pyotp
|
|
pyzbar
|
|
]);
|
|
|
|
runtimeLibs = with pkgs; [
|
|
gtk3
|
|
zbar
|
|
gobject-introspection
|
|
];
|
|
|
|
in
|
|
{
|
|
packages.${system}.default = pkgs.stdenv.mkDerivation {
|
|
name = "py2fa-gtk";
|
|
|
|
src = ./src;
|
|
|
|
nativeBuildInputs = [
|
|
pkgs.wrapGAppsHook3
|
|
pkgs.makeWrapper
|
|
];
|
|
|
|
buildInputs = runtimeLibs ++ [ pythonEnv ];
|
|
|
|
dontBuild = true;
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
# A. Create standard directory structure in the Nix Store
|
|
mkdir -p $out/bin $out/share/py2fa-gtk
|
|
|
|
# B. Copy the python script to the store (Read-Only)
|
|
cp main.py $out/share/py2fa-gtk/main.py
|
|
|
|
# C. Create the binary executable
|
|
# We wrap the python executable.
|
|
# 1. We tell it to run our specific script.
|
|
# 2. We inject the ZBar library path so pyzbar works.
|
|
makeWrapper ${pythonEnv}/bin/python3 $out/bin/py2fa-gtk \
|
|
--add-flags "$out/share/py2fa-gtk/main.py" \
|
|
--prefix LD_LIBRARY_PATH : "${pkgs.lib.makeLibraryPath [ pkgs.zbar ]}"
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
# wrapGAppsHook runs automatically after installPhase.
|
|
# It will see the binary in $out/bin/py2fa-gtk and double-wrap it
|
|
# to inject XDG_DATA_DIRS and GI_TYPELIB_PATH (fixing Pango/GTK).
|
|
};
|
|
};
|
|
}
|