Re: [Nix-dev] Depending on a service from inside an expression?

2015-04-28 Thread Tomas Hlavaty
Hi Mateusz,

Mateusz Kowalczyk  writes:
> There is a project that as part of its tests has to create a postgresql
> database which means that the postgres server needs to be running.
>
> Is there an easy way to achieve this? How does one go about testing such
> packages to begin with?

I am currently setting something like that (hydra tests) for a nix
module (a systemd service) which requires postgresql.  What works for
me:

1) a nix package file for your program (say foo) so that your program
   compiles and installs

2) a nix env file (say fooEnv) for runtime-only dependencies (not
   detected by nix) which will be deployed as part of the service
   (because there is a limit on the PATH variable length)

3) a nix module file which defines the systemd service.  I have two
   modules:

   - foo-init which takes a long time to set up the database and other
 things

   - foo-service which is the actual service running the foo program

4) a nix vm file which defines a VM with that module plus postgresql
   module.  This is also useful for manually testing the VM.

5) a nix vmtest file which imports nixpkgs/nixos/tests/make-test.nix,
   creates the VM and runs the testScript

If your program doesn't run as a service, you would not need 3) I guess.

nixpkgs/nixos/tests/make-test.nix runs the tests in a fresh qemu machine
which is then discarded.

Cheers,

Tomas
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Depending on a service from inside an expression?

2015-04-27 Thread Ryan Trinkle
It's possible to run postgres with just a unix domain socket for
communication, and no network access. Then, you can point your tests at
that self-contained postgres environment.  Would that work for your
situation?

On Mon, Apr 27, 2015 at 8:52 PM, Mateusz Kowalczyk 
wrote:

> Hi,
>
> There is a project that as part of its tests has to create a postgresql
> database which means that the postgres server needs to be running.
>
> Is there an easy way to achieve this? How does one go about testing such
> packages to begin with?
>
> --
> Mateusz K.
> ___
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


[Nix-dev] Depending on a service from inside an expression?

2015-04-27 Thread Mateusz Kowalczyk
Hi,

There is a project that as part of its tests has to create a postgresql
database which means that the postgres server needs to be running.

Is there an easy way to achieve this? How does one go about testing such
packages to begin with?

-- 
Mateusz K.
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev