1

I have made a nix Flake to build a Golang module. It uses a PostgreSQL database. Is it possible to use flake to install PostgreSQL like this using nix flake. The following code runs and builds the Go module.

irmago= buidGoModule {
pname = "irma";

version = "0.8.0"
BuiltInputs =[postgresql]

... and so on

The flake is building fine, and the Irma executable is working. However, the PostgreSQL instance is not installed. it is possible to install PostgreSQL and create a database through the same nix flake so that the complete process (Build IRMA, install PostgreSQL, create a database in it, and then perform connection test) is done in one command. However, as a first step, I am trying to install just PostgreSQL which is not happening.

Peter Becich
  • 989
  • 3
  • 14
  • 30
raghu
  • 335
  • 4
  • 11
  • 2
    Nix by itself does not configure services. Its only purpose is to write store paths. It can produce store paths with service _configuration files_ in them, but it is not responsible for starting and managing services. You can choose from a wide range of tools to do this for you in various scenarios, including NixOS, Arion, NixOps, nixosTest, nix-processmgmt and dockerTools+docker. – Robert Hensing Aug 05 '21 at 21:59
  • So what do you mean by "the complete process"? What are you trying to achieve? – Robert Hensing Aug 05 '21 at 21:59
  • If these services are set up and/or managed by a script, this script could be executed by `nix run`, right? You could have Flake `app` outputs `startPostgres`, `resetPostgres`, etc. Of course it would be better to use one of the tools you have listed. – Peter Becich Aug 27 '23 at 22:43
  • 1
    @raghu , check out this example: https://github.com/nix-community/todomvc-nix (working `nix develop` shell: https://github.com/nix-community/todomvc-nix/pull/44) – Peter Becich Sep 01 '23 at 04:51
  • Also https://github.com/numtide/devshell, which is built on top of Flakes, and supports background services: https://numtide.github.io/devshell/getting_started.html#adding-background-services I am looking for more detail about how that works. – Peter Becich Sep 02 '23 at 07:28

0 Answers0