-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(services): added postgres service
services-flake is used to provide services the application needs to run. For now, this includes postgres which can be used for data storage going forward. Use `nix run .#services` to launch process-compose which will spin up the services. The http server also depends on a lockpad server being present but this is not ran through the services at this time. Instead lockpad has its own `services` package which functions the same way. Environment variables have been added that are used to configure dependent services: - `PRJ_DATA_HOME` - where to persist service data (recommend: set to the absolute path to the `.data` subdirectory of this repo) - `ANNAPURNA_POSTGRES_PORT` - determines the port to use (note, this is disabled via commenting `listen_port`, but the name is reserved)
- Loading branch information
1 parent
7d2faeb
commit 42dd383
Showing
6 changed files
with
673 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ result* | |
target | ||
|
||
.static | ||
.data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{...} @ part-inputs: { | ||
imports = []; | ||
|
||
perSystem = { | ||
pkgs, | ||
inputs', | ||
self', | ||
... | ||
}: { | ||
packages = { | ||
postgresql = inputs'.nix-postgres.packages."psql_15/bin"; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{inputs, ...} @ part-inputs: { | ||
imports = []; | ||
|
||
perSystem = { | ||
pkgs, | ||
inputs', | ||
self', | ||
... | ||
}: let | ||
ports = { | ||
annapurna-postgres = "\${ANNAPURNA_POSTGRES_PORT}"; | ||
}; | ||
|
||
global-imports = [ | ||
({name, ...}: { | ||
dataDirEnv = "\${PRJ_DATA_HOME}/${name}"; | ||
socketDirEnv = "\${PRJ_DATA_HOME}/${name}/sockets"; | ||
}) | ||
]; | ||
in rec { | ||
process-compose = { | ||
services = { | ||
imports = [ | ||
inputs.services-flake.processComposeModules.default | ||
]; | ||
|
||
services.postgres."annapurna-postgres" = { | ||
imports = global-imports; | ||
|
||
enable = true; | ||
package = self'.packages.postgresql; | ||
|
||
# by not including a listen address, we only listen on the unix socket | ||
# listen_addresses = "127.0.0.1"; | ||
port = ports.annapurna-postgres; | ||
initialDatabases = [ | ||
{ | ||
name = "annapurna-local"; | ||
} | ||
]; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.