1 { config, lib, pkgs, ... }:
3 # TODO: This may file may need additional review, eg which configurations to
6 # I only used it to access some simple databases.
9 # isql, then type the following commands:
10 # CREATE DATABASE '/var/db/firebird/data/test.fdb' USER 'SYSDBA' PASSWORD 'masterkey';
11 # CONNECT '/var/db/firebird/data/test.fdb' USER 'SYSDBA' PASSWORD 'masterkey';
12 # CREATE TABLE test ( text varchar(100) );
15 # Be careful, virtuoso-opensource also provides a different isql command !
17 # There are at least two ways to run firebird. superserver has been chosen
18 # however there are no strong reasons to prefer this or the other one AFAIK
19 # Eg superserver is said to be most efficiently using resources according to
20 # https://www.firebirdsql.org/manual/qsg25-classic-or-super.html
23 cfg = config.services.firebird;
25 firebird = cfg.package;
27 dataDir = "${cfg.baseDir}/data";
28 systemDir = "${cfg.baseDir}/system";
40 enable = lib.mkEnableOption "the Firebird super server";
42 package = lib.mkPackageOption pkgs "firebird" {
43 example = "firebird_3";
45 For SuperServer use override: `pkgs.firebird_3.override { superServer = true; };`
51 type = lib.types.port;
61 User account under which firebird runs.
65 baseDir = lib.mkOption {
66 default = "/var/lib/firebird";
69 Location containing data/ and system/ directories.
70 data/ stores the databases, system/ stores the password database security2.fdb.
81 config = lib.mkIf config.services.firebird.enable {
83 environment.systemPackages = [cfg.package];
85 systemd.tmpfiles.rules = [
86 "d '${dataDir}' 0700 ${cfg.user} - - -"
87 "d '${systemDir}' 0700 ${cfg.user} - - -"
90 systemd.services.firebird =
91 { description = "Firebird Super-Server";
93 wantedBy = [ "multi-user.target" ];
95 # TODO: moving security2.fdb into the data directory works, maybe there
99 if ! test -e "${systemDir}/security2.fdb"; then
100 cp ${firebird}/security2.fdb "${systemDir}"
103 if ! test -e "${systemDir}/security3.fdb"; then
104 cp ${firebird}/security3.fdb "${systemDir}"
107 if ! test -e "${systemDir}/security4.fdb"; then
108 cp ${firebird}/security4.fdb "${systemDir}"
111 chmod -R 700 "${dataDir}" "${systemDir}" /var/log/firebird
114 serviceConfig.User = cfg.user;
115 serviceConfig.LogsDirectory = "firebird";
116 serviceConfig.LogsDirectoryMode = "0700";
117 serviceConfig.ExecStart = "${firebird}/bin/fbserver -d";
119 # TODO think about shutdown
122 environment.etc."firebird/firebird.msg".source = "${firebird}/firebird.msg";
124 # think about this again - and eventually make it an option
125 environment.etc."firebird/firebird.conf".text = ''
126 # RootDirectory = Restrict ${dataDir}
127 DatabaseAccess = Restrict ${dataDir}
128 ExternalFileAccess = Restrict ${dataDir}
129 # what is this? is None allowed?
131 # "Native" = traditional interbase/firebird, "mixed" is windows only
132 Authentication = Native
134 # defaults to -1 on non Win32
135 #MaxUnflushedWrites = 100
136 #MaxUnflushedWriteTime = 100
138 # show trace if trouble occurs (does this require debug build?)
140 # ConnectionTimeout = 180
142 #RemoteServiceName = gds_db
143 RemoteServicePort = ${toString cfg.port}
145 # randomly choose port for server Event Notification
147 # rsetrict connections to a network card:
149 # there are some additional settings which should be reviewed
152 users.users.firebird = {
153 description = "Firebird server user";
155 uid = config.ids.uids.firebird;
158 users.groups.firebird.gid = config.ids.gids.firebird;