/
darwin-configuration.nix
71 lines (62 loc) · 2.53 KB
/
darwin-configuration.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{ config, pkgs, ... }:
{
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages =
[ pkgs.vim
];
nix.settings.experimental-features = [ "nix-command" "flakes" ];
# taken from https://github.com/LnL7/nix-darwin/issues/339
system.activationScripts.preActivation = {
enable = true;
text = ''
if [ ! -d "/var/lib/postgresql/" ]; then
echo "creating PostgreSQL data directory..."
sudo mkdir -m 750 -p /var/lib/postgresql/
chown -R danielluna:staff /var/lib/postgresql/
fi
'';
};
services.postgresql = {
enable = true;
package = pkgs.postgresql_15;
extraPlugins = with pkgs.postgresql_15.pkgs; [ postgis h3-pg pgvector ];
initdbArgs = ["-U danielluna" "--pgdata=/var/lib/postgresql/15" "--no-locale" "--encoding=UTF8"];
authentication = pkgs.lib.mkOverride 10 ''
#type database DBuser auth-method optional_ident_map
local all all peer map=superuser_map
#type database user address method
host all all localhost trust
'';
identMap = ''
# ArbitraryMapName systemUser DBUser
superuser_map root postgres
superuser_map postgres postgres
superuser_map danielluna postgres
# Let other names login as themselves
superuser_map /^(.*)$ \1
'';
# ensureDatabases = [ "postgres" ]; # doesnt work on nix-darwin
# initialScript = pkgs.writeText "backend-initScript" '' # doesnt work on nix-darwin
# CREATE ROLE postgres CREATEDB;
# CREATE DATABASE postgres;
# GRANT ALL PRIVILEGES ON DATABASE postgres TO postgres;
# '';
};
launchd.user.agents.postgresql.serviceConfig = {
StandardErrorPath = "/Users/danielluna/nix-postgres/postgres.error.log";
StandardOutPath = "/Users/danielluna/nix-postgres/postgres.log";
};
# Use a custom configuration.nix location.
# $ darwin-rebuild switch -I darwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix
# environment.darwinConfig = "$HOME/.config/nixpkgs/darwin/configuration.nix";
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
# nix.package = pkgs.nix;
# Create /etc/zshrc that loads the nix-darwin environment.
programs.zsh.enable = true; # default shell on catalina
# programs.fish.enable = true;
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 4;
}