From 58df5018daa8150a430bcd336a1b93cd58d6ccbb Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Tue, 9 Apr 2024 09:25:30 -0400 Subject: [PATCH] meta: Handle postgres at the system level This makes sense since postgres is a service that runs on the system. --- modules/shell.nix | 27 +++------------------------ modules/system.nix | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/modules/shell.nix b/modules/shell.nix index 048246e7..c7132e92 100644 --- a/modules/shell.nix +++ b/modules/shell.nix @@ -1,19 +1,11 @@ -{ pkgs, config, lib, ... }: +{ pkgs, lib, ... }: let inherit (pkgs) fish; - inherit (lib) mkEnableOption mkIf mkMerge singleton; - inherit (cfg) postgres; - inherit (config.modules.system) username; + inherit (lib) mkMerge; inherit (builtins) attrValues; - - cfg = config.modules.shell; in { - options.modules.shell = { - postgres = mkEnableOption "postgres database and pgcli for containers"; - }; - config = { users.defaultUserShell = fish; environment.shells = [ fish ]; @@ -84,6 +76,7 @@ in visidata zellij diskonaut + pgcli ; inherit (pkgs) p7zip @@ -105,22 +98,8 @@ in nix-search-cli ; }) - - (mkIf postgres (attrValues { - inherit (pkgs) pgcli; - })) ]; - services.postgresql = mkIf postgres { - enable = true; - - ensureUsers = singleton { - name = username; - }; - - ensureDatabases = [ username ]; - }; - programs = { fish.enable = true; neovim.enable = true; diff --git a/modules/system.nix b/modules/system.nix index 22e5eb0f..3805017d 100644 --- a/modules/system.nix +++ b/modules/system.nix @@ -4,7 +4,7 @@ let inherit (lib) mkOption mkEnableOption mkIf singleton; inherit (lib.types) nullOr str listOf; 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; cfg = config.modules.system; @@ -55,6 +55,7 @@ in noRoot = mkEnableOption "disable access to root"; mullvad = mkEnableOption "mullvad vpn"; + postgres = mkEnableOption "postgres database for containers"; allowSRB2Port = mkEnableOption "port for srb2"; allowZolaPort = mkEnableOption "port for zola"; @@ -207,11 +208,23 @@ in }; }; - services.resolved.llmnr = "false"; + services = { + resolved.llmnr = "false"; - services.mullvad-vpn = mkIf mullvad { - enable = true; - enableExcludeWrapper = false; + mullvad-vpn = mkIf mullvad { + enable = true; + enableExcludeWrapper = false; + }; + + postgresql = mkIf postgres { + enable = true; + + ensureUsers = singleton { + name = username; + }; + + ensureDatabases = [ username ]; + }; }; environment.systemPackages = with pkgs; [