Skip to content

Commit

Permalink
Reformat some files
Browse files Browse the repository at this point in the history
  • Loading branch information
alapshin committed Jan 24, 2024
1 parent e08b8ee commit fac58cb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
6 changes: 4 additions & 2 deletions hosts/carbon/syncthing.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{ config
, pkgs
, ...
}: let
}:
let
cfg = config.services.syncthing;

username = "alapshin";
usergroup = config.users.users.${username}.group;
in {
in
{
sops = {
secrets = {
"syncthing/key" = {
Expand Down
47 changes: 25 additions & 22 deletions hosts/server/pg-upgrade.nix
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
{ config, pkgs, ... }:
{
environment.systemPackages = [
(let
# Specify the postgresql package you'd like to upgrade to.
# Do not forget to list the extensions you need.
newPostgres = pkgs.postgresql_16.withPackages (pp: [
# pp.plv8
]);
in pkgs.writeScriptBin "pg-upgrade-cluster" ''
set -eux
# It's perhaps advisable to stop all services that depend on postgresql
systemctl stop postgresql
(
let
# Specify the postgresql package you'd like to upgrade to.
# Do not forget to list the extensions you need.
newPostgres = pkgs.postgresql_16.withPackages (pp: [
# pp.plv8
]);
in
pkgs.writeScriptBin "pg-upgrade-cluster" ''
set -eux
# It's perhaps advisable to stop all services that depend on postgresql
systemctl stop postgresql
export OLDBIN="${config.services.postgresql.package}/bin"
export OLDDATA="${config.services.postgresql.dataDir}"
export OLDBIN="${config.services.postgresql.package}/bin"
export OLDDATA="${config.services.postgresql.dataDir}"
export NEWBIN="${newPostgres}/bin"
export NEWDATA="/var/lib/postgresql/${newPostgres.psqlSchema}"
export NEWBIN="${newPostgres}/bin"
export NEWDATA="/var/lib/postgresql/${newPostgres.psqlSchema}"
install -d -m 0700 -o postgres -g postgres "$NEWDATA"
cd "$NEWDATA"
sudo -u postgres $NEWBIN/initdb -D "$NEWDATA"
install -d -m 0700 -o postgres -g postgres "$NEWDATA"
cd "$NEWDATA"
sudo -u postgres $NEWBIN/initdb -D "$NEWDATA"
sudo -u postgres $NEWBIN/pg_upgrade \
--old-bindir $OLDBIN --new-bindir $NEWBIN \
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \
"$@"
'')
sudo -u postgres $NEWBIN/pg_upgrade \
--old-bindir $OLDBIN --new-bindir $NEWBIN \
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \
"$@"
''
)
];
}

0 comments on commit fac58cb

Please sign in to comment.