blob: 0d61b3122366ec0d057ca860135d31979847a619 (
plain)
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
|
# Running postgres in a Guix container
GNU Guix never fails to amaze me.
Here is a simple recipe to run Postgres in userland on a system that has a guix daemon running
## Steps
Select a recent version of guix (note the leading dot)
```
. ~/opt/guix-pull/etc/profile
```
Install postgres (here we opt for v14) with
```
guix packages -A postgres
mkdir -p ~/data/pgdata
cd ~/data
guix shell -C -N postgresql@14.4 glibc-locales binutils coreutils which \
--share=$HOME/data/pgdata --share=/var/run/postgresql
```
To share `/var/run` make sure your user id is member of the postgres group.
Inside the shell
```
mkdir -p /var/run/postgresql
initdb -k -D pgdata/14
pg_ctl -D pgdata/14 -l logfile start
createdb test
psql test
```
and you should be able to work with everything. Note the user is the same as the user that runs the container.
Test then network interface with
```
telnet localhost 5432
```
To run a container in the background you may want to use screen and/or tmux.
To have the postgres client outside the container install it with
```
. ~/opt/guix-pull/etc/profile
guix package -i postgresql@14.4 -p ~/opt/postgresql14
```
Now you can add this
```
. ~/opt/postgresql14/etc/profile
psql test
\dt
etc etc
```
## More
=> https://fluca1978.github.io/2021/09/30/GNU_GUIX_PostgreSQL.html
=> https://guix.gnu.org/cookbook/en/html_node/A-Database-Container.html
|