Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wyaWR-003Upw-00 for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Aug 2026 19:39:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wyaWP-0049S6-2v for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Aug 2026 19:39:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wyaWO-0049Rx-3B for pgsql-hackers@lists.postgresql.org; Mon, 24 Aug 2026 19:39:53 +0000 Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wyaWM-00000002ELi-3AEt for pgsql-hackers@lists.postgresql.org; Mon, 24 Aug 2026 19:39:52 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 281E7EC04D7; Mon, 24 Aug 2026 15:39:49 -0400 (EDT) Received: from phl-imap-15 ([10.202.2.104]) by phl-compute-05.internal (MEProxy); Mon, 24 Aug 2026 15:39:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=partin.io; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1787600389; x=1787686789; bh=5qxNafwbGrKHbe/cVLWuh1mIRXmmWhJ5ptQYuTFp7AM=; b= oKbTRmL7ceBBUgPrdO7e5OLEkX1aEjbuWIfldEbE95SGWv/Eo1n3R2upiQSBpM/a EyBcIea6zl9pu/x73FLsyslfN6OYCycC8Iplt3SsC+/VvlvMOTW1y2K8frJZJ3R7 mLnr9G3tXSsvzVCHYxUmIKp6LUVo5gWH6BYPiu3GWb8Z5tqt3298hdl516fxFQ8T PaXPnv+BU5/Dt8G3h943aUDe4g3CVpuf4J9VeW5+xesh+ItpuG/R8DacoRyvAkVD 8yyPzTvEH85vksx6u4HftaY8c/DZ75a6wfpxiKEHwzo6JI6lszmnsa56C3OR16FZ cTax11G4pGT0r571adqbpQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1787600389; x= 1787686789; bh=5qxNafwbGrKHbe/cVLWuh1mIRXmmWhJ5ptQYuTFp7AM=; b=f cg/QFfuPPEfuBaB2U88KoMlTVkVzFLHPmReDjpDncw2rpYPpcaHUqgKu3l2QMkE/ 3aXBfq0VcQPekpyhxU1GX/eKkOrGz/S0lObl9HviA6YqyeguDBdsDC/IWJXlRnjz 72v27kIrIaNpy1DFSsZs5zzwvJLr2TUnsPlcr6y5wjdGcgsjnit9GLjfm3B7Vmpx 843udtDQGaZ9OT2rpV/AgucFJN4/idfxAyiilO1PJA5/slJJG9wAHqmrbrYvQFzB 06dC34vz6ZKi8YRE4spS5JCkHMm7n+25j5Uu9v+xhKCrqyn6pGTR7HPgctXLPrfX 812O0Cp+OfqhgRwgqnfZA== X-ME-Sender: X-ME-Proxy-Cause: dmFkZTE1/48ygadwY0B+A/XeL4wbiQp9kpQF0VDFmr4jxvmM5n2H3NLPdHk/icgSrjfRTe nFMBowQbQICiGX0eBsls8G1R6ABJl+3H9Y2V6eSvxm2GcKFbHt6Y2sIKjKeKht8AVstVq+ GLBAFCCwkzDOkMhSGRhiqTJ6PCbUvwEEF9AETENm93vvW0I4ZrqRXznRzk7vWEzS4JyBEe aBisHHf2OjM6CE2oXvdz/h81udfATANkK3NrUfNiXuBbiG15Grkoy/HE4MZWXLFiG2H5ec AGd2DXvYRWVYyNl7FHYohFIb8iffKvzsPsS9lcZUnrlyhggicmi75Q+zOvQ7Qd8Bi3v4EM 3PM5mCqpeMnFM0Zm12RETZ4N+cGGW0PGBD1/+nCIhUu4fyTqNA2mMcCc5fPQahFnlkpTzP 4ZgU0TKqVJHObKfTQxg0BhIumnCpo57CxeHuPgMDHT3CuEFHQM+bWjVWF4+l2mSUN8zu5E PEURMcJWAk4Xb5vFjqEKbygelGLYASCdsHh/Ckid+PQplVGkNS+dskeL0P/Pfuc7zXjOta MWxJOD1zi+900MK8dij1xq3MamnvP+zREbJ5cqKjI7rM1z1QiySF8qI0GlFznGWrmWYlNc 54miTTJexwSc+8JyrMsYGOU96Pk0JH4C55iKVzQoYe9nmzw39dUNBY2k4qmA X-ME-Proxy: Feedback-ID: idd01497b:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id C2C487811F0; Mon, 24 Aug 2026 15:39:48 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 24 Aug 2026 19:39:48 +0000 Message-Id: Subject: Re: Add a Nix flake To: "Greg Burd" From: "Tristan Partin" Cc: "PostgreSQL Hackers" X-Mailer: aerc 0.22.0 References: In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon Aug 24, 2026 at 11:59 AM CDT, Greg Burd wrote: > Hackers, > > I'd like to propose adding a flake.nix at the repository root. Attached > is a first cut. +1 > This is not another build system. It doesn't touch configure, Meson, or t= he > Makefiles, it wires up what we already have. A flake is a small, declarat= ive > manifest that tells Nix how to fetch our build dependencies and drop a > developer into a shell where ./configure && make or meson setup just > works, with bison, flex, perl, the optional libraries, and the docs > toolchain all present and pinned to compatible versions. nix develop give= s > you that shell; nix build produces a server. > > The reason to carry it in-tree: Nix users are a growing segment of the > PostgreSQL developer base across Linux, macOS, and increasingly the BSDs = and > even illumos. Today each of them keeps a private flake to hack on Postgre= s, I > have one, and I know I'm not alone. These private copies drift, disagree = on > which features to enable, and have to be re-derived every time someone ne= w > wants to contribute from a Nix machine. A single blessed flake in the tre= e > gives everyone the same reproducible starting point and one place to keep= it > current, the same argument that motivates the .editorconfig and CI files = we > already ship. I am one of the people that has a private copy. I've also been working on a NixOS-based buildfarm client that includes a derivation for the buildfarm-client code. > The flake exposes a toggle for every optional feature configure and Meson > support, both build systems, and platform-appropriate defaults (io_uring, > libnuma, systemd, PAM on Linux; Bonjour on macOS), so it's a starting poi= nt, > not a policy so flip anything with an override. > > One deliberate omission: there is no flake.lock. A lock file pins the exa= ct > nixpkgs revision, which is the right call for an application that wants a > frozen environment, but wrong for us. We don't want to freeze contributor= s to > one snapshot of the dependency universe, and we don't want a lock file to > become one more thing that goes stale in the tree and needs bumping. Leav= ing > it out means the flake tracks whatever nixpkgs the developer already runs= , > which is exactly the behavior a build-from-source developer wants. Anyone= who > needs reproducibility can generate a lock locally; the tree stays clean. I think the lack of flake.lock makes sense. I would add it to the .gitignore. Additionally, I would also add `/result` and `/result-*` to the .gitignore. > It's meant to sit at the root next to configure, not in a subdirectory, s= o > that a fresh checkout is immediately usable with nix develop. > > To use it you'll need to be in a Nix environment. This means a Nix-based= OS > like NixOS or the macOS/Windows layers that bring in the Nix environment. > Start by reading the https://nixos.org/learn/ information. Can be Linux as well! For instance, I am using Nix on Fedora, which is available in the Fedora system repositories. > With a flake you can start a "developer shell" (a "dev shell") which will= have > all the dependencies required to build and run Postgres, no installing Al= l The > Things (TM) if you buy into this model you have a predictable environment= , a > shell with developer tools prepared and present always at hand when neede= d. > > So, first start the dev(eloper) shell: > > ``` > nix develop > # then, meson (the default direction): > meson setup build && ninja -C build > > # or classic autoconf: > ./configure && make -j > ``` > > You don't have to enter the dev shell, you could instead build a server: > > ``` > nix build # default: meson, all features for your pl= atform > ./result/bin/postgres --version > ``` > > The presets: > > ``` > nix build .#postgresql-debug # cassert + debug syms + injection poin= ts > nix build .#postgresql-minimal # no optional libs =E2=80=94 fastest co= mpile > nix build .#postgresql-autoconf # configure/make instead of meson > ``` > > Flip any single feature (26 toggles) without a preset: > > ``` > nix build --expr '(builtins.getFlake (toString ./.)).packages.x86_64-linu= x.postgresql.override { llvmSupport =3D true; cassert =3D true; }' > ``` I didn't know that this was a thing. What a mouthful! > Run without installing: > > ``` > nix run . -- --version # runs postgres (mainProgram is psql, so:) > nix run .#postgresql -- --version > ``` > > There are many other things we could add into the flake such as > cross-compilation, but to start off this should suffice. I hope this gen= erates > interest and constructive debate. I'll say upfront, I'm not a Nix master= , > just a user and I find it invaluable. I'm sure I'm not alone. > > Feedback welcome. I think this is a great first pass! I am a recent Nix convert myself, and I have found the development shell to be quite invaluable. I have added flake.nix's to all of my personal projects. I think lowering the bar to PostgreSQL development could really make a meaningful difference in attracting new contributors. I think this will also have side benefits of making things easier to test. For instance, we could start inlining buildfarm client members configurations as derivations in this repository. Then we can have a library of derivations to test against that are tracked in version control that are easily visible to everyone. People who find that their submissions are failing on certain animals could more easily test and diagnose what is causing the animal to fail. Additionally, I wonder if NixOS VM tests could expose new ways to do automated testing of Postgres. That is not something that I have thought about. Regarding the code, can you explain the reasoning for the packages list in the development shell? It seems like everything in the list is already included by the Postgres package. --=20 Tristan Partin PostgreSQL Contributors Team AWS (https://aws.amazon.com)