Personal Nix setup

Add ollama daemon

Changed files
+44
home
lib
+1
home/default.nix
···
./zsh.nix
./tmux.nix
./rbw.nix
+
./ollama.nix
./wezterm
./npm
./gpg
+41
home/ollama.nix
···
+
{ helpers, lib, pkgs, ... }:
+
+
let
+
ollamaArgs = [
+
"${pkgs.ollama}/bin/ollama"
+
"serve"
+
];
+
in {
+
config = lib.mkMerge [
+
{ home.packages = [ pkgs.ollama ]; }
+
+
(helpers.mkIfLinux {
+
systemd.user.services.ollama = {
+
Unit = {
+
Description = "Ollama";
+
Documentation = "https://github.com/jmorganca/ollama";
+
};
+
Install.WantedBy = [ "default.target" ];
+
Service = {
+
ExecStart = lib.escapeShellArgs ollamaArgs;
+
Restart = "on-failure";
+
RestartSec = 5;
+
};
+
};
+
})
+
+
(helpers.mkIfDarwin {
+
launchd.agents.ollama = {
+
enable = true;
+
config = {
+
ProcessType = "Background";
+
ProgramArguments = ollamaArgs;
+
KeepAlive = {
+
Crashed = true;
+
SuccessfulExit = false;
+
};
+
};
+
};
+
})
+
];
+
}
+2
lib/helpers.nix
···
inherit isLinux isDarwin;
linuxAttrs = lib.attrsets.optionalAttrs isLinux;
darwinAttrs = lib.attrsets.optionalAttrs isDarwin;
+
mkIfLinux = lib.mkIf isLinux;
+
mkIfDarwin = lib.mkIf isDarwin;
}