New to NixOs, trouble with NixOps

Hello, I’m very new to NixOs and desperately trying to get a Github repository running. It is a project called THERMOS, a software for modelling distributed heating networks. It was funded by an EU project and is now open source.

What I’m trying is to get a THERMOS server running on my local machine. The project require a PostGreSQL server and PostGIS. There is a nix expression 110-thermos-ui/dev/pg-server.nix at 99465d7606862d64b9b86a63505954060ba2762c · cse-bristol/110-thermos-ui · GitHub which should install both, SQL server and PostGIS. Further the project requires Clojure.

While I’m usually working with Ubuntu, I thougt NixOs would be the better option for this time. So, I installed NixOS 23.11 and the nix packages for OpendJDK and nixos_unstable.

In the source code of this expression mentioned above I found a line
nixops create -d pg-server pg-server.nix

I tried to run this, but I get just some error messages like pg-server was an unknown argument.

I would be very grateful for any advice or support.

sure, let’s take some time to work through your challenges

you said you want to install this on your local machine - does that mean you have NixOS installed on your local machine? or do you want to run this in some sort of container on your local machine?

please clarify what OS you are running on your local machine already, specifically what OS you want to be running on your local machine, and whether your goal was to be using containers or not



Hi, thanks for your reply! I’ve installed NixOS 23.11 on a new partition. As I wrote, I use to work with Ubuntu 22.04 LTS.

Using containers (Docker) would be a nice option, but this would require deeper knowledge about NixOS and containers. A dedicated NixOS partition would be the easier way, I thougt.


in that case let’s forget NixOps and just work with your current NixOS install

you will want to add the following configuration to your configuration.nix:

{ pkgs, config, ...}:
    pg = pkgs.postgresql;
  pgis = pkgs.postgis.override { postgresql = pg; };
  create-database = builtins.toFile "create-database.sql"
    CREATE ROLE postgres LOGIN;
    GRANT root TO postgres;
    ALTER USER postgres WITH PASSWORD 'therm0s';
    CREATE DATABASE thermos;
  enable-postgis = builtins.toFile "enable-postgis.sql"
    "CREATE EXTENSION postgis;";
    environment.systemPackages = [pkgs.rxvt_unicode.terminfo];

    networking.firewall.allowedTCPPorts = [ 22 5432 ];

    services.postgresql = {
      enable = true;
      package = pg;
      extraPlugins = [ pgis ];
      enableTCPIP = true;

      authentication = ''
        local all all trust
        host all all all trust

      initialScript = create-database;
    }; = {
      path = [pg];
      wantedBy = [""];
      after = ["postgresql.service"];
      requires = ["postgresql.service"];
      script = ''
        [[ -f /var/lib/enabled-postgis ]] ||
        ( psql -U root -d thermos -a -f "${enable-postgis}" &&
          touch /var/lib/enabled-postgis )

if you add that and rebuild your system you should have what you want running locally

let us know how it goes

1 Like

Hi Aaron, thanks again! I spent yesterday evening with NixOS. I modified configuration.nix according to your post, but it didn’t work.

In the first line of that expression, they mention Virtualbox

# nixops configuration for a postgresql server, deployed into virtualbox

So I installed a VB and loaded the current NixOS iso file. This was pretty easy! Then I opened a nix-shell, pulled the project from Git, pulled Clojure and OpenJDK und ran the Clojure script

clojure -Adev:server:client jar

…but I didn’t succeed. The compilation ran for a few minutes and got stuck every time.

I’m an absolute NixOS noob. Nixos is a different world. Today I learned how to install GIT permanently (net-env -iA nixos.git) :muscle: and installed OpenJDK and Clojure in the same way. Then I called the clojure script - and it got stuck again…

can you please provide very specific details on how this didn’t work?

i think we should try to simplify your life and avoid NixOps and VirtualBox for now - given that you have recently started with nix i think these additional technologies aren’t worth it for you yet

since you’re working with java inside a virtual machine i will make the assumption that your vm ran out of resources and i will continue to suggest we avoid VirtualBox as well as NixOps for now

don’t worry, we’ll get you sorted :muscle: let’s focus on your issues with your nixos configuration as mentioned above and go from there


Hi Aaron, yes, you’re right! Let’s try without NixOps and vm. I installed NixOS again, means I have a clean system, plus GIT, OpenJDK and Clojure. Pulled the project from GIT and started to build.

clojure -Adev:server:client dev

The build stopped at the same postion where it had stopped before when running under Ubuntu or on the NixOS-VM. The protocol is huge. If you don’t mind… I will share it on mit GDrive.

i ran through the same steps as you and got the same results

looks like you already created an issue upstream which is good… i would suggest that upstream should provide some advice for us at this point

let’s wait and see what they have to say and then we can continue here if needed

1 Like

Hi! I was looking through this randomly and was wondering if you tried changing the pg-host variable? I suspect that IP is a hard-code value for the virtual machine’s network interface. Since you’re not running it through virtualbox it should probably be localhost (

1 Like

desperately trying to get a Github repository running.

Honestly, as much as I love all things Nix, I’d just use Docker to run postgres for a local dev environment like that. Unless you just want to sink some time into learning Nix and NixOS.

It might be as simple as (see:

docker run --rm --name thermos-db \
  -e POSTGRES_DB=thermos \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=therm0s \
  -p 5432:5432 \
1 Like

Thanks for this hint! You can run Thermos online as SaaS.

I suppose, is the address of SQL server. And I guess, if you build the project with

clojure -Adev:server:client jar

it will use the online SQL server.

But: I changed the address to - and the build stopped at the same position as before.