meta: Handle postgres at the system level

This makes sense since postgres is a service that runs on the system.
This commit is contained in:
Donovan Glover 2024-04-09 09:25:30 -04:00
parent bfd55ef40a
commit 58df5018da
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
2 changed files with 21 additions and 29 deletions

View File

@ -1,19 +1,11 @@
{ pkgs, config, lib, ... }: { pkgs, lib, ... }:
let let
inherit (pkgs) fish; inherit (pkgs) fish;
inherit (lib) mkEnableOption mkIf mkMerge singleton; inherit (lib) mkMerge;
inherit (cfg) postgres;
inherit (config.modules.system) username;
inherit (builtins) attrValues; inherit (builtins) attrValues;
cfg = config.modules.shell;
in in
{ {
options.modules.shell = {
postgres = mkEnableOption "postgres database and pgcli for containers";
};
config = { config = {
users.defaultUserShell = fish; users.defaultUserShell = fish;
environment.shells = [ fish ]; environment.shells = [ fish ];
@ -84,6 +76,7 @@ in
visidata visidata
zellij zellij
diskonaut diskonaut
pgcli
; ;
inherit (pkgs) inherit (pkgs)
p7zip p7zip
@ -105,22 +98,8 @@ in
nix-search-cli nix-search-cli
; ;
}) })
(mkIf postgres (attrValues {
inherit (pkgs) pgcli;
}))
]; ];
services.postgresql = mkIf postgres {
enable = true;
ensureUsers = singleton {
name = username;
};
ensureDatabases = [ username ];
};
programs = { programs = {
fish.enable = true; fish.enable = true;
neovim.enable = true; neovim.enable = true;

View File

@ -4,7 +4,7 @@ let
inherit (lib) mkOption mkEnableOption mkIf singleton; inherit (lib) mkOption mkEnableOption mkIf singleton;
inherit (lib.types) nullOr str listOf; inherit (lib.types) nullOr str listOf;
inherit (pkgs.nixVersions) nix_2_19; inherit (pkgs.nixVersions) nix_2_19;
inherit (cfg) username iHaveLotsOfRam hashedPassword mullvad allowSRB2Port allowZolaPort noRoot; inherit (cfg) username iHaveLotsOfRam hashedPassword mullvad allowSRB2Port allowZolaPort noRoot postgres;
inherit (builtins) attrValues; inherit (builtins) attrValues;
cfg = config.modules.system; cfg = config.modules.system;
@ -55,6 +55,7 @@ in
noRoot = mkEnableOption "disable access to root"; noRoot = mkEnableOption "disable access to root";
mullvad = mkEnableOption "mullvad vpn"; mullvad = mkEnableOption "mullvad vpn";
postgres = mkEnableOption "postgres database for containers";
allowSRB2Port = mkEnableOption "port for srb2"; allowSRB2Port = mkEnableOption "port for srb2";
allowZolaPort = mkEnableOption "port for zola"; allowZolaPort = mkEnableOption "port for zola";
@ -207,11 +208,23 @@ in
}; };
}; };
services.resolved.llmnr = "false"; services = {
resolved.llmnr = "false";
services.mullvad-vpn = mkIf mullvad { mullvad-vpn = mkIf mullvad {
enable = true; enable = true;
enableExcludeWrapper = false; enableExcludeWrapper = false;
};
postgresql = mkIf postgres {
enable = true;
ensureUsers = singleton {
name = username;
};
ensureDatabases = [ username ];
};
}; };
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [