at 18.09-beta 1.3 kB view raw
1# Global configuration for freetds environment. 2 3{ config, lib, pkgs, ... }: 4 5with lib; 6 7let 8 9 cfg = config.environment.freetds; 10 11in 12{ 13 ###### interface 14 15 options = { 16 17 environment.freetds = mkOption { 18 type = types.attrsOf types.str; 19 default = {}; 20 example = literalExample '' 21 { MYDATABASE = ''' 22 host = 10.0.2.100 23 port = 1433 24 tds version = 7.2 25 '''; 26 } 27 ''; 28 description = 29 '' 30 Configure freetds database entries. Each attribute denotes 31 a section within freetds.conf, and the value (a string) is the config 32 content for that section. When at least one entry is configured 33 the global environment variables FREETDSCONF, FREETDS and SYBASE 34 will be configured to allow the programs that use freetds to find the 35 library and config. 36 ''; 37 38 }; 39 40 }; 41 42 ###### implementation 43 44 config = mkIf (length (attrNames cfg) > 0) { 45 46 environment.variables.FREETDSCONF = "/etc/freetds.conf"; 47 environment.variables.FREETDS = "/etc/freetds.conf"; 48 environment.variables.SYBASE = "${pkgs.freetds}"; 49 50 environment.etc."freetds.conf" = { text = 51 (concatStrings (mapAttrsToList (name: value: 52 '' 53 [${name}] 54 ${value} 55 '' 56 ) cfg)); 57 }; 58 59 }; 60 61}