I’ve copied a function declaration from this issue comment, but I can’t get it to run without errors.
It returns this when doing a nixos-rebuild switch
:
error: undefined variable 'mkJob' at /etc/nixos/configuration.nix:84:22
(use '--show-trace' to show detailed location information)
building Nix...
error: undefined variable 'mkJob' at /etc/nixos/configuration.nix:84:22
(use '--show-trace' to show detailed location information)
building the system configuration...
error: undefined variable 'mkJob' at /etc/nixos/configuration.nix:84:22
(use '--show-trace' to show detailed location information)
The relevant code I have in configuration.nix
is the following, where “user” is a valid user:
mkJob = user: {
"syncthing-${user}" = {
description = "Syncthing service for user ${user}";
after = [ "network.target" ];
environment = { STNOUPGRADE = "yes"; };
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Restart = "on-failure";
SuccessExitStatus = "2 3 4";
RestartForceExitStatus="3 4";
User = user;
Group = "users";
PermissionsStartOnly = true;
ExecStart = "${config.services.syncthing.package}/bin/syncthing -no-restart -no-browser -home=/var/lib/syncthing/${user}";
};
};
};
systemd.services = mkJob "user";
I don’t understand how it’s undefined. Is it failing to recognize it as a function?