Conflicting definition values when using a module

Hey all,

I’ve moduleified a Python / FastAPI application. A problem arises when I want to actually use it in a configuration, then I get the following error:

       error: The option `' has conflicting definition values:
       - In `/nix/store/7q4y8idjk2di380j1fxn4k7wx9y935cl-source/nixos/modules/system/boot/systemd.nix': "/nix/store/jql7780b4x5z00g7zbmr1kx820jamhdc-unit-script-blitz-api-start/bin/blitz-api-start "
       - In `/nix/store/81hfyqr8x6myjpcvnfcdahcxqpl1qcp8-source/modules/blitz_api.nix': "/nix/store/sxk87kjjq88wnbqnlbcj4w3n2c60jahj-python3.11-blitz-api-0.5.1/bin/api --port 2121 --host"
       Use `lib.mkForce value` or `lib.mkDefault value` to change the priority on any of these definitions.

I dont know where the second ExecStart option suddenly comes from. The full log files don’t seem to contain any more info. Thank You!

Here’s a link to the module file:

The system config file
}: {
  imports = [

  # boot.isContainer = true;
  boot.loader.grub.enable = false;
  boot.loader.generic-extlinux-compatible.enable = true;

  nix.extraOptions = "experimental-features = nix-command flakes";

  networking.hostName = "tbnix"; # Define your hostname.
  time.timeZone = "Europe/Berlin";

  i18n.defaultLocale = "en_US.UTF-8";
  console = {
    font = "Lat2-Terminus16";
    useXkbConfig = true; # use xkb.options in tty.

  users.users.admin = {
    isNormalUser = true;
    extraGroups = ["wheel"]; # Enable ‘sudo’ for the user.
    packages = with pkgs; [];

  environment.systemPackages = with pkgs; [

  services = {
    blitz-api = {
      enable = true;

    openssh = {
      enable = true;

    redis.servers."".enable = true;

  networking.firewall.allowedTCPPorts = [22];

  system.stateVersion = "23.11"; # Did you read the comment?

This ExecStart is there because you specify serviceConfig.script here, which sets ExecStart here within Nixpkgs. I think you can’t have both ExecStart and script at the same time.

For the curious: I did not know this before answering. I found it by searching unit-script- within Nixpkgs, which led me to a function called makeJobScript. A subsequent search of the term makeJobScript brought up the actual place where the function is used.

1 Like

Thank you! This was the solution. I’ve moved the if statements in the script into the environment variables (as it should have been in the first place)!

1 Like