2022-04-14 15:50:17 +00:00
|
|
|
let
|
2022-04-15 10:36:49 +00:00
|
|
|
common = import ./common.nix;
|
|
|
|
pkgs = import common.pkgsSrc {};
|
2022-04-14 15:50:17 +00:00
|
|
|
python-with-my-packages = pkgs.python3.withPackages (p: with p; [
|
|
|
|
minio
|
|
|
|
]);
|
|
|
|
in
|
2022-04-15 10:36:49 +00:00
|
|
|
pkgs.stdenv.mkDerivation {
|
|
|
|
name = "backup-psql";
|
|
|
|
src = pkgs.lib.sourceFilesBySuffices ./. [ ".py" ];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
python-with-my-packages
|
|
|
|
pkgs.age
|
|
|
|
pkgs.postgresql_14
|
|
|
|
];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
cat > backup-psql <<EOF
|
2022-04-15 12:24:41 +00:00
|
|
|
#!${pkgs.bash}/bin/bash
|
2022-04-15 12:57:54 +00:00
|
|
|
|
2022-04-15 12:24:41 +00:00
|
|
|
export PYTHONPATH=${python-with-my-packages}/${python-with-my-packages.sitePackages}
|
2022-04-15 12:57:54 +00:00
|
|
|
export PATH=${python-with-my-packages}/bin:${pkgs.age}/bin:${pkgs.postgresql_14}/bin
|
|
|
|
|
2022-04-15 12:24:41 +00:00
|
|
|
${python-with-my-packages}/bin/python3 $out/lib/backup-psql.py
|
2022-04-15 10:36:49 +00:00
|
|
|
EOF
|
2022-04-15 12:24:41 +00:00
|
|
|
|
2022-04-15 10:36:49 +00:00
|
|
|
chmod +x backup-psql
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/{bin,lib}
|
|
|
|
cp *.py $out/lib/backup-psql.py
|
2022-04-15 12:24:41 +00:00
|
|
|
cp backup-psql $out/bin/backup-psql
|
2022-04-15 10:36:49 +00:00
|
|
|
'';
|
|
|
|
}
|
|
|
|
|