nixos/incus-agent: init

This commit is contained in:
Adam Stephens 2024-08-10 12:08:33 -04:00
parent 792028c425
commit 293c17926d
No known key found for this signature in database
3 changed files with 55 additions and 2 deletions

View File

@ -1679,6 +1679,7 @@
./virtualisation/ecs-agent.nix
./virtualisation/hyperv-guest.nix
./virtualisation/incus.nix
./virtualisation/incus-agent.nix
./virtualisation/kvmgt.nix
./virtualisation/libvirtd.nix
./virtualisation/lxc.nix

View File

@ -0,0 +1,41 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.virtualisation.incus.agent;
in
{
meta = {
maintainers = lib.teams.lxc.members;
};
options = {
virtualisation.incus.agent.enable = lib.mkEnableOption "Incus agent";
};
config = lib.mkIf cfg.enable {
services.udev.packages = [ config.virtualisation.incus.package.agent_loader ];
systemd.packages = [ config.virtualisation.incus.package.agent_loader ];
systemd.services.incus-agent = {
enable = true;
wantedBy = [ "multi-user.target" ];
path = [
pkgs.kmod
pkgs.util-linux
# allow `incus exec` to find system binaries
"/run/current-system/sw"
];
# avoid killing nixos-rebuild switch when executed through incus exec
restartIfChanged = false;
stopIfChanged = false;
};
};
}

View File

@ -13,10 +13,8 @@
buildGoModule,
fetchFromGitHub,
writeScript,
writeShellScript,
acl,
cowsql,
hwdata,
libcap,
lxc,
pkg-config,
@ -38,6 +36,11 @@ buildGoModule rec {
version
;
outputs = [
"out"
"agent_loader"
];
src = fetchFromGitHub {
owner = "lxc";
repo = "incus";
@ -99,6 +102,14 @@ buildGoModule rec {
--bash <($out/bin/incus completion bash) \
--fish <($out/bin/incus completion fish) \
--zsh <($out/bin/incus completion zsh)
mkdir -p $agent_loader/bin $agent_loader/etc/systemd/system $agent_loader/lib/udev/rules.d
cp internal/server/instance/drivers/agent-loader/incus-agent-setup $agent_loader/bin/
chmod +x $agent_loader/bin/incus-agent-setup
patchShebangs $agent_loader/bin/incus-agent-setup
cp internal/server/instance/drivers/agent-loader/systemd/incus-agent.service $agent_loader/etc/systemd/system/
cp internal/server/instance/drivers/agent-loader/systemd/incus-agent.rules $agent_loader/lib/udev/rules.d/99-incus-agent.rules
substituteInPlace $agent_loader/etc/systemd/system/incus-agent.service --replace-fail 'TARGET/systemd' "$agent_loader/bin"
'';
passthru = {