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