This repository has been archived on 2023-03-15. You can view files and clone it, but cannot push or open issues or pull requests.
infrastructure/app/backup/build/backup-psql/default.nix

38 lines
893 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
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
'';
}