How to directly integrate nixcloud-webservices (without explicit install)

I want to install nixcloud-webservices (as a nixnoob), but on nixcloud-webservices the most logical declarative way of installing (namely directly pulling the git repo from within the config) is not documented, and I’m having a bit of a struggle.

The upstream recommended installation method:

$ git clone https://github.com/nixcloud/nixcloud-webservices

(imperative) and then

{
  imports = [
    ./hardware-configuration.nix
    /path/to/nixcloud-webservices
  ];
  # ... other options ...
}

So I thought to translate this to

{ config, pkgs, ... }:
  let
    ncws = (import <nixpkgs> {}).fetchFromGitHub {
          owner = "nixcloud";
          repo = "nixcloud-webservices";
          rev = "7e421fed1cb6dc460468d5917bb93b559606c7b6";
          sha256 = "sha256:0y3kpajq10ixh5xnijfsq2aqpf9f7yij5bxl7ynh3n9dj44ksflb";
    };
  in {
    imports = [ "${ncws}" {} ];

    nixcloud.reverse-proxy = {
      enable = true;
      extendEtcHosts = true;
    };
}

which doesn’t work:

# nixos-rebuild switch
building Nix...
building the system configuration...
error: getting status of '/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/lib/testing.nix': No such
file or directory

Or another try:

  nixpkgs.config.packageOverrides = pkgs: {
    nixcloud = import (builtins.fetchFromGitHub {
          owner = "nixcloud";
          repo = "nixcloud-webservices";
          rev = "7e421fed1cb6dc460468d5917bb93b559606c7b6";
          sha256 = "sha256:0y3kpajq10ixh5xnijfsq2aqpf9f7yij5bxl7ynh3n9dj44ksflb";
    }) { inherit pkgs; };
  };

  nixcloud.reverse-proxy = {
    enable = true;
    extendEtcHosts = true;
  };

which also doesn’t work. (error: undefined variable 'nixcloud')

What am I doing wrong?

1 Like

Ok, I figured out that probably the first one would have worked with

nixcloud.tests.enable = false;

but that a much more compact form to achieve the same is:

{
  imports = [ "${fetchGit https://github.com/nixcloud/nixcloud-webservices}/modules/" ];
  nixcloud.tests.enable = false;

  nixcloud.reverse-proxy = {
    enable = true;
    extendEtcHosts = true;
  };
}

(I happened to find it in this example)

1 Like