Skip to content

Commit

Permalink
feat: add oci-containers module
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkolenz committed Dec 10, 2024
1 parent d1ee4a7 commit 2d899d8
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions modules/oci.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{ lib, ... }:
let
mkContainer =
attrs@{
labels ? { },
extraOptions ? [ ],
}:
{
labels = {
"io.containers.autoupdate" = "registry";
} // labels;
extraOptions = [
"--userns"
"auto"
"--pull"
"newer"
] ++ extraOptions;
}
// (lib.removeAttrs attrs [
"labels"
"extraOptions"
]);
in
{
systemd.tmpfiles.settings.oci-containers = {
"/var/lib/ollama-oci".d = {
user = "containers";
group = "containers";
};
"/var/lib/open-webui-oci".d = {
user = "containers";
group = "containers";
};
};
virtualisation.oci-containers = {
ollama = mkContainer {
image = "docker.io/ollama/ollama:latest";
volumes = [
"/var/lib/ollama-oci:/root/.ollama"
];
extraOptions = [
"--device"
"nvidia.com/gpu=4,5,6,7"
];
};
open-webui = mkContainer {
image = "ghcr.io/open-webui/open-webui:latest";
ports = [
"3000:8080"
];
volumes = [
"/var/lib/open-webui-oci:/app/backend/data"
];
extraOptions = [
"--add-host"
"host.docker.internal:host-gateway"
];
};
};
}

0 comments on commit 2d899d8

Please sign in to comment.