···2626# Match diffs, avoid to trim trailing whitespace2727[*.{diff,patch}]2828trim_trailing_whitespace = false2929+3030+# https://github.com/NixOS/nixpkgs/pull/39336#discussion_r1833877543131+[.version]3232+insert_final_newline = false
.version
+50
doc/languages-frameworks/haskell.section.md
···666666cannot use GHC 7.10.x at all for some reason, the approach of downgrading to an667667older version might be useful.668668669669+### How to override packages in all compiler-specific package sets670670+671671+In the previous section we learned how to override a package in a single672672+compiler-specific package set. You may have some overrides defined that you want673673+to use across multiple package sets. To accomplish this you could use the674674+technique that we learned in the previous section by repeating the overrides for675675+all the compiler-specific package sets. For example:676676+677677+```nix678678+{679679+ packageOverrides = super: let self = super.pkgs; in680680+ {681681+ haskell = super.haskell // {682682+ packages = super.haskell.packages // {683683+ ghc784 = super.haskell.packages.ghc784.override {684684+ overrides = self: super: {685685+ my-package = ...;686686+ my-other-package = ...;687687+ };688688+ };689689+ ghc822 = super.haskell.packages.ghc784.override {690690+ overrides = self: super: {691691+ my-package = ...;692692+ my-other-package = ...;693693+ };694694+ };695695+ ...696696+ };697697+ };698698+ };699699+}700700+```701701+702702+However there's a more convenient way to override all compiler-specific package703703+sets at once:704704+705705+```nix706706+{707707+ packageOverrides = super: let self = super.pkgs; in708708+ {709709+ haskell = super.haskell // {710710+ packageOverrides = self: super: {711711+ my-package = ...;712712+ my-other-package = ...;713713+ };714714+ };715715+ };716716+}717717+```718718+669719### How to recover from GHC's infamous non-deterministic library ID bug670720671721GHC and distributed build farms don't get along well:
+3-1
doc/reviewing-contributions.xml
···2323 xlink:href="https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc">most2424 recently</link> and the <link2525 xlink:href="https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-asc">least2626- recently</link> updated pull-requests.</para>2626+ recently</link> updated pull-requests.2727+ We highly encourage looking at <link xlink:href="https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+review%3Anone+status%3Asuccess+-label%3A%222.status%3A+work-in-progress%22+no%3Aproject+no%3Aassignee+no%3Amilestone">2828+ this list of ready to merge, unreviewed pull requests</link>.</para>27292830<para>When reviewing a pull request, please always be nice and polite.2931 Controversial changes can lead to controversial opinions, but it is important
···2525 type = types.bool;2626 description = ''2727 Enable in-memory compressed swap space provided by the zram kernel2828- module. It is recommended to enable only for kernel 3.14 or higher.2828+ module.2929+ See https://www.kernel.org/doc/Documentation/blockdev/zram.txt2930 '';3031 };31323233 numDevices = mkOption {3333- default = 4;3434+ default = 1;3435 type = types.int;3536 description = ''3636- Number of zram swap devices to create. It should be equal to the3737- number of CPU cores your system has.3737+ Number of zram swap devices to create.3838 '';3939 };4040
+2-1
nixos/modules/installer/tools/nixos-enter.sh
···5151 exit 1265252fi53535454-mkdir -m 0755 -p "$mountPoint/dev"5454+mkdir -m 0755 -p "$mountPoint/dev" "$mountPoint/sys"5555mount --rbind /dev "$mountPoint/dev"5656+mount --rbind /sys "$mountPoint/sys"56575758# Run the activation script. Set $LOCALE_ARCHIVE to supress some Perl locale warnings.5859LOCALE_ARCHIVE=$system/sw/lib/locale/locale-archive chroot "$mountPoint" "$system/activate" >&2 || true
+31-12
nixos/modules/misc/documentation.nix
···1616 description = ''1717 Whether to install documentation of packages from1818 <option>environment.systemPackages</option> into the generated system path.1919+2020+ See "Multiple-output packages" chapter in the nixpkgs manual for more info.1921 '';2222+ # which is at ../../../doc/multiple-output.xml2023 };21242225 man.enable = mkOption {···2825 description = ''2926 Whether to install manual pages and the <command>man</command> command.3027 This also includes "man" outputs.2828+ '';2929+ };3030+3131+ info.enable = mkOption {3232+ type = types.bool;3333+ default = true;3434+ description = ''3535+ Whether to install info pages and the <command>info</command> command.3636+ This also includes "info" outputs.3137 '';3238 };3339···5038 '';5139 };52405353- info.enable = mkOption {4141+ dev.enable = mkOption {5442 type = types.bool;5555- default = true;4343+ default = false;5644 description = ''5757- Whether to install info pages and the <command>info</command> command.5858- This also includes "info" outputs.4545+ Whether to install documentation targeted at developers.4646+ <itemizedlist>4747+ <listitem><para>This includes man pages targeted at developers if <option>man.enable</option> is4848+ set (this also includes "devman" outputs).</para></listitem>4949+ <listitem><para>This includes info pages targeted at developers if <option>info.enable</option>5050+ is set (this also includes "devinfo" outputs).</para></listitem>5151+ <listitem><para>This includes other pages targeted at developers if <option>doc.enable</option>5252+ is set (this also includes "devdoc" outputs).</para></listitem>5353+ </itemizedlist>5954 '';6055 };6156···7556 (mkIf cfg.man.enable {7657 environment.systemPackages = [ pkgs.man-db ];7758 environment.pathsToLink = [ "/share/man" ];7878- environment.extraOutputsToInstall = [ "man" ];5959+ environment.extraOutputsToInstall = [ "man" ] ++ optional cfg.dev.enable [ "devman" ];6060+ })6161+6262+ (mkIf cfg.info.enable {6363+ environment.systemPackages = [ pkgs.texinfoInteractive ];6464+ environment.pathsToLink = [ "/share/info" ];6565+ environment.extraOutputsToInstall = [ "info" ] ++ optional cfg.dev.enable [ "devinfo" ];7966 })80678168 (mkIf cfg.doc.enable {8269 # TODO(@oxij): put it here and remove from profiles?8370 # environment.systemPackages = [ pkgs.w3m ]; # w3m-nox?8471 environment.pathsToLink = [ "/share/doc" ];8585- environment.extraOutputsToInstall = [ "doc" ];8686- })8787-8888- (mkIf cfg.info.enable {8989- environment.systemPackages = [ pkgs.texinfoInteractive ];9090- environment.pathsToLink = [ "/share/info" ];9191- environment.extraOutputsToInstall = [ "info" ];7272+ environment.extraOutputsToInstall = [ "doc" ] ++ optional cfg.dev.enable [ "devdoc" ];9273 })93749475 ]);
···5858 default = "";5959 example = "systemctl reload nginx.service";6060 description = ''6161- Commands to run after certificates are re-issued. Typically6161+ Commands to run after new certificates go live. Typically6262 the web server and other servers using certificates need to6363 be reloaded.6464+6565+ Executed in the same directory with the new certificate.6466 '';6567 };6668···7775 store public certificate bundle in <filename>fullchain.pem</filename>,7876 private key in <filename>key.pem</filename> and those two previous7977 files combined in <filename>full.pem</filename> in its state directory.7878+ '';7979+ };8080+8181+ activationDelay = mkOption {8282+ type = types.nullOr types.str;8383+ default = null;8484+ description = ''8585+ Systemd time span expression to delay copying new certificates to main8686+ state directory. See <citerefentry><refentrytitle>systemd.time</refentrytitle>8787+ <manvolnum>7</manvolnum></citerefentry>.8888+ '';8989+ };9090+9191+ preDelay = mkOption {9292+ type = types.lines;9393+ default = "";9494+ description = ''9595+ Commands to run after certificates are re-issued but before they are9696+ activated. Typically the new certificate is published to DNS.9797+9898+ Executed in the same directory with the new certificate.8099 '';81100 };82101···209186 servicesLists = mapAttrsToList certToServices cfg.certs;210187 certToServices = cert: data:211188 let212212- cpath = "${cfg.directory}/${cert}";189189+ domain = if data.domain != null then data.domain else cert;190190+ cpath = lpath + optionalString (data.activationDelay != null) ".staging";191191+ lpath = "${cfg.directory}/${cert}";213192 rights = if data.allowKeysForGroup then "750" else "700";214193 cmdline = [ "-v" "-d" data.domain "--default_root" data.webroot "--valid_min" cfg.validMin ]215194 ++ optionals (data.email != null) [ "--email" data.email ]216195 ++ concatMap (p: [ "-f" p ]) data.plugins217196 ++ concatLists (mapAttrsToList (name: root: [ "-d" (if root == null then name else "${name}:${root}")]) data.extraDomains)218218- ++ (if cfg.production then []219219- else ["--server" "https://acme-staging.api.letsencrypt.org/directory"]);197197+ ++ optionals (!cfg.production) ["--server" "https://acme-staging.api.letsencrypt.org/directory"];220198 acmeService = {221199 description = "Renew ACME Certificate for ${cert}";222200 after = [ "network.target" "network-online.target" ];···230206 Group = data.group;231207 PrivateTmp = true;232208 };233233- path = [ pkgs.simp_le ];209209+ path = with pkgs; [ simp_le systemd ];234210 preStart = ''235211 mkdir -p '${cfg.directory}'236212 chown 'root:root' '${cfg.directory}'···253229 exit "$EXITCODE"254230 '';255231 postStop = ''232232+ cd '${cpath}'233233+256234 if [ -e /tmp/lastExitCode ] && [ "$(cat /tmp/lastExitCode)" = "0" ]; then257257- echo "Executing postRun hook..."258258- ${data.postRun}235235+ ${if data.activationDelay != null then ''236236+237237+ ${data.preDelay}238238+239239+ if [ -d '${lpath}' ]; then240240+ systemd-run --no-block --on-active='${data.activationDelay}' --unit acme-setlive-${cert}.service241241+ else242242+ systemctl --wait start acme-setlive-${cert}.service243243+ fi244244+ '' else data.postRun}259245 fi260246 '';261247262248 before = [ "acme-certificates.target" ];263249 wantedBy = [ "acme-certificates.target" ];250250+ };251251+ delayService = {252252+ description = "Set certificate for ${cert} live";253253+ path = with pkgs; [ rsync ];254254+ serviceConfig = {255255+ Type = "oneshot";256256+ };257257+ script = ''258258+ rsync -a --delete-after '${cpath}/' '${lpath}'259259+ '';260260+ postStop = data.postRun;264261 };265262 selfsignedService = {266263 description = "Create preliminary self-signed certificate for ${cert}";···347302 };348303 in (349304 [ { name = "acme-${cert}"; value = acmeService; } ]350350- ++351351- (if cfg.preliminarySelfsigned352352- then [ { name = "acme-selfsigned-${cert}"; value = selfsignedService; } ]353353- else []354354- )305305+ ++ optional cfg.preliminarySelfsigned { name = "acme-selfsigned-${cert}"; value = selfsignedService; }306306+ ++ optional (data.activationDelay != null) { name = "acme-setlive-${cert}"; value = delayService; }355307 );356308 servicesAttr = listToAttrs services;357309 injectServiceDep = {
+360
nixos/modules/services/databases/foundationdb.nix
···11+{ config, lib, pkgs, ... }:22+33+with lib;44+55+let66+ cfg = config.services.foundationdb;77+88+ # used for initial cluster configuration99+ initialIpAddr = if (cfg.publicAddress != "auto") then cfg.publicAddress else "127.0.0.1";1010+1111+ fdbServers = n:1212+ concatStringsSep "\n" (map (x: "[fdbserver.${toString (x+cfg.listenPortStart)}]") (range 0 (n - 1)));1313+1414+ backupAgents = n:1515+ concatStringsSep "\n" (map (x: "[backup_agent.${toString x}]") (range 1 n));1616+1717+ configFile = pkgs.writeText "foundationdb.conf" ''1818+ [general]1919+ cluster_file = /etc/foundationdb/fdb.cluster2020+2121+ [fdbmonitor]2222+ restart_delay = ${toString cfg.restartDelay}2323+ user = ${cfg.user}2424+ group = ${cfg.group}2525+2626+ [fdbserver]2727+ command = ${pkgs.foundationdb}/bin/fdbserver2828+ public_address = ${cfg.publicAddress}:$ID2929+ listen_address = ${cfg.listenAddress}3030+ datadir = ${cfg.dataDir}/$ID3131+ logdir = ${cfg.logDir}3232+ logsize = ${cfg.logSize}3333+ maxlogssize = ${cfg.maxLogSize}3434+ ${optionalString (cfg.class != null) "class = ${cfg.class}"}3535+ memory = ${cfg.memory}3636+ storage_memory = ${cfg.storageMemory}3737+3838+ ${optionalString (cfg.locality.machineId != null) "locality_machineid=${cfg.locality.machineId}"}3939+ ${optionalString (cfg.locality.zoneId != null) "locality_zoneid=${cfg.locality.zoneId}"}4040+ ${optionalString (cfg.locality.datacenterId != null) "locality_dcid=${cfg.locality.datacenterId}"}4141+ ${optionalString (cfg.locality.dataHall != null) "locality_data_hall=${cfg.locality.dataHall}"}4242+4343+ ${fdbServers cfg.serverProcesses}4444+4545+ [backup_agent]4646+ command = ${pkgs.foundationdb}/libexec/backup_agent4747+ ${backupAgents cfg.backupProcesses}4848+ '';4949+in5050+{5151+ options.services.foundationdb = {5252+5353+ enable = mkEnableOption "FoundationDB Server";5454+5555+ publicAddress = mkOption {5656+ type = types.str;5757+ default = "auto";5858+ description = "Publicly visible IP address of the process. Port is determined by process ID";5959+ };6060+6161+ listenAddress = mkOption {6262+ type = types.str;6363+ default = "public";6464+ description = "Publicly visible IP address of the process. Port is determined by process ID";6565+ };6666+6767+ listenPortStart = mkOption {6868+ type = types.int;6969+ default = 4500;7070+ description = ''7171+ Starting port number for database listening sockets. Every FDB process binds to a7272+ subsequent port, to this number reflects the start of the overall range. e.g. having7373+ 8 server processes will use all ports between 4500 and 4507.7474+ '';7575+ };7676+7777+ openFirewall = mkOption {7878+ type = types.bool;7979+ default = false;8080+ description = ''8181+ Open the firewall ports corresponding to FoundationDB processes and coordinators8282+ using <option>config.networking.firewall.*</option>.8383+ '';8484+ };8585+8686+ dataDir = mkOption {8787+ type = types.path;8888+ default = "/var/lib/foundationdb";8989+ description = "Data directory. All cluster data will be put under here.";9090+ };9191+9292+ logDir = mkOption {9393+ type = types.path;9494+ default = "/var/log/foundationdb";9595+ description = "Log directory.";9696+ };9797+9898+ user = mkOption {9999+ type = types.str;100100+ default = "foundationdb";101101+ description = "User account under which FoundationDB runs.";102102+ };103103+104104+ group = mkOption {105105+ type = types.str;106106+ default = "foundationdb";107107+ description = "Group account under which FoundationDB runs.";108108+ };109109+110110+ class = mkOption {111111+ type = types.nullOr (types.enum [ "storage" "transaction" "stateless" ]);112112+ default = null;113113+ description = "Process class";114114+ };115115+116116+ restartDelay = mkOption {117117+ type = types.int;118118+ default = 10;119119+ description = "Number of seconds to wait before restarting servers.";120120+ };121121+122122+ logSize = mkOption {123123+ type = types.string;124124+ default = "10MiB";125125+ description = ''126126+ Roll over to a new log file after the current log file127127+ reaches the specified size.128128+ '';129129+ };130130+131131+ maxLogSize = mkOption {132132+ type = types.string;133133+ default = "100MiB";134134+ description = ''135135+ Delete the oldest log file when the total size of all log136136+ files exceeds the specified size. If set to 0, old log files137137+ will not be deleted.138138+ '';139139+ };140140+141141+ serverProcesses = mkOption {142142+ type = types.int;143143+ default = 1;144144+ description = "Number of fdbserver processes to run.";145145+ };146146+147147+ backupProcesses = mkOption {148148+ type = types.int;149149+ default = 1;150150+ description = "Number of backup_agent processes to run for snapshots.";151151+ };152152+153153+ memory = mkOption {154154+ type = types.string;155155+ default = "8GiB";156156+ description = ''157157+ Maximum memory used by the process. The default value is158158+ <literal>8GiB</literal>. When specified without a unit,159159+ <literal>MiB</literal> is assumed. This parameter does not160160+ change the memory allocation of the program. Rather, it sets161161+ a hard limit beyond which the process will kill itself and162162+ be restarted. The default value of <literal>8GiB</literal>163163+ is double the intended memory usage in the default164164+ configuration (providing an emergency buffer to deal with165165+ memory leaks or similar problems). It is not recommended to166166+ decrease the value of this parameter below its default167167+ value. It may be increased if you wish to allocate a very168168+ large amount of storage engine memory or cache. In169169+ particular, when the <literal>storageMemory</literal>170170+ parameter is increased, the <literal>memory</literal>171171+ parameter should be increased by an equal amount.172172+ '';173173+ };174174+175175+ storageMemory = mkOption {176176+ type = types.string;177177+ default = "1GiB";178178+ description = ''179179+ Maximum memory used for data storage. The default value is180180+ <literal>1GiB</literal>. When specified without a unit,181181+ <literal>MB</literal> is assumed. Clusters using the memory182182+ storage engine will be restricted to using this amount of183183+ memory per process for purposes of data storage. Memory184184+ overhead associated with storing the data is counted against185185+ this total. If you increase the186186+ <literal>storageMemory</literal>, you should also increase187187+ the <literal>memory</literal> parameter by the same amount.188188+ '';189189+ };190190+191191+ locality = mkOption {192192+ default = {193193+ machineId = null;194194+ zoneId = null;195195+ datacenterId = null;196196+ dataHall = null;197197+ };198198+199199+ description = ''200200+ FoundationDB locality settings.201201+ '';202202+203203+ type = types.submodule ({204204+ options = {205205+ machineId = mkOption {206206+ default = null;207207+ type = types.nullOr types.str;208208+ description = ''209209+ Machine identifier key. All processes on a machine should share a210210+ unique id. By default, processes on a machine determine a unique id to share.211211+ This does not generally need to be set.212212+ '';213213+ };214214+215215+ zoneId = mkOption {216216+ default = null;217217+ type = types.nullOr types.str;218218+ description = ''219219+ Zone identifier key. Processes that share a zone id are220220+ considered non-unique for the purposes of data replication.221221+ If unset, defaults to machine id.222222+ '';223223+ };224224+225225+ datacenterId = mkOption {226226+ default = null;227227+ type = types.nullOr types.str;228228+ description = ''229229+ Data center identifier key. All processes physically located in a230230+ data center should share the id. If you are depending on data231231+ center based replication this must be set on all processes.232232+ '';233233+ };234234+235235+ dataHall = mkOption {236236+ default = null;237237+ type = types.nullOr types.str;238238+ description = ''239239+ Data hall identifier key. All processes physically located in a240240+ data hall should share the id. If you are depending on data241241+ hall based replication this must be set on all processes.242242+ '';243243+ };244244+ };245245+ });246246+ };247247+248248+ extraReadWritePaths = mkOption {249249+ default = [ ];250250+ type = types.listOf types.path;251251+ description = ''252252+ An extra set of filesystem paths that FoundationDB can read to253253+ and write from. By default, FoundationDB runs under a heavily254254+ namespaced systemd environment without write access to most of255255+ the filesystem outside of its data and log directories. By256256+ adding paths to this list, the set of writeable paths will be257257+ expanded. This is useful for allowing e.g. backups to local files,258258+ which must be performed on behalf of the foundationdb service.259259+ '';260260+ };261261+262262+ pidfile = mkOption {263263+ type = types.path;264264+ default = "/run/foundationdb.pid";265265+ description = "Path to pidfile for fdbmonitor.";266266+ };267267+ };268268+269269+ config = mkIf cfg.enable {270270+ meta.doc = ./foundationdb.xml;271271+ meta.maintainers = with lib.maintainers; [ thoughtpolice ];272272+273273+ environment.systemPackages = [ pkgs.foundationdb ];274274+275275+ users.extraUsers = optionalAttrs (cfg.user == "foundationdb") (singleton276276+ { name = "foundationdb";277277+ description = "FoundationDB User";278278+ uid = config.ids.uids.foundationdb;279279+ group = cfg.group;280280+ });281281+282282+ users.extraGroups = optionalAttrs (cfg.group == "foundationdb") (singleton283283+ { name = "foundationdb";284284+ gid = config.ids.gids.foundationdb;285285+ });286286+287287+ networking.firewall.allowedTCPPortRanges = mkIf cfg.openFirewall288288+ [ { from = cfg.listenPortStart;289289+ to = (cfg.listenPortStart + cfg.serverProcesses) - 1;290290+ }291291+ ];292292+293293+ systemd.services.foundationdb = {294294+ description = "FoundationDB Service";295295+296296+ after = [ "network.target" ];297297+ wantedBy = [ "multi-user.target" ];298298+ unitConfig =299299+ { RequiresMountsFor = "${cfg.dataDir} ${cfg.logDir}";300300+ };301301+302302+ serviceConfig =303303+ let rwpaths = [ cfg.dataDir cfg.logDir cfg.pidfile "/etc/foundationdb" ]304304+ ++ cfg.extraReadWritePaths;305305+ in306306+ { Type = "simple";307307+ Restart = "always";308308+ RestartSec = 5;309309+ User = cfg.user;310310+ Group = cfg.group;311311+ PIDFile = "${cfg.pidfile}";312312+313313+ PermissionsStartOnly = true; # setup needs root perms314314+ TimeoutSec = 120; # give reasonable time to shut down315315+316316+ # Security options317317+ NoNewPrivileges = true;318318+ ProtectHome = true;319319+ ProtectSystem = "strict";320320+ ProtectKernelTunables = true;321321+ ProtectControlGroups = true;322322+ PrivateTmp = true;323323+ PrivateDevices = true;324324+ ReadWritePaths = lib.concatStringsSep " " (map (x: "-" + x) rwpaths);325325+ };326326+327327+ path = [ pkgs.foundationdb pkgs.coreutils ];328328+329329+ preStart = ''330330+ rm -f ${cfg.pidfile} && \331331+ touch ${cfg.pidfile} && \332332+ chown -R ${cfg.user}:${cfg.group} ${cfg.pidfile}333333+334334+ for x in "${cfg.logDir}" "${cfg.dataDir}" /etc/foundationdb; do335335+ [ ! -d "$x" ] && mkdir -m 0700 -vp "$x" && chown -R ${cfg.user}:${cfg.group} "$x";336336+ done337337+338338+ if [ ! -f /etc/foundationdb/fdb.cluster ]; then339339+ cf=/etc/foundationdb/fdb.cluster340340+ desc=$(tr -dc A-Za-z0-9 </dev/urandom 2>/dev/null | head -c8)341341+ rand=$(tr -dc A-Za-z0-9 </dev/urandom 2>/dev/null | head -c8)342342+ echo ''${desc}:''${rand}@${initialIpAddr}:${builtins.toString cfg.listenPortStart} > $cf343343+ chmod 0660 $cf && chown -R ${cfg.user}:${cfg.group} $cf344344+ touch "${cfg.dataDir}/.first_startup"345345+ fi346346+ '';347347+348348+ script = ''349349+ exec fdbmonitor --lockfile ${cfg.pidfile} --conffile ${configFile};350350+ '';351351+352352+ postStart = ''353353+ if [ -e "${cfg.dataDir}/.first_startup" ]; then354354+ fdbcli --exec "configure new single ssd"355355+ rm -f "${cfg.dataDir}/.first_startup";356356+ fi357357+ '';358358+ };359359+ };360360+}
+279
nixos/modules/services/databases/foundationdb.xml
···11+<chapter xmlns="http://docbook.org/ns/docbook"22+ xmlns:xlink="http://www.w3.org/1999/xlink"33+ xmlns:xi="http://www.w3.org/2001/XInclude"44+ version="5.0"55+ xml:id="module-foundationdb">66+77+<title>FoundationDB</title>88+99+<para><emphasis>Source:</emphasis> <filename>modules/services/databases/foundationdb.nix</filename></para>1010+1111+<para><emphasis>Upstream documentation:</emphasis> <link xlink:href="https://apple.github.io/foundationdb/"/></para>1212+1313+<para><emphasis>Maintainer:</emphasis> Austin Seipp</para>1414+1515+<para><emphasis>Default version:</emphasis> 5.1.x</para>1616+1717+<para>FoundationDB (or "FDB") is a distributed, open source, high performance,1818+transactional key-value store. It can store petabytes of data and deliver1919+exceptional performance while maintaining consistency and ACID semantics over a2020+large cluster.</para>2121+2222+<section><title>Configuring and basic setup</title>2323+2424+<para>To enable FoundationDB, add the following to your2525+<filename>configuration.nix</filename>:2626+2727+<programlisting>2828+services.foundationdb.enable = true;2929+</programlisting>3030+</para>3131+3232+<para>After running <command>nixos-rebuild</command>, you can verify whether3333+FoundationDB is running by executing <command>fdbcli</command> (which is added3434+to <option>environment.systemPackages</option>):3535+3636+<programlisting>3737+$ sudo -u foundationdb fdbcli3838+Using cluster file `/etc/foundationdb/fdb.cluster'.3939+4040+The database is available.4141+4242+Welcome to the fdbcli. For help, type `help'.4343+fdb> status4444+4545+Using cluster file `/etc/foundationdb/fdb.cluster'.4646+4747+Configuration:4848+ Redundancy mode - single4949+ Storage engine - memory5050+ Coordinators - 15151+5252+Cluster:5353+ FoundationDB processes - 15454+ Machines - 15555+ Memory availability - 5.4 GB per process on machine with least available5656+ Fault Tolerance - 0 machines5757+ Server time - 04/20/18 15:21:145858+5959+...6060+6161+fdb>6262+</programlisting>6363+</para>6464+6565+<para>FoundationDB is run under the <command>foundationdb</command> user and6666+group by default, but this may be changed in the NixOS configuration. The6767+systemd unit <command>foundationdb.service</command> controls the6868+<command>fdbmonitor</command> process.</para>6969+7070+<para>By default, the NixOS module for FoundationDB creates a single7171+SSD-storage based database for development and basic usage. This storage engine7272+is designed for SSDs and will perform poorly on HDDs; however it can handle far7373+more data than the alternative "memory" engine and is a better default choice7474+for most deployments. (Note that you can change the storage backend on-the-fly7575+for a given FoundationDB cluster using <command>fdbcli</command>.)</para>7676+7777+<para>Furthermore, only 1 server process and 1 backup agent are started in the7878+default configuration. See below for more on scaling to increase this.</para>7979+8080+<para>FoundationDB stores all data for all server processes under8181+<filename>/var/lib/foundationdb</filename>. You can override this using8282+<option>services.foundationdb.dataDir</option>, e.g.8383+8484+<programlisting>8585+services.foundationdb.dataDir = "/data/fdb";8686+</programlisting>8787+8888+</para>8989+9090+<para>Similarly, logs are stored under9191+<filename>/var/log/foundationdb</filename> by default, and there is a9292+corresponding <option>services.foundationdb.logDir</option> as well.</para>9393+9494+</section>9595+9696+<section><title>Scaling processes and backup agents</title>9797+9898+<para>Scaling the number of server processes is quite easy; simply specify9999+<option>services.foundationdb.serverProcesses</option> to be the number of100100+FoundationDB worker processes that should be started on the machine.</para>101101+102102+<para>FoundationDB worker processes typically require 4GB of RAM per-process at103103+minimum for good performance, so this option is set to 1 by default since the104104+maximum aount of RAM is unknown. You're advised to abide by this restriction,105105+so pick a number of processes so that each has 4GB or more.</para>106106+107107+<para>A similar option exists in order to scale backup agent processes,108108+<option>services.foundationdb.backupProcesses</option>. Backup agents are not109109+as performance/RAM sensitive, so feel free to experiment with the number of110110+available backup processes.</para>111111+112112+</section>113113+114114+<section><title>Clustering</title>115115+116116+<para>FoundationDB on NixOS works similarly to other Linux systems, so this117117+section will be brief. Please refer to the full FoundationDB documentation for118118+more on clustering.</para>119119+120120+<para>FoundationDB organizes clusters using a set of121121+<emphasis>coordinators</emphasis>, which are just specially-designated worker122122+processes. By default, every installation of FoundationDB on NixOS will start123123+as its own individual cluster, with a single coordinator: the first worker124124+process on <command>localhost</command>.</para>125125+126126+<para>Coordinators are specified globally using the127127+<command>/etc/foundationdb/fdb.cluster</command> file, which all servers and128128+client applications will use to find and join coordinators. Note that this file129129+<emphasis>can not</emphasis> be managed by NixOS so easily: FoundationDB is130130+designed so that it will rewrite the file at runtime for all clients and nodes131131+when cluster coordinators change, with clients transparently handling this132132+without intervention.</para>133133+134134+<para>When dealing with a cluster, there are two main things you want to135135+do:</para>136136+137137+<itemizedlist>138138+ <listitem><para>Add a node to the cluster for storage/compute.</para></listitem>139139+ <listitem><para>Promote an ordinary worker to a coordinator.</para></listitem>140140+</itemizedlist>141141+142142+<para>A node must already be a member of the cluster in order to properly be143143+promoted to a coordinator, so you must always add it first if you wish to144144+promote it.</para>145145+146146+<para>To add a machine to a FoundationDB cluster:</para>147147+148148+<itemizedlist>149149+ <listitem><para>Choose one of the servers to start as the initial coordinator.150150+ </para></listitem>151151+ <listitem><para>Copy the <command>/etc/foundationdb/fdb.cluster</command> file152152+ from this server to all the other servers. Restart FoundationDB on all of153153+ these other servers, so they join the cluster.</para></listitem>154154+ <listitem><para>All of these servers are now connected and working together155155+ in the cluster, under the chosen coordinator.</para></listitem>156156+</itemizedlist>157157+158158+<para>At this point, you can add as many nodes as you want by just repeating159159+the above steps. By default there will still be a single coordinator: you can160160+use <command>fdbcli</command> to change this and add new coordinators.</para>161161+162162+<para>As a convenience, FoundationDB can automatically assign coordinators163163+based on the redundancy mode you wish to achieve for the cluster. Once all the164164+nodes have been joined, simply set the replication policy, and then issue the165165+<command>coordinators auto</command> command</para>166166+167167+<para>For example, assuming we have 3 nodes available, we can enable double168168+redundancy mode, then auto-select coordinators. For double redundancy, 3169169+coordinators is ideal: therefore FoundationDB will make170170+<emphasis>every</emphasis> node a coordinator automatically:</para>171171+172172+<programlisting>173173+fdbcli> configure double ssd174174+fdbcli> coordinators auto175175+</programlisting>176176+177177+<para>This will transparently update all the servers within seconds, and178178+appropriately rewrite the <command>fdb.cluster</command> file, as well as179179+informing all client processes to do the same.</para>180180+181181+</section>182182+183183+<section><title>Client connectivity</title>184184+185185+<para>By default, all clients must use the current186186+<command>fdb.cluster</command> file to access a given FoundationDB cluster.187187+This file is located by default in188188+<command>/etc/foundationdb/fdb.cluster</command> on all machines with the189189+FoundationDB service enabled, so you may copy the active one from your cluster190190+to a new node in order to connect, if it is not part of the cluster.</para>191191+192192+</section>193193+194194+<section><title>Backups and Disaster Recovery</title>195195+196196+<para>The usual rules for doing FoundationDB backups apply on NixOS as written197197+in the FoundationDB manual. However, one important difference is the security198198+profile for NixOS: by default, the <command>foundationdb</command> systemd unit199199+uses <emphasis>Linux namespaces</emphasis> to restrict write access to the200200+system, except for the log directory, data directory, and the201201+<command>/etc/foundationdb/</command> directory. This is enforced by default202202+and cannot be disabled.</para>203203+204204+<para>However, a side effect of this is that the <command>fdbbackup</command>205205+command doesn't work properly for local filesystem backups: FoundationDB uses a206206+server process alongside the database processes to perform backups and copy the207207+backups to the filesystem. As a result, this process is put under the208208+restricted namespaces above: the backup process can only write to a limited209209+number of paths.</para>210210+211211+<para>In order to allow flexible backup locations on local disks, the212212+FoundationDB NixOS module supports a213213+<option>services.foundationdb.extraReadWritePaths</option> option. This option214214+takes a list of paths, and adds them to the systemd unit, allowing the215215+processes inside the service to write (and read) the specified216216+directories.</para>217217+218218+<para>For example, to create backups in <command>/opt/fdb-backups</command>,219219+first set up the paths in the module options:</para>220220+221221+<programlisting>222222+services.foundationdb.extraReadWritePaths = [ "/opt/fdb-backups" ];223223+</programlisting>224224+225225+<para>Restart the FoundationDB service, and it will now be able to write to226226+this directory (even if it does not yet exist.) Note: this path227227+<emphasis>must</emphasis> exist before restarting the unit. Otherwise, systemd228228+will not include it in the private FoundationDB namespace (and it will not add229229+it dynamically at runtime).</para>230230+231231+<para>You can now perform a backup:</para>232232+233233+<programlisting>234234+$ sudo -u foundationdb fdbbackup start -t default -d file:///opt/fdb-backups235235+$ sudo -u foundationdb fdbbackup status -t default236236+</programlisting>237237+238238+</section>239239+240240+<section><title>Known limitations</title>241241+242242+<para>The FoundationDB setup for NixOS should currently be considered beta.243243+FoundationDB is not new software, but the NixOS compilation and integration has244244+only undergone fairly basic testing of all the available functionality.</para>245245+246246+<itemizedlist>247247+ <listitem><para>TLS plugin support is compiled in, but it's currently not248248+ possible to specify the set of TLS certificate options in249249+ <command>services.foundationdb</command></para></listitem>250250+ <listitem><para>There is no way to specify individual parameters for251251+ individual <command>fdbserver</command> processes. Currently, all server252252+ processes inherit all the global <command>fdbmonitor</command> settings.253253+ </para></listitem>254254+ <listitem><para>Python bindings are not currently installed.</para></listitem>255255+ <listitem><para>Ruby bindings are not currently installed.</para></listitem>256256+ <listitem><para>Java bindings are not currently installed.</para></listitem>257257+ <listitem><para>Go bindings are not currently installed.</para></listitem>258258+</itemizedlist>259259+260260+</section>261261+262262+<section><title>Options</title>263263+264264+<para>NixOS's FoundationDB module allows you to configure all of the most265265+relevant configuration options for <command>fdbmonitor</command>, matching it266266+quite closely. For a complete list of all options, check <command>man267267+configuration.nix</command>.</para>268268+269269+</section>270270+271271+<section><title>Full documentation</title>272272+273273+<para>FoundationDB is a complex piece of software, and requires careful274274+administration to properly use. Full documentation for administration can be275275+found here: <link xlink:href="https://apple.github.io/foundationdb/"/>.</para>276276+277277+</section>278278+279279+</chapter>
···33with import ../lib/testing.nix { inherit system; };4455let66+ readyFile = "/tmp/readerReady";77+ resultFile = "/tmp/readerResult";88+69 testReader = pkgs.writeScript "test-input-reader" ''710 #!${pkgs.stdenv.shell}88- readInput() {99- touch /tmp/reader.ready1010- echo "Waiting for '$1' to be typed"1111- read -r -n1 c1212- if [ "$c" = "$2" ]; then1313- echo "SUCCESS: Got back '$c' as expected."1414- echo 0 >&21515- else1616- echo "FAIL: Expected '$2' but got '$c' instead."1717- echo 1 >&21818- fi1919- }1111+ rm -f ${resultFile}1212+ logger "testReader: START: Waiting for $1 characters, expecting '$2'."1313+ touch ${readyFile}1414+ read -r -N $1 chars1515+ rm -f ${readyFile}20162121- main() {2222- error=02323- while [ $# -gt 0 ]; do2424- ret="$((readInput "$2" "$3" | systemd-cat -t "$1") 2>&1)"2525- if [ $ret -ne 0 ]; then error=1; fi2626- shift 32727- done2828- return $error2929- }3030-3131- main "$@"; echo -n $? > /tmp/reader.exit1717+ if [ "$chars" == "$2" ]; then1818+ logger -s "testReader: PASS: Got '$2' as expected." 2>${resultFile}1919+ else2020+ logger -s "testReader: FAIL: Expected '$2' but got '$chars'." 2>${resultFile}2121+ fi3222 '';33233434- mkReaderInput = testname: { qwerty, expect }: with pkgs.lib; let3535- lq = length qwerty;3636- le = length expect;3737- msg = "`qwerty' (${lq}) and `expect' (${le}) lists"3838- + " need to be of the same length!";3939- result = flatten (zipListsWith (a: b: [testname a b]) qwerty expect);4040- in if lq != le then throw msg else result;41244225 mkKeyboardTest = layout: { extraConfig ? {}, tests }: with pkgs.lib; let4343- readerInput = flatten (mapAttrsToList mkReaderInput tests);2626+ combinedTests = foldAttrs (acc: val: acc ++ val) [] (builtins.attrValues tests);4427 perlStr = val: "'${escape ["'" "\\"] val}'";4545- perlReaderInput = concatMapStringsSep ", " perlStr readerInput;2828+ lq = length combinedTests.qwerty;2929+ le = length combinedTests.expect;3030+ msg = "length mismatch between qwerty (${toString lq}) and expect (${toString le}) lists!";3131+ send = concatMapStringsSep ", " perlStr combinedTests.qwerty;3232+ expect = if (lq == le) then concatStrings combinedTests.expect else throw msg;3333+4634 in makeTest {4735 name = "keymap-${layout}";4836···3850 machine.i18n.consoleKeyMap = mkOverride 900 layout;3951 machine.services.xserver.layout = mkOverride 900 layout;4052 machine.imports = [ ./common/x11.nix extraConfig ];4141- machine.services.xserver.displayManager.slim.enable = true;42534354 testScript = ''4444- sub waitCatAndDelete ($) {4545- return $machine->succeed(4646- "for i in \$(seq 600); do if [ -e '$_[0]' ]; then ".4747- "cat '$_[0]' && rm -f '$_[0]' && exit 0; ".4848- "fi; sleep 0.1; done; echo timed out after 60 seconds >&2; exit 1"4949- );5050- };51555256 sub mkTest ($$) {5357 my ($desc, $cmd) = @_;54585555- my @testdata = (${perlReaderInput});5656- my $shellTestdata = join ' ', map { "'".s/'/'\\'''/gr."'" } @testdata;5757-5859 subtest $desc, sub {5959- $machine->succeed("$cmd ${testReader} $shellTestdata &");6060- while (my ($testname, $qwerty, $expect) = splice(@testdata, 0, 3)) {6161- waitCatAndDelete "/tmp/reader.ready";6262- $machine->sendKeys($qwerty);6363- };6464- my $exitcode = waitCatAndDelete "/tmp/reader.exit";6565- die "tests for $desc failed" if $exitcode ne 0;6060+ # prepare and start testReader6161+ $machine->execute("rm -f ${readyFile} ${resultFile}");6262+ $machine->succeed("$cmd ${testReader} ${toString le} ".q(${escapeShellArg expect} & ));6363+6464+ if ($desc eq "Xorg keymap") {6565+ # make sure the xterm window is open and has focus6666+ $machine->waitForWindow(qr/testterm/);6767+ $machine->succeed("${pkgs.xdotool}/bin/xdotool search --name testterm windowactivate --sync");6868+ }6969+7070+ # wait for reader to be ready7171+ $machine->waitForFile("${readyFile}");7272+ $machine->sleep(1);7373+7474+ # send all keys7575+ foreach ((${send})) { $machine->sendKeys($_); };7676+7777+ # wait for result and check7878+ $machine->waitForFile("${resultFile}");7979+ $machine->succeed("grep -q 'PASS:' ${resultFile}");6680 };6767- }8181+ };68826983 $machine->waitForX;70847185 mkTest "VT keymap", "openvt -sw --";7272- mkTest "Xorg keymap", "DISPLAY=:0 xterm -fullscreen -e";8686+ mkTest "Xorg keymap", "DISPLAY=:0 xterm -title testterm -fullscreen -e";7387 '';7488 };7589
+6-4
pkgs/applications/altcoins/bitcoin-unlimited.nix
···11{ stdenv, fetchFromGitHub, pkgconfig, autoreconfHook, openssl, db48, boost22, zlib, miniupnpc, qt4, utillinux, protobuf, qrencode, libevent33-, withGui }:33+, withGui44+, Foundation, ApplicationServices, AppKit }:4556with stdenv.lib;67···2019 nativeBuildInputs = [ pkgconfig autoreconfHook ];2120 buildInputs = [ openssl db48 boost zlib2221 miniupnpc utillinux protobuf libevent ]2323- ++ optionals withGui [ qt4 qrencode ];2222+ ++ optionals withGui [ qt4 qrencode ]2323+ ++ optionals stdenv.isDarwin [ Foundation ApplicationServices AppKit ];24242525 patches = [2626 ./bitcoin-unlimited-const-comparators.patch···3836 completely decentralized, without the need for a central server or trusted3937 parties. Users hold the crypto keys to their own money and transact directly4038 with each other, with the help of a P2P network to check for double-spending.4141-3939+4240 The Bitcoin Unlimited (BU) project seeks to provide a voice to all4341 stakeholders in the Bitcoin ecosystem.4442···57555856 If you support an increase in the blocksize limit by any means - or just5957 support Bitcoin conflict resolution as originally envisioned by its founder -6060- consider running a Bitcoin Unlimited client. 5858+ consider running a Bitcoin Unlimited client.6159 '';6260 homepage = https://www.bitcoinunlimited.info/;6361 maintainers = with maintainers; [ DmitryTsygankov ];
+5-3
pkgs/applications/altcoins/bitcoin-xt.nix
···11{ stdenv, fetchFromGitHub, pkgconfig, autoreconfHook, openssl, db48, boost22, zlib, miniupnpc, qt4, utillinux, protobuf, qrencode, curl, libevent33-, withGui }:33+, withGui44+, Foundation, ApplicationServices, AppKit }:4556with stdenv.lib;67stdenv.mkDerivation rec{···1918 nativeBuildInputs = [ pkgconfig autoreconfHook ];2019 buildInputs = [ openssl db48 boost zlib libevent2120 miniupnpc utillinux protobuf curl ]2222- ++ optionals withGui [ qt4 qrencode ];2121+ ++ optionals withGui [ qt4 qrencode ]2222+ ++ optionals stdenv.isDarwin [ Foundation ApplicationServices AppKit ];23232424 configureFlags = [2525 "--with-boost-libdir=${boost.out}/lib"···3836 Bitcoin XT is an implementation of a Bitcoin full node, based upon the3937 source code of Bitcoin Core. It is built by taking the latest stable4038 Core release, applying a series of patches, and then doing deterministic4141- builds so anyone can check the downloads correspond to the source code. 3939+ builds so anyone can check the downloads correspond to the source code.4240 '';4341 homepage = https://bitcoinxt.software/;4442 maintainers = with maintainers; [ jefdaj ];
···11{ stdenv22, coreutils33, patchelf44-, requireFile44+, callPackage55, alsaLib66, dbus77, fontconfig···1818, zlib1919, libxml22020, libuuid2121+, lang ? "en"2122}:22232324let···2726 "Linux"2827 else2928 throw "Mathematica requires i686-linux or x86_64 linux";2929+3030+ l10n =3131+ with stdenv.lib;3232+ with callPackage ./l10ns.nix {};3333+ flip (findFirst (l: l.lang == lang)) l10ns3434+ (throw "Language '${lang}' not supported");3035in3136stdenv.mkDerivation rec {3232- version = "11.2.0";3333-3434- name = "mathematica-${version}";3535-3636- src = requireFile rec {3737- name = "Mathematica_${version}_LINUX.sh";3838- message = '' 3939- This nix expression requires that ${name} is4040- already part of the store. Find the file on your Mathematica CD4141- and add it to the nix store with nix-store --add-fixed sha256 <FILE>.4242- '';4343- sha256 = "4a1293cc1c404303aa1cab1bd273c7be151d37ac5ed928fbbb18e9c5ab2d8df9";4444- };3737+ inherit (l10n) version name src;45384639 buildInputs = [4740 coreutils
···11+{ lib, requireFile }:22+33+with lib;44+{55+ l10ns = flip map66+ [77+ {88+ version = "11.2.0";99+ lang = "en";1010+ language = "English";1111+ sha256 = "4a1293cc1c404303aa1cab1bd273c7be151d37ac5ed928fbbb18e9c5ab2d8df9";1212+ }1313+ {1414+ version = "11.2.0";1515+ lang = "ja";1616+ language = "Japanese";1717+ sha256 = "916392edd32bed8622238df435dd8e86426bb043038a3336f30df10d819b49b1";1818+ }1919+ ]2020+ ({ version, lang, language, sha256 }: {2121+ inherit version lang;2222+ name = "mathematica-${version}" + optionalString (lang != "en") "-${lang}";2323+ src = requireFile rec {2424+ name = "Mathematica_${version}" + optionalString (lang != "en") "_${language}" + "_LINUX.sh";2525+ message = ''2626+ This nix expression requires that ${name} is2727+ already part of the store. Find the file on your Mathematica CD2828+ and add it to the nix store with nix-store --add-fixed sha256 <FILE>.2929+ '';3030+ inherit sha256;3131+ };3232+ });3333+}
+4
pkgs/applications/science/math/maxima/default.nix
···6969 url = "https://git.sagemath.org/sage.git/plain/build/pkgs/maxima/patches/maxima.system.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";7070 sha256 = "18zafig8vflhkr80jq2ivk46k92dkszqlyq8cfmj0b2vcfjwwbar";7171 })7272+ # There are some transient test failures. I hope this disables all those tests.7373+ # If those test failures ever happen in the non-ecl version, that should be7474+ # reportetd upstream.7575+ ./known-ecl-failures.patch7276 ];73777478 # Failures in the regression test suite won't abort the build process. We run
···11-{ fetchurl, stdenv }:11+{ stdenv22+, fetchurl33+# Excerpt from glpk's INSTALL file:44+# This feature allows the exact simplex solver to use the GNU MP55+# bignum library. If it is disabled, the exact simplex solver uses the66+# GLPK bignum module, which provides the same functionality as GNU MP,77+# however, it is much less efficient.88+, withGmp ? true99+, gmp1010+}:1111+1212+assert withGmp -> gmp != null;213314stdenv.mkDerivation rec {44- name = "glpk-4.65";1515+ version = "4.65";1616+ name = "glpk-${version}";517618 src = fetchurl {719 url = "mirror://gnu/glpk/${name}.tar.gz";820 sha256 = "040sfaa9jclg2nqdh83w71sv9rc1sznpnfiripjdyr48cady50a2";921 };2222+2323+ buildInputs = stdenv.lib.optionals withGmp [2424+ gmp2525+ ];2626+2727+ configureFlags = stdenv.lib.optionals withGmp [2828+ "--with-gmp"2929+ ];10301131 doCheck = true;1232···4323 homepage = http://www.gnu.org/software/glpk/;4424 license = stdenv.lib.licenses.gpl3Plus;45254646- maintainers = [ stdenv.lib.maintainers.bjg ];2626+ maintainers = with stdenv.lib.maintainers; [ bjg ];4727 platforms = stdenv.lib.platforms.all;4828 };4929}
···77 owner = "gphoto";88 repo = "libgphoto2";99 rev = "${meta.tag}";1010- sha256 = "1svbpmxqm56pqkv0rxhlyk4vw7mjgjz8zz4p669qvmw630082yj9";1010+ sha256 = "0pbfg89817qkb35mmajsw2iz6j9nhkkj67m419f8x8yxpqkaa0wb";1111 };12121313 patches = [];···3333 MTP, and other vendor specific protocols for controlling and transferring data3434 from digital cameras.3535 '';3636- version = "2.5.16";3737- tag = "libgphoto2-2_5_16-release";3636+ version = "2.5.17";3737+ tag = "libgphoto2-2_5_17-release";3838 # XXX: the homepage claims LGPL, but several src files are lgpl21Plus3939 license = stdenv.lib.licenses.lgpl21Plus;4040 platforms = with stdenv.lib.platforms; unix;
···153153 # to be adapted154154 zfsStable = common {155155 # comment/uncomment if breaking kernel versions are known156156- incompatibleKernelVersion = null;156156+ incompatibleKernelVersion = "4.16";157157158158 # this package should point to the latest release.159159 version = "0.7.8";
+1-1
pkgs/servers/dns/knot-dns/default.nix
···32323333 #doCheck = true; problems in combination with dynamic linking34343535- postInstall = ''rm -r "$out"/var'';3535+ postInstall = ''rm -r "$out"/var "$out"/lib/*.la'';36363737 meta = with stdenv.lib; {3838 description = "Authoritative-only DNS server from .cz domain registry";