summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorMichael Raskin <7c6f434c@mail.ru>2014-08-29 00:38:23 +0400
committerMichael Raskin <7c6f434c@mail.ru>2014-08-29 00:38:23 +0400
commit0036f4d79294925c3f8103f754f249c79503f571 (patch)
treee554b4581fe3338aa21f9b963299e88e3d13a25f /nixos
parent792afca11318aaac0715f343d7454ea4933a932a (diff)
parentd39684b69bb196de3e3440cc7fb0a749f6b7bc6c (diff)
downloadnixlib-0036f4d79294925c3f8103f754f249c79503f571.tar
nixlib-0036f4d79294925c3f8103f754f249c79503f571.tar.gz
nixlib-0036f4d79294925c3f8103f754f249c79503f571.tar.bz2
nixlib-0036f4d79294925c3f8103f754f249c79503f571.tar.lz
nixlib-0036f4d79294925c3f8103f754f249c79503f571.tar.xz
nixlib-0036f4d79294925c3f8103f754f249c79503f571.tar.zst
nixlib-0036f4d79294925c3f8103f754f249c79503f571.zip
Merge pull request #3047 from chrisfarms/freetds
Simple nixos module to enable configuration of freetds
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/programs/freetds.nix61
2 files changed, 62 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index e2f2921b8701..77a14fd53863 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -61,6 +61,7 @@
   ./programs/ssmtp.nix
   ./programs/venus.nix
   ./programs/wvdial.nix
+  ./programs/freetds.nix
   ./programs/zsh/zsh.nix
   ./rename.nix
   ./security/apparmor.nix
diff --git a/nixos/modules/programs/freetds.nix b/nixos/modules/programs/freetds.nix
new file mode 100644
index 000000000000..398fd104363b
--- /dev/null
+++ b/nixos/modules/programs/freetds.nix
@@ -0,0 +1,61 @@
+# Global configuration for freetds environment.
+
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+  cfg = config.environment.freetds;
+
+in
+{
+  ###### interface
+
+  options = {
+
+    environment.freetds = mkOption {
+      type = types.attrsOf types.str;
+      default = {};
+      example = {
+        MYDATABASE = 
+          ''
+          host = 10.0.2.100
+          port = 1433
+          tds version = 7.2
+          '';
+      };
+      description = 
+        ''
+        Configure freetds database entries. Each attribute denotes
+        a section within freetds.conf, and the value (a string) is the config
+        content for that section. When at least one entry is configured
+        the global environment variables FREETDSCONF, FREETDS and SYBASE
+        will be configured to allow the programs that use freetds to find the
+        library and config.
+        '';
+
+    };
+
+  };
+
+  ###### implementation
+
+  config = mkIf (length (attrNames cfg) > 0) {
+
+    environment.variables.FREETDSCONF = "/etc/freetds.conf";
+    environment.variables.FREETDS = "/etc/freetds.conf";
+    environment.variables.SYBASE = "${pkgs.freetds}";
+
+    environment.etc."freetds.conf" = { text = 
+      (concatStrings (mapAttrsToList (name: value:
+        ''
+        [${name}]
+        ${value}
+        ''
+      ) cfg));
+    };
+
+  };
+
+}