diff --git a/modules/nixos-modules/default.nix b/modules/nixos-modules/default.nix index 63b2757..371a156 100644 --- a/modules/nixos-modules/default.nix +++ b/modules/nixos-modules/default.nix @@ -11,6 +11,7 @@ ./sync.nix ./impermanence.nix ./disko.nix + ./ollama.nix ./server ]; diff --git a/modules/nixos-modules/ollama.nix b/modules/nixos-modules/ollama.nix new file mode 100644 index 0000000..5cdc041 --- /dev/null +++ b/modules/nixos-modules/ollama.nix @@ -0,0 +1,27 @@ +{ + config, + lib, + ... +}: { + config = lib.mkMerge [ + { + services.ollama = { + group = "ollama"; + user = "ollama"; + }; + } + (lib.mkIf config.host.impermanence.enable (lib.mkIf config.services.ollama.enable { + environment.persistence."/persist/system/root" = { + enable = true; + hideMounts = true; + directories = [ + { + directory = config.services.ollama.models; + user = config.services.ollama.user; + group = config.services.ollama.group; + } + ]; + }; + })) + ]; +} diff --git a/modules/nixos-modules/users.nix b/modules/nixos-modules/users.nix index 5cfa7fb..15631a9 100644 --- a/modules/nixos-modules/users.nix +++ b/modules/nixos-modules/users.nix @@ -22,6 +22,7 @@ headscale = 2005; nextcloud = 2006; syncthing = 2007; + ollama = 2008; }; gids = { @@ -36,6 +37,7 @@ headscale = 2005; nextcloud = 2006; syncthing = 2007; + ollama = 2008; }; users = config.users.users; @@ -150,6 +152,12 @@ in { isSystemUser = true; group = config.users.users.syncthing.name; }; + + ollama = { + uid = lib.mkForce uids.ollama; + isSystemUser = true; + group = config.users.users.ollama.name; + }; }; groups = { @@ -240,6 +248,13 @@ in { eve ]; }; + + ollama = { + gid = lib.mkForce gids.ollama; + members = [ + users.ollama.name + ]; + }; }; }; }