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": {
|
"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": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1751274312,
|
"lastModified": 1765311797,
|
||||||
"narHash": "sha256-/bVBlRpECLVzjV19t5KMdMFWSwKLtb5RyXdjz3LJT+g=",
|
"narHash": "sha256-mSD5Ob7a+T2RNjvPvOA1dkJHGVrNVl8ZOrAwBjKBDQo=",
|
||||||
"owner": "NixOS",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "50ab793786d9de88ee30ec4e4c24fb4236fc2674",
|
"rev": "09eb77e94fa25202af8f3e81ddc7353d9970ac1b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "nixos",
|
||||||
"ref": "nixos-24.11",
|
"ref": "nixos-25.11",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"nixpkgs": "nixpkgs"
|
"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",
|
"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 = {
|
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
|
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils }:
|
outputs = { self, nixpkgs }:
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
let
|
||||||
let
|
system = "x86_64-linux";
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
python = pkgs.python312 or pkgs.python3;
|
packageName = "py2fa-gtk";
|
||||||
in {
|
scriptSource = ./src/main.py;
|
||||||
devShells.default = pkgs.mkShell {
|
|
||||||
name = "py2fa-gtk-shell";
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
# 1. Define Python environment
|
||||||
pkgs.gobject-introspection
|
python = pkgs.python312.withPackages (ps: with ps; [
|
||||||
];
|
cryptography
|
||||||
|
opencv-python
|
||||||
|
pygobject3
|
||||||
|
pyotp
|
||||||
|
pyzbar
|
||||||
|
]);
|
||||||
|
|
||||||
buildInputs = [
|
# 2. Define libraries for ZBar (shared object)
|
||||||
(python.withPackages (ps: with ps; [
|
zbarLibs = [ pkgs.zbar ];
|
||||||
cryptography
|
|
||||||
opencv4
|
|
||||||
pygobject3
|
|
||||||
pyotp
|
|
||||||
pyzbar
|
|
||||||
]))
|
|
||||||
pkgs.gtk3
|
|
||||||
pkgs.zbar
|
|
||||||
];
|
|
||||||
|
|
||||||
shellHook = ''
|
in
|
||||||
echo "Environment ready. Run the app with:"
|
{
|
||||||
echo " python main.py"
|
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