Initial commit
This commit is contained in:
commit
cf83801dd1
5 changed files with 110 additions and 0 deletions
50
flake.nix
Normal file
50
flake.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# flake.nix
|
||||
{
|
||||
description = "Dev shell + runnable app for merge_pdfs.py";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
||||
forEachSystem = f: nixpkgs.lib.genAttrs systems (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
python = pkgs.python311.withPackages (ps: [ ps.pypdf2 ]);
|
||||
# Small wrapper so `nix run` works: it uses the Python with PyPDF2 and your script.
|
||||
merge-pdfs = pkgs.writeShellScriptBin "merge-pdfs" ''
|
||||
exec ${python}/bin/python ${./merge_pdfs.py} "$@"
|
||||
'';
|
||||
in f pkgs python merge-pdfs
|
||||
);
|
||||
in {
|
||||
devShells = forEachSystem (pkgs: python: merge-pdfs: {
|
||||
default = pkgs.mkShell {
|
||||
packages = [
|
||||
python # Python 3.11 with PyPDF2
|
||||
pkgs.ruff # optional: linter
|
||||
pkgs.pyright # optional: type checker
|
||||
];
|
||||
shellHook = ''
|
||||
echo "✅ Dev shell ready. Try:"
|
||||
echo " python merge_pdfs.py output.pdf a.pdf b.pdf"
|
||||
'';
|
||||
};
|
||||
});
|
||||
|
||||
# `nix run` makes it easy to use from anywhere:
|
||||
apps = forEachSystem (pkgs: python: merge-pdfs: {
|
||||
default = {
|
||||
type = "app";
|
||||
program = "${merge-pdfs}/bin/merge-pdfs";
|
||||
};
|
||||
});
|
||||
|
||||
# expose the tiny wrapper as a package if you want `nix build .#merge-pdfs`
|
||||
packages = forEachSystem (pkgs: python: merge-pdfs: {
|
||||
default = merge-pdfs;
|
||||
merge-pdfs = merge-pdfs;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue