0

I'm trying to build my Nix configuration in GitLab CI, to make sure any changes have at least a chance of working in NixOS. The official Nix Docker image has a very different structure from NixOS (being based on Alpine), and I keep getting an error I've no idea how to resolve:

$ docker run --volume=$(pwd):/etc/nixos --interactive --rm --tty nixos/nix
5cc8dad8d887:/# nix-build /etc/nixos/configuration.nix
error: cannot auto-call a function that has an argument without a default value ('config')

Even the file generated by nixos-generate-config has the same problem:

$ cd "$(mktemp --directory)"
$ nixos-generate-config --root .
$ nix-build etc/nixos/configuration.nix
error: cannot auto-call a function that has an argument without a default value ('config')

The only other repo I've found to do something similar is much more complex than what I was hoping to do here.

1 Answer 1

1

Worked it out, finally:

build:
  stage: test
  image: nixos/nix
  before_script:
  - echo system-features = kvm | tee -a /etc/nix/nix.conf
  - echo {} | tee common.nix hardware-configuration.nix host.nix
  - nix-env --install --attr nixpkgs.nixos-rebuild nixpkgs.man
  script:
  - nix-build '<nixpkgs/nixos>' -I nixos-config=ci.nix
  cache:
  - key:
      files:
      - configuration.nix
    paths:
    - /nix/store

ci.nix overrides some things to be able to build:

{ lib, ... }: {
  imports = [ ./configuration.nix ];
  boot = lib.mkForce { };
  environment.systemPackages = lib.mkForce [ ];
}

Caveat: To avoid running out of disk space (or having to create and maintain my own runners) I've emptied environment.systemPackages in ci.yml.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .