Compare commits
5 commits
820b52314f
...
e215f7aa1d
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | e215f7aa1d | ||
Bruno BELANYI | afb683f1cf | ||
Bruno BELANYI | c320387746 | ||
Bruno BELANYI | bbb1231ad3 | ||
Bruno BELANYI | 9f00d8a38e |
18
flake.lock
18
flake.lock
|
@ -23,11 +23,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1626073055,
|
||||
"narHash": "sha256-vocByfpVu6m9zvtJugDvmd6/9iT2HJuG4tmDICKd0lI=",
|
||||
"lastModified": 1627501942,
|
||||
"narHash": "sha256-rG2PUTgzmXvf/fSDCWKhlRwZjZs1/0TySC5eYHVJrmg=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "775cb20bd4af7781fbf336fb201df02ee3d544bb",
|
||||
"rev": "2272fc312d5dc477e70816d94e550d08729b307b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -39,11 +39,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1626046891,
|
||||
"narHash": "sha256-Zt8saH+hAehXskW0iFAzk+iMillYoFBxvLReYNqGT9E=",
|
||||
"lastModified": 1627391865,
|
||||
"narHash": "sha256-tPoWBO9Nzu3wuX37WcnctzL6LoDCErJLnfLGqqmXCm4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d8f8f31af9d77a48220e4e8a301d1e79774cb7d2",
|
||||
"rev": "8ecc61c91a596df7d3293603a9c2384190c1b89a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -55,11 +55,11 @@
|
|||
},
|
||||
"nur": {
|
||||
"locked": {
|
||||
"lastModified": 1626192709,
|
||||
"narHash": "sha256-REQ9ByMk4crAX37e8YDZOBl9Kxn+nTfnnLwwxczcoP0=",
|
||||
"lastModified": 1627534577,
|
||||
"narHash": "sha256-cGVIlBkZZA9VvhXRRrWsTpkesJ/bSlGSPYPxafQVjSU=",
|
||||
"owner": "nix-community",
|
||||
"repo": "NUR",
|
||||
"rev": "564ec91b61dab796f1af44502ff3a9c124f4d6da",
|
||||
"rev": "0e1a91ef1d0460adfb5c669a9c0114f46e67956c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
./pirate.nix
|
||||
./podgrab.nix
|
||||
./postgresql-backup.nix
|
||||
./postgresql.nix
|
||||
./quassel.nix
|
||||
./rss-bridge.nix
|
||||
./sabnzbd.nix
|
||||
|
|
|
@ -81,6 +81,7 @@ in
|
|||
users.groups.drone = { };
|
||||
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
ensureDatabases = [ "drone" ];
|
||||
ensureUsers = [{
|
||||
name = "drone";
|
||||
|
|
|
@ -63,7 +63,6 @@ in
|
|||
config = lib.mkIf cfg.enable {
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
package = pkgs.postgresql_12;
|
||||
initialScript = pkgs.writeText "synapse-init.sql" ''
|
||||
CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse';
|
||||
CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse"
|
||||
|
|
|
@ -78,7 +78,7 @@ in
|
|||
dashboards = [
|
||||
{
|
||||
name = "Node Exporter";
|
||||
options.path = pkgs.nur.repos.alarsyo.grafana-dashboards.node-exporter;
|
||||
options.path = pkgs.nur.repos.alarsyo.grafanaDashboards.node-exporter;
|
||||
disableDeletion = true;
|
||||
}
|
||||
];
|
||||
|
|
|
@ -30,7 +30,7 @@ in
|
|||
config = lib.mkIf cfg.enable {
|
||||
services.nextcloud = {
|
||||
enable = true;
|
||||
package = pkgs.nextcloud21;
|
||||
package = pkgs.nextcloud22;
|
||||
hostName = nextcloudDomain;
|
||||
home = "/var/lib/nextcloud";
|
||||
maxUploadSize = cfg.maxSize;
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
services.grafana.provision.dashboards = [
|
||||
{
|
||||
name = "NGINX";
|
||||
options.path = pkgs.nur.repos.alarsyo.grafana-dashboards.nginx;
|
||||
options.path = pkgs.nur.repos.alarsyo.grafanaDashboards.nginx;
|
||||
disableDeletion = true;
|
||||
}
|
||||
];
|
||||
|
|
61
modules/services/postgresql.nix
Normal file
61
modules/services/postgresql.nix
Normal file
|
@ -0,0 +1,61 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.my.services.postgresql;
|
||||
in
|
||||
{
|
||||
options.my.services.postgresql = with lib; {
|
||||
enable = my.mkDisableOption "postgres configuration";
|
||||
|
||||
# Transient option to be enabled for migrations
|
||||
upgradeScript = mkEnableOption "postgres upgrade script";
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
# Let other services enable postgres when they need it
|
||||
(lib.mkIf cfg.enable {
|
||||
services.postgresql = {
|
||||
package = pkgs.postgresql_13;
|
||||
};
|
||||
})
|
||||
|
||||
# Taken from the manual
|
||||
(lib.mkIf cfg.upgradeScript {
|
||||
containers.temp-pg.config.services.postgresql = {
|
||||
enable = true;
|
||||
package = pkgs.postgresql_13;
|
||||
};
|
||||
|
||||
environment.systemPackages =
|
||||
let
|
||||
newpg = config.containers.temp-pg.config.services.postgresql;
|
||||
in
|
||||
[
|
||||
(pkgs.writeScriptBin "upgrade-pg-cluster" ''
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -x
|
||||
export OLDDATA="${config.services.postgresql.dataDir}"
|
||||
export NEWDATA="${newpg.dataDir}"
|
||||
export OLDBIN="${config.services.postgresql.package}/bin"
|
||||
export NEWBIN="${newpg.package}/bin"
|
||||
|
||||
if [ "$OLDDATA" -ef "$NEWDATA" ]; then
|
||||
echo "Cannot migrate to same data directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install -d -m 0700 -o postgres -g postgres "$NEWDATA"
|
||||
cd "$NEWDATA"
|
||||
sudo -u postgres $NEWBIN/initdb -D "$NEWDATA"
|
||||
|
||||
systemctl stop postgresql # old one
|
||||
|
||||
sudo -u postgres $NEWBIN/pg_upgrade \
|
||||
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \
|
||||
--old-bindir $OLDBIN --new-bindir $NEWBIN \
|
||||
"$@"
|
||||
'')
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
Loading…
Reference in a new issue