Skip to content

Commit

Permalink
feat: add incus
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgon committed Nov 3, 2024
1 parent e7a3c16 commit ef1fd64
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 3 deletions.
17 changes: 17 additions & 0 deletions machines/deedee/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,23 @@ rec {
rootless = false;
};

incus = {
enable = true;
enableUI = true;
initializeBaseNixOSVM = true;
defaultStoragePool = {
config = {
source = "tank/vms";
};
driver = "zfs";
};
defaultNIC = {
nictype = "bridged";
parent = "br0";
type = "nic";
};
};

letsencrypt = {
enable = true;
useProduction = true;
Expand Down
7 changes: 5 additions & 2 deletions machines/deedee/secrets.sops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ system:
DB_PASSWORD: ENC[AES256_GCM,data:mbC7eRSCB99A5VkhCK7BL4oQh5T8k+wbQZPcsReKtHjQtO/4PIanww==,iv:Bhp2whhp7MWBgPwbVWG/79S/ZA7UOCtwNFYhqTbfImQ=,tag:nNoNloIEe6lUKt7Fh2aUPA==,type:str]
OIDC_SECRET_ENCRYPTED: ENC[AES256_GCM,data:HNwOGx5f6g7NTFi7Xk7lRWFpPgqH+2sAZXE4wGPsTdOXZtl/EsQFFP6x5kG/L0UvC+WcpmqP9M2RrN70pvNfpR5DZtAx91owYYgnhQ9jBvNgCb0cgyEf9IO0n5YWZ5dGlYN7DrwXYPZ5UAbNl4QGMoYq93BSUo6Ob9KYw6r+PJKvmK8=,iv:AiMZO4itdkNCdUlJ2JfruYwzi1viA3xYbmDnC/vcD9c=,tag:pK3UsufBQ3rKUhaMdAM0AA==,type:str]
OIDC_SECRET_RAW: ENC[AES256_GCM,data:JMA2jwiSTCtP0bJzXiPawWLfkKtLJMDDIcwJbTBhzKlxiL8YE0NwXz098CRwd2o3sUxoyZa6CrygTUuq3GDUopwHVX7ZsQn2,iv:iU06dfr+g9mK3ZwwvZqkn1NxjbtErG/UQnefTTqJ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bjJubzlBckdDb2lNOUZtOGMKRbHxa1B3QAdredBMTd7W7g3kRz6l8uyV
bBclsA8Gm7p+6ndV39sN+Daqm5MyggY1Prwv/Ukdd5Q+1C+XsEW6OQ==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2024-11-02T14:27:10Z"
mac: ENC[AES256_GCM,data:Yc/OB/IBUxCRLQYCckjmSrpLHBeHw+r8ZZ5BfzPwyg9Khrk2cdWSoTOcssYQjJpwdyelnTLFPXujmJRzOoqf6PteoL7d6yn6YxyzVEvYKo5UPNaTb5fjnAH4TszxXXderjhZUw8D70ogMIHHNqD+OlEpM5JVj1ZK57acaH3rhbw=,iv:jhre5EViny+uaqP5xpwWIOnDiVl0YUgJtFzTRH3Ekys=,tag:Uy4fG2oNXiqg9KE+qB60FA==,type:str]
lastmodified: "2024-11-03T19:20:18Z"
mac: ENC[AES256_GCM,data:1nM8NWF8vD9J+1zuGxp3LRO1uZh8fPVPegogrYrWobHNv7i0VwT7suCTFBnkRmkPwIVRC63inEiFCSO/Ojz/QvDfSGr2P8w8SAdWs+xe9hMnuuFDPuGi9Hq0eV8O0YiuOxkmRgmexZqYp+SUPvtPQ4ztvYFcTi7tZNKlaJkHseU=,iv:fuAdNDFW2aZFlsV8ctMbxc3waeAaHnPdNK0wOGZmtYc=,tag:lhLSPHqzaiqin97k7o4JKw==,type:str]
pgp: []
unencrypted_suffix: _unencrypted
version: 3.8.1
1 change: 1 addition & 0 deletions modules/system/apps/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ _: {

./adguardhome
./docker
./incus
./letsencrypt
./nginx
./openconnect
Expand Down
170 changes: 170 additions & 0 deletions modules/system/apps/incus/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
{
config,
lib,
svc,
...
}:
let
cfg = config.mySystemApps.incus;
in
{
options.mySystemApps.incus = {
enable = lib.mkEnableOption "incus app";
dataDir = lib.mkOption {
type = lib.types.str;
description = "Path to directory containing data.";
default = "/var/lib/incus";
};
defaultStoragePool = lib.mkOption {
type = lib.types.attrs;
description = "Default storage pool configuration for incus.";
default = {
config = {
source = "${cfg.dataDir}/disks/default.img";
size = "500GiB";
};
driver = "btrfs";
name = "default";
};
};
defaultNIC = lib.mkOption {
type = lib.types.attrs;
description = "Default NIC for the VM.";
default = {
network = "incusbr0";
type = "nic";
};
example = {
nictype = "bridged";
parent = "br0";
type = "nic";
vlan = 100;
};
};
enableUI = lib.mkOption {
type = lib.types.bool;
description = "Enable incus UI";
default = false;
};
incusUICrtSopsSecret = lib.mkOption {
type = lib.types.str;
description = ''
Sops secret name containing Incus UI certificate.
Don't use incus UI to generate it, as it generates faulty certificates, not accepted by nginx.
Instead do:
openssl req -newkey rsa:4096 -nodes -keyout incus-ui.key -x509 -days 36500 -out incus-ui.crt
'';
default = "system/apps/incus/incus-ui.crt";
};
incusUIKeySopsSecret = lib.mkOption {
type = lib.types.str;
description = ''
Sops secret name containing Incus UI certificate.
Don't use incus UI to generate it, as it generates faulty certificates, not accepted by nginx.
Instead do:
openssl req -newkey rsa:4096 -nodes -keyout incus-ui.key -x509 -days 36500 -out incus-ui.crt
'';
default = "system/apps/incus/incus-ui.key";
};
initializeBaseNixOSVM = lib.mkOption {
type = lib.types.bool;
description = "If set to true, it will install base image, compatible with nixos-anywhere.";
default = false;
};
};

config = lib.mkIf cfg.enable {
assertions = [
{
assertion = (!cfg.enableUI) || config.mySystemApps.authelia.enable;
message = "To use incus UI, authelia container needs to be enabled.";
}
];

sops.secrets = {
"${cfg.incusUICrtSopsSecret}" = {
owner = "nginx";
group = "nginx";
restartUnits = [ "nginx.service" ];
};
"${cfg.incusUIKeySopsSecret}" = {
owner = "nginx";
group = "nginx";
restartUnits = [ "nginx.service" ];
};
};

virtualisation.incus = {
enable = true;
ui.enable = cfg.enableUI;

preseed = {
profiles = [
{
name = "default";
description = "Default profile";
devices = {
eth0 = lib.recursiveUpdate cfg.defaultNIC { name = "eth0"; };
root = {
path = "/";
pool = "default";
size = "200GiB";
type = "disk";
};
};
config = {
"boot.autostart" = false;
"limits.cpu" = 4;
"limits.memory" = "8GiB";
"security.secureboot" = false;
"snapshots.schedule" = "@hourly";
};
}
];
storage_pools = [ (lib.recursiveUpdate cfg.defaultStoragePool { name = "default"; }) ];
};
};

users.users."${config.mySystem.primaryUser}".extraGroups = [ "incus-admin" ];
networking.firewall.trustedInterfaces =
lib.optionals (builtins.hasAttr "network" cfg.defaultNIC) [ cfg.defaultNIC.network ]
++ lib.optionals (builtins.hasAttr "parent" cfg.defaultNIC) [ cfg.defaultNIC.parent ];

environment.persistence."${config.mySystem.impermanence.persistPath}" =
lib.mkIf config.mySystem.impermanence.enable
{ directories = [ cfg.dataDir ]; };

systemd.services.incus.postStart = lib.mkAfter (
(lib.optionalString cfg.enableUI ''
${lib.getExe config.virtualisation.incus.package} config set core.https_address 127.0.0.1:8443
${lib.getExe config.virtualisation.incus.package} config trust add-certificate ${
config.sops.secrets."${cfg.incusUICrtSopsSecret}".path
} || true
'')
+ (lib.optionalString cfg.initializeBaseNixOSVM ''
if ! incus image show nixos/base/vm; then
nix run github:deedee-ops/nixlab#build-base-vm
fi
'')
);

services.nginx.virtualHosts.incus = lib.mkIf cfg.enableUI (
svc.mkNginxVHost {
host = "incus";
proxyPass = "https://127.0.0.1:8443";
extraConfig = ''
proxy_ssl_certificate ${config.sops.secrets."${cfg.incusUICrtSopsSecret}".path};
proxy_ssl_certificate_key ${config.sops.secrets."${cfg.incusUIKeySopsSecret}".path};
'';
}
);

mySystemApps.homepage = lib.mkIf cfg.enableUI {
services.Apps.Incus = svc.mkHomepage "incus" // {
icon = "proxmox.svg"; # @todo
container = null;
description = "Virtual machines manager";
};
};
};
}
4 changes: 3 additions & 1 deletion modules/system/lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
useAuthelia ? true,
autheliaIgnorePaths ? [ ],
customCSP ? null,
extraConfig ? "",
}:
let
# proxy_pass needs to be passed as variable, otherwise resolver won't work as expected
Expand All @@ -40,7 +41,8 @@
more_set_headers "Content-Security-Policy: ${
lib.trim (builtins.replaceStrings [ "\n" ] [ " " ] customCSP)
}";
'');
'')
+ extraConfig;
in
{
extraConfig =
Expand Down

0 comments on commit ef1fd64

Please sign in to comment.