diff --git a/modules/postgres.nix b/modules/postgres.nix deleted file mode 100644 index b1e5f593..00000000 --- a/modules/postgres.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ pkgs, ... }: - -{ - services.postgresql = { - enable = true; - - ensureUsers = [ - { - name = "user"; - } - { - name = "cooldbname"; - ensureDBOwnership = true; - } - ]; - - ensureDatabases = [ - "cooldbname" - ]; - }; - - environment.systemPackages = with pkgs; [ - pgcli - ]; -} diff --git a/modules/shell.nix b/modules/shell.nix index 5d0e6c72..3c0e14a3 100644 --- a/modules/shell.nix +++ b/modules/shell.nix @@ -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 = {