From: Ismaƫl Bouya Date: Thu, 9 Apr 2020 23:22:16 +0000 (+0200) Subject: Stop using overlays in the middle of modules X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FConfig%2FNix.git;a=commitdiff_plain;h=9f16e659f129dd8acab7d086ef9822673a01ba06 Stop using overlays in the middle of modules --- diff --git a/modules/private/databases/default.nix b/modules/private/databases/default.nix index c4a023a..6cd6feb 100644 --- a/modules/private/databases/default.nix +++ b/modules/private/databases/default.nix @@ -10,10 +10,6 @@ in }; }; - config.nixpkgs.overlays = lib.mkIf cfg.enable [ (self: super: { - postgresql = self.postgresql_11_custom; - }) ]; - config.myServices.databases = lib.mkIf cfg.enable { mariadb = { enable = true; diff --git a/modules/private/databases/postgresql_replication.nix b/modules/private/databases/postgresql_replication.nix index 7172c5e..6ac2455 100644 --- a/modules/private/databases/postgresql_replication.nix +++ b/modules/private/databases/postgresql_replication.nix @@ -11,6 +11,13 @@ in Base path to put the replications ''; }; + mainPackage = lib.mkOption { + type = lib.types.package; + default = pkgs.postgresql; + description = '' + Postgresql package available in shell + ''; + }; hosts = lib.mkOption { default = {}; description = '' @@ -43,10 +50,6 @@ in }; config = lib.mkIf cfg.enable { - nixpkgs.overlays = [ (self: super: { - postgresql = self.postgresql_11_custom; - }) ]; - users.users.postgres = { name = "postgres"; uid = config.ids.uids.postgres; @@ -57,7 +60,7 @@ in extraGroups = [ "keys" ]; }; users.groups.postgres.gid = config.ids.gids.postgres; - environment.systemPackages = [ pkgs.postgresql ]; + environment.systemPackages = [ cfg.mainPackage ]; secrets.keys = lib.flatten (lib.mapAttrsToList (name: hcfg: [ { diff --git a/modules/private/mail/postfix.nix b/modules/private/mail/postfix.nix index 92fa580..985d4af 100644 --- a/modules/private/mail/postfix.nix +++ b/modules/private/mail/postfix.nix @@ -171,9 +171,6 @@ networking.firewall.allowedTCPPorts = [ 25 465 587 ]; - nixpkgs.overlays = [ (self: super: { - postfix = super.postfix.override { withMySQL = true; }; - }) ]; users.users."${config.services.postfix.user}".extraGroups = [ "keys" ]; services.filesWatcher.postfix = { restart = true; diff --git a/modules/private/mail/relay.nix b/modules/private/mail/relay.nix index c6231aa..d29ae75 100644 --- a/modules/private/mail/relay.nix +++ b/modules/private/mail/relay.nix @@ -89,9 +89,6 @@ networking.firewall.allowedTCPPorts = [ 25 ]; - nixpkgs.overlays = [ (self: super: { - postfix = super.postfix.override { withMySQL = true; }; - }) ]; users.users."${config.services.postfix.user}".extraGroups = [ "keys" ]; services.filesWatcher.postfix = { restart = true; diff --git a/modules/private/monitoring/default.nix b/modules/private/monitoring/default.nix index 8b45d47..0586567 100644 --- a/modules/private/monitoring/default.nix +++ b/modules/private/monitoring/default.nix @@ -11,6 +11,11 @@ let pkgs.mailutils ]} ''; + postgresqlBinary = if config.myServices.databasesReplication.postgresql.enable + then config.myServices.databasesReplication.postgresql.mainPackage + else if config.myServices.databases.enable + then config.myServices.databases.postgresql.package + else pkgs.postgresql; myplugins = pkgs.runCommand "buildplugins" { buildInputs = [ pkgs.makeWrapper pkgs.perl ]; } '' @@ -28,7 +33,7 @@ let pkgs.gnugrep pkgs.gawk pkgs.procps-ng ]} wrapProgram $out/check_postgres_replication --prefix PATH : ${lib.makeBinPath [ - pkgs.postgresql + postgresqlBinary ]} wrapProgram $out/check_redis_replication --prefix PATH : ${lib.makeBinPath [ pkgs.gnugrep pkgs.coreutils pkgs.redis diff --git a/modules/private/system/backup-2.nix b/modules/private/system/backup-2.nix index 3d263f5..a49c374 100644 --- a/modules/private/system/backup-2.nix +++ b/modules/private/system/backup-2.nix @@ -66,10 +66,12 @@ postgresql = { enable = true; base = "/backup2"; + mainPackage = pkgs.postgresql; hosts = { eldiron = { slot = "backup_2"; connection = "postgresql://backup-2:${config.hostEnv.ldap.password}@eldiron.immae.eu"; + package = pkgs.postgresql; }; }; }; diff --git a/overlays/databases/postgresql/default.nix b/overlays/databases/postgresql/default.nix index ae58987..50d9496 100644 --- a/overlays/databases/postgresql/default.nix +++ b/overlays/databases/postgresql/default.nix @@ -1,5 +1,5 @@ self: super: rec { - postgresql_11_custom = super.postgresql_11.overrideAttrs(old: { + postgresql = super.postgresql_11.overrideAttrs(old: { # datadir in /var/lib/postgresql is named after psqlSchema passthru = old.passthru // { psqlSchema = "11.0"; }; configureFlags = old.configureFlags ++ [ "--with-pam" ]; diff --git a/overlays/default.nix b/overlays/default.nix index 881083d..b3bc8ca 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -17,6 +17,7 @@ nixops = import ./nixops; pass = import ./pass; pelican = import ./pelican; + postfix = import ./postfix; postgresql = import ./databases/postgresql; s6 = import ./s6; sc-im = import ./sc-im; diff --git a/overlays/postfix/default.nix b/overlays/postfix/default.nix new file mode 100644 index 0000000..55b8312 --- /dev/null +++ b/overlays/postfix/default.nix @@ -0,0 +1,3 @@ +self: super: { + postfix = super.postfix.override { withMySQL = true; }; +}