try 2 , nix run copies the script to a dir... without checking if it's there, i should add alternate store location to nix-ran version
This commit is contained in:
parent
9ace38e77c
commit
c583ad191d
4 changed files with 69 additions and 73 deletions
46
flake.lock
generated
46
flake.lock
generated
|
|
@ -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",
|
||||
|
|
|
|||
96
flake.nix
96
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} <<EOF
|
||||
#!/bin/sh
|
||||
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath zbarLibs}:\$LD_LIBRARY_PATH"
|
||||
|
||||
TARGET_DIR="\$HOME/.local/share/${packageName}"
|
||||
TARGET_FILE="\$TARGET_DIR/main.py"
|
||||
|
||||
mkdir -p "\$TARGET_DIR"
|
||||
|
||||
if [ ! -f "\$TARGET_FILE" ]; then
|
||||
echo "Installing main.py to \$TARGET_FILE..."
|
||||
cp "${scriptSource}" "\$TARGET_FILE"
|
||||
chmod +w "\$TARGET_FILE"
|
||||
fi
|
||||
|
||||
exec ${python}/bin/python3 "\$TARGET_FILE" "\$@"
|
||||
EOF
|
||||
|
||||
chmod +x $out/bin/${packageName}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue