diff --git a/flake.lock b/flake.lock index 032fb8b..7d39aeb 100644 --- a/flake.lock +++ b/flake.lock @@ -1,59 +1,25 @@ { "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1751274312, - "narHash": "sha256-/bVBlRpECLVzjV19t5KMdMFWSwKLtb5RyXdjz3LJT+g=", - "owner": "NixOS", + "lastModified": 1765311797, + "narHash": "sha256-mSD5Ob7a+T2RNjvPvOA1dkJHGVrNVl8ZOrAwBjKBDQo=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "50ab793786d9de88ee30ec4e4c24fb4236fc2674", + "rev": "09eb77e94fa25202af8f3e81ddc7353d9970ac1b", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixos-24.11", + "owner": "nixos", + "ref": "nixos-25.11", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { - "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index ea75373..2f0d765 100644 --- a/flake.nix +++ b/flake.nix @@ -1,40 +1,70 @@ { - description = "run py2fa-gtk"; + description = "Install main.py to data directory with dependencies"; - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; - flake-utils.url = "github:numtide/flake-utils"; - }; + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11"; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - python = pkgs.python312 or pkgs.python3; - in { - devShells.default = pkgs.mkShell { - name = "py2fa-gtk-shell"; + outputs = { self, nixpkgs }: + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + packageName = "py2fa-gtk"; + scriptSource = ./src/main.py; - nativeBuildInputs = [ - pkgs.gobject-introspection - ]; + # 1. Define Python environment + python = pkgs.python312.withPackages (ps: with ps; [ + cryptography + opencv-python + pygobject3 + pyotp + pyzbar + ]); - buildInputs = [ - (python.withPackages (ps: with ps; [ - cryptography - opencv4 - pygobject3 - pyotp - pyzbar - ])) - pkgs.gtk3 - pkgs.zbar - ]; + # 2. Define libraries for ZBar (shared object) + zbarLibs = [ pkgs.zbar ]; - shellHook = '' - echo "Environment ready. Run the app with:" - echo " python main.py" - ''; - }; - }); + in + { + packages.${system}.default = pkgs.stdenv.mkDerivation { + name = packageName; + + nativeBuildInputs = [ pkgs.wrapGAppsHook3 ]; + + buildInputs = with pkgs; [ + gtk3 + pango + gdk-pixbuf + atk + cairo + gobject-introspection + # Python env included here so the wrapper knows about it + python + ] ++ zbarLibs; + + dontUnpack = true; + + installPhase = '' + mkdir -p $out/bin + + cat > $out/bin/${packageName} <