Following documentation such as this, I have the following systemd unit config:
# api.nix
{ ... }: {
systemd.services.foobar = {
enable = true;
description = "loreum ipsum";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
ExecStart = "/api";
Type = "simple";
Restart = "always";
User = "skainswo";
};
};
}
and it is being import
ed in configuration.nix
:
# configuration.nix
{...}: {
imports = [
...
./api.nix
];
...
}
However, when I run nixos-rebuild:
# This is the latest nixos-23.11 commit as of 2024-04-17. Check https://status.nixos.org for updates.
NIXPKGS_COMMIT=53a2c32bc66f5ae41a28d7a9a49d321172af621e
nix run github:NixOS/nixpkgs/$NIXPKGS_COMMIT#nixos-rebuild -- switch \
-I nixos-config="$(dirname "$0")"/../nixos/configuration.nix \
-I nixpkgs=https://github.com/NixOS/nixpkgs/archive/$NIXPKGS_COMMIT.tar.gz \
--target-host bitbop-proxy-arm
I get the following output:
these 4 derivations will be built:
/nix/store/6f70ls8fkhxrhc8kib3ha303ms69gpfc-unit-foobar.service.drv
/nix/store/5iixfnfkfmvjy396nxhwqs6xxf0pr0kr-system-units.drv
/nix/store/qy84c0z4ls1271s7zadc351kk4z415pj-etc.drv
/nix/store/96wq8z5z3vx8s82r1lsrapjljlxsgi07-nixos-system-bitbop-proxy-arm-23.11pre-git.drv
building '/nix/store/6f70ls8fkhxrhc8kib3ha303ms69gpfc-unit-foobar.service.drv'...
building '/nix/store/5iixfnfkfmvjy396nxhwqs6xxf0pr0kr-system-units.drv'...
building '/nix/store/qy84c0z4ls1271s7zadc351kk4z415pj-etc.drv'...
building '/nix/store/96wq8z5z3vx8s82r1lsrapjljlxsgi07-nixos-system-bitbop-proxy-arm-23.11pre-git.drv'...
copying 4 paths...
copying path '/nix/store/r2d6738y9wly2f4bq838f4msc33qdlgm-unit-foobar.service' to 'ssh://bitbop-proxy-arm'...
copying path '/nix/store/rzmfkln67s1nwrayc3ivgs7mkj5d4hxq-system-units' to 'ssh://bitbop-proxy-arm'...
copying path '/nix/store/znimh9xpqjayqcp3fsmwykzwlgprifwm-etc' to 'ssh://bitbop-proxy-arm'...
copying path '/nix/store/xl35byy41l4w44nn46kbxjg68mz2ls29-nixos-system-bitbop-proxy-arm-23.11pre-git' to 'ssh://bitbop-proxy-arm'...
updating GRUB 2 menu...
stopping the following units: dbus-broker.service, systemd-oomd.service, systemd-oomd.socket, systemd-sysctl.service, systemd-timesyncd.service, systemd-tmpfiles-resetup.service, systemd-udevd-control.socket, systemd-udevd-kernel.socket, systemd-udevd.service, systemd-vconsole-setup.service
root@b62e2017d34d:/workspaces/bitbop/cherami#
However, I do not see this unit being deployed or enabled on the remote host:
❯ ls /etc/systemd/system/ | grep foobar
❯ sudo systemctl list-units --all | grep foobar
❯
Am I missing something? Is there something wrong with my service configuration?