From 1f72e01273ff0ff9bd16513f4c0a2c3a4f12ca41 Mon Sep 17 00:00:00 2001 From: TheK0tYaRa Date: Thu, 11 Dec 2025 01:56:20 +0200 Subject: [PATCH] nix flake complete, added alternative data storage option --- flake.nix | 74 ++++++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 39 deletions(-) diff --git a/flake.nix b/flake.nix index 2f0d765..c5c6e4c 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "Install main.py to data directory with dependencies"; + description = "py2fa-gtk packaged the Nix way"; inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11"; @@ -7,11 +7,8 @@ let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; - packageName = "py2fa-gtk"; - scriptSource = ./src/main.py; - # 1. Define Python environment - python = pkgs.python312.withPackages (ps: with ps; [ + pythonEnv = pkgs.python312.withPackages (ps: with ps; [ cryptography opencv-python pygobject3 @@ -19,52 +16,51 @@ pyzbar ]); - # 2. Define libraries for ZBar (shared object) - zbarLibs = [ pkgs.zbar ]; + runtimeLibs = with pkgs; [ + gtk3 + zbar + gobject-introspection + ]; in { packages.${system}.default = pkgs.stdenv.mkDerivation { - name = packageName; + name = "py2fa-gtk"; + + src = ./src; - nativeBuildInputs = [ pkgs.wrapGAppsHook3 ]; + nativeBuildInputs = [ + pkgs.wrapGAppsHook3 + pkgs.makeWrapper + ]; - buildInputs = with pkgs; [ - gtk3 - pango - gdk-pixbuf - atk - cairo - gobject-introspection - # Python env included here so the wrapper knows about it - python - ] ++ zbarLibs; + buildInputs = runtimeLibs ++ [ pythonEnv ]; - dontUnpack = true; + dontBuild = true; installPhase = '' - mkdir -p $out/bin + runHook preInstall - cat > $out/bin/${packageName} <