meta: Merge postgres module with shell

Realistically this might be more related to "system" than shell, however
it may also be advantageous to keep system as minimal as possible since
it could also be argued that interpreted programming languages are a
part of the system.
This commit is contained in:
Donovan Glover 2024-04-04 18:37:40 -04:00
parent 721ead4572
commit 6f1b17a600
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
2 changed files with 24 additions and 29 deletions

View File

@ -1,25 +0,0 @@
{ pkgs, ... }:
{
services.postgresql = {
enable = true;
ensureUsers = [
{
name = "user";
}
{
name = "cooldbname";
ensureDBOwnership = true;
}
];
ensureDatabases = [
"cooldbname"
];
};
environment.systemPackages = with pkgs; [
pgcli
];
}

View File

@ -2,15 +2,19 @@
let
inherit (pkgs) fish htop-vim;
inherit (lib) mkEnableOption mkIf;
inherit (lib) mkEnableOption mkIf mkMerge singleton;
inherit (builtins) attrValues;
inherit (cfg) postgres;
inherit (config.modules.system) username;
cfg = config.modules.shell;
in
{
options.modules.shell = {
postgres = mkEnableOption "postgres database and pgcli for containers";
};
config = with cfg; {
config = {
users.defaultUserShell = fish;
environment.shells = [ fish ];
@ -24,8 +28,24 @@ in
VISUAL = "nvim";
};
environment.systemPackages = builtins.attrValues {
inherit (pkgs) wget jq eza fd fzf ripgrep;
environment.systemPackages = mkMerge [
(attrValues {
inherit (pkgs) wget jq eza fd fzf ripgrep;
})
(mkIf postgres (attrValues {
inherit (pkgs) pgcli;
}))
];
services.postgresql = mkIf postgres {
enable = true;
ensureUsers = singleton {
name = username;
};
ensureDatabases = [ username ];
};
programs = {