Skip to content

Instantly share code, notes, and snippets.

@gilligan
Created July 6, 2017 14:28
Show Gist options
  • Save gilligan/bed28a6dca9ed6a2758553799f0ea67c to your computer and use it in GitHub Desktop.
Save gilligan/bed28a6dca9ed6a2758553799f0ea67c to your computer and use it in GitHub Desktop.
{
network.description = "hc-web continuous integration server";
jenkinsMaster =
{ config, pkgs, ... }:
{
# server config ...
};
}
import <nixpkgs/nixos/tests/make-test.nix> ({ pkgs, ... }: {
name = "boot";
machine = (import server.nix).jenkinsMaster;
testScript = ''
$machine->start;
# ... lotsa tests ...
'';
}
@gilligan
Copy link
Author

gilligan commented Jul 6, 2017

So test requires some more memory otherwise jenkins explodes.

I cannot add virtualisation.memorySize to the server.nix because nixops will choke on that since it's only valid for the tests..

building all machine configurations... 
error: The option `virtualisation.memorySize' defined in `/home/gilligan/Development/hc-web-ci-server/infrastructure/hc-web-ci-server.nix' does not exist.     
(use ‘--show-trace’ to show detailed location information)                     
error: unable to build all machine configurations               

How can I add the virtualisation attribute in test.nix ? The only thing I could think of now is to move the attribute set that the jenkinsMaster function returns to a separate .nix file and then just do something like ...

{
  machine = { config, pkgs, ... }: import config.nix // { virtualisation.memorySize = 4096; };
}

Actually just thought of that while typing this up. Is this what you would do? I am thinking there is a different way ...

@Profpatsch
Copy link

Profpatsch commented Jul 6, 2017

To be honest, I don’t know how nixops evaluates the module configs you hand it, e.g. in the example from the manual:

$ nixops create ./trivial.nix ./trivial-vbox.nix -d trivial

There are two attribute sets of modules given, only one of them contains nixops-specific options (stuff from https://nixos.org/nixops/manual/#ch-options). I’d think nixops might do something like merge every attribute with the same name in all files you give it on the command line, as follows:

listOfAttributeModules:
import <nixpkgs/nixos> { 
  configuration = {
    imports = [ nixopsOptionDeclarations ] ++ listOfAttributeModules;
  };
}

The part where all nixops-specific options are imported is important.
That’s just my guess, to be sure you’d have to look at the nixops source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment