]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Check environment variables at build time
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 29 Dec 2018 23:40:08 +0000 (00:40 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 29 Dec 2018 23:40:08 +0000 (00:40 +0100)
libs.nix
virtual/eldiron.nix

index da13a0359c227df3790d2d6e5c5a3ae68aa530f4..cef85869d513fba5227907955abe20eef49d60d0 100644 (file)
--- 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;
 }
index ed414298a2d44334c2af1368a0631d8b4303f5cd..fb366b7dffe0ed3826a8e72a2ce3b983d1961fd5 100644 (file)
@@ -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"; ''
         <IfModule ldap_module>
           LDAPSharedCacheSize 500000
           LDAPCacheEntries 1024
     # 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