From: Ismaƫl Bouya Date: Sat, 29 Dec 2018 23:40:08 +0000 (+0100) Subject: Check environment variables at build time X-Git-Tag: nur_publish~388 X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FConfig%2FNix.git;a=commitdiff_plain;h=6cd8d6ce21e3efeda631037851653c04ad64e41c Check environment variables at build time --- diff --git a/libs.nix b/libs.nix index da13a03..cef8586 100644 --- a/libs.nix +++ b/libs.nix @@ -26,4 +26,6 @@ in name = "${json.meta.name}-${version}"; src = fetchgit json.git; }; + + checkEnv = var: builtins.stringLength (builtins.getEnv var) > 0; } diff --git a/virtual/eldiron.nix b/virtual/eldiron.nix index ed41429..fb366b7 100644 --- a/virtual/eldiron.nix +++ b/virtual/eldiron.nix @@ -6,6 +6,7 @@ eldiron = { config, pkgs, ... }: let mypkgs = import ./packages.nix; + mylibs = import ../libs.nix; in { networking = { @@ -96,7 +97,7 @@ "ldap" "authnz_ldap" ]); - extraConfig = '' + extraConfig = assert mylibs.checkEnv "NIXOPS_HTTP_LDAP_PASSWORD"; '' LDAPSharedCacheSize 500000 LDAPCacheEntries 1024 @@ -162,7 +163,8 @@ # FIXME: environment variables ? security.pam.services = let pam_ldap = pkgs.pam_ldap; - pam_ldap_mysql = pkgs.writeText "mysql.conf" '' + pam_ldap_mysql = assert mylibs.checkEnv "NIXOPS_MYSQL_PAM_PASSWORD"; + pkgs.writeText "mysql.conf" '' host ldap.immae.eu base dc=immae,dc=eu binddn cn=mysql,cn=pam,ou=services,dc=immae,dc=eu