infrastructure/app/backup/build/backup-psql/default.nix

34 lines
773 B
Nix
Raw Normal View History

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
#!${pkgs.bash}/bin/bash
export PYTHONPATH=${python-with-my-packages}/${python-with-my-packages.sitePackages}
python3 $out/lib/backup-psql.py
EOF
chmod +x backup-psql
'';
installPhase = ''
mkdir -p $out/{bin,lib}
cp *.py $out/lib/backup-psql.py
cp backup-psql $out/bin/backup-sql
'';
}