Refactor bash a bit.

This commit is contained in:
Dmitry Voronin 2024-10-14 00:59:15 +03:00
parent 00b2b7320e
commit 5dab0401f2
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
34 changed files with 24 additions and 752 deletions

1
.gitignore vendored
View file

@ -1,2 +1 @@
/live
.NixRoot*

View file

@ -30,7 +30,7 @@ fix-ulimit:
# HACK: They broke switching in systemd service ffs.
# https://github.com/NixOS/nixpkgs/issues/347315
fix-unlock:
pkill nixos-rebuild
pkill nixos-rebuild || true
format:
treefmt --no-cache --on-unmatched=info

View file

@ -1,9 +1,9 @@
{ pkgs, lib, ... }:
with lib;
let
url = "https://i.imgur.com/iDuNPOQ.jpeg";
sha256 = "1hyzc53jkmjkhabbzx4nxzg5bqrk2524dl167fs5aw58r8q6fr75";
forceContrastText = true;
url = "https://i.imgur.com/7PoLqMb.jpeg";
sha256 = "1vwhgdxsfn33pcyw06b2f5xikz6iwp4h54lr8515fqnnzbl06vjm";
forceContrastText = false;
in
{
options = {

View file

@ -609,22 +609,6 @@
"type": "github"
}
},
"nvimOllama": {
"flake": false,
"locked": {
"lastModified": 1717906114,
"narHash": "sha256-8tW5tp2GiYw+PnR7rqiKfykLW/yqvGOtqauZCgEeQCg=",
"owner": "nomnivore",
"repo": "ollama.nvim",
"rev": "45e58779fecde7ac5b8f62800bbe7180d4b48507",
"type": "github"
},
"original": {
"owner": "nomnivore",
"repo": "ollama.nvim",
"type": "github"
}
},
"nvimPlenary": {
"flake": false,
"locked": {
@ -762,7 +746,6 @@
"nvimGruvboxMaterial": "nvimGruvboxMaterial",
"nvimIndentoMatic": "nvimIndentoMatic",
"nvimLspconfig": "nvimLspconfig",
"nvimOllama": "nvimOllama",
"nvimPlenary": "nvimPlenary",
"nvimTelescope": "nvimTelescope",
"nvimTodo": "nvimTodo",

View file

@ -82,10 +82,6 @@
url = "github:neovim/nvim-lspconfig";
flake = false;
};
nvimOllama = {
url = "github:nomnivore/ollama.nvim";
flake = false;
};
nvimPlenary = {
url = "github:nvim-lua/plenary.nvim";
flake = false;

View file

@ -35,7 +35,6 @@ in
"${inputs.nvimGruvboxMaterial}"
"${inputs.nvimIndentoMatic}"
"${inputs.nvimLspconfig}"
"${inputs.nvimOllama}"
"${inputs.nvimPlenary}"
"${inputs.nvimTelescope}"
"${inputs.nvimTodo}"
@ -65,7 +64,6 @@ in
./module/plugin/Align.nix
./module/plugin/Treesitter.nix
./module/plugin/Fold.nix
./module/plugin/Ollama.nix
./module/plugin/Colorizer.nix
./module/plugin/lsp/Haskell.nix
./module/plugin/lsp/Rust.nix
@ -79,7 +77,6 @@ in
./module/key/Filetree.nix
./module/key/Gitsigns.nix
./module/key/Navigation.nix
./module/key/Ollama.nix
./module/key/Save.nix
./module/key/Sort.nix
./module/key/TabWidth.nix

View file

@ -1,7 +0,0 @@
{ ... }:
{
text = ''
rekey_normal("<Leader>p", ":<c-u>lua require('ollama').prompt()<cr>")
rekey_visual("<Leader>p", ":<c-u>lua require('ollama').prompt()<cr>")
'';
}

View file

@ -8,7 +8,7 @@
]])
vim.o.background = "dark"
vim.g.gruvbox_material_background = "hard"
vim.g.gruvbox_material_background = "medium"
vim.g.gruvbox_material_foreground = "original"
vim.g.gruvbox_material_transparent_background = 2
-- vim.g.gruvbox_material_better_performance = 1 -- NOTE: Broken on NixOS.

View file

@ -1,18 +0,0 @@
{ config, ... }:
{
text = ''
require("ollama").setup {
model = "${config.setting.ollama.primaryModel}",
url = "http://127.0.0.1:11434",
-- View the actual default prompts in ./lua/ollama/prompts.lua
prompts = {
-- Sample_Prompt = {
-- prompt = "This is a sample prompt that receives $input and $sel(ection), among others.",
-- input_label = "> ",
-- model = "mistral",
-- action = "display",
-- }
}
}
'';
}

View file

@ -1,18 +1,9 @@
{ config, ... }:
let
fontName = config.style.font.serif.name;
fontSize = toString config.style.font.size.desktop;
accent = config.style.color.accent;
bg = config.style.color.bg.dark;
fg = config.style.color.fg.light;
in
{ ... }:
{
text = ''
# Application launcher.
# Note: pass the final command to swaymsg so that the resulting window can be opened
# on the original workspace that the command was run on.
# set $menu _dmenu_path_wrapped | wmenu -b -p 'Run:' -i -f "${fontName} ${fontSize}" -M ${bg}D9 -S ${bg}D9 -N ${bg}D9 -m ${accent} -s ${accent} -n ${fg} | xargs swaymsg exec --
set $menu fuzzel
bindsym $mod+space exec $menu

View file

@ -1,21 +0,0 @@
{ ... }:
{
text = ''
# Start an Android emulator.
# Default name is `main`.
# Usage: emulator [NAME]
function emulator() {
local name="$1"
[[ "$name" = "" ]] && name="main"
steam-run ~/.android/sdk/emulator/emulator -avd "$name" &> /dev/null & disown
}
function _android_emulators() {
_autocomplete_first $(ls --classify ~/.android/avd/ | grep \/$ | sed -e "s/.avd\/$//")
}
complete -F _android_emulators emulator
'';
}

View file

@ -1,27 +0,0 @@
{ ... }:
{
text = ''
# Ask general AI.
# Usage: ask <QUERY>
function ask() {
curl http://localhost:11434/api/generate -d "{
\"model\": \"''${OLLAMA_MODEL}\",
\"prompt\":\"''${*}\"
}" 2> /dev/null | parallel -j1 -- "echo {} | jq -r .response | tr -d '\n'"
echo
}
# Specify ask model.
function ask_model() {
export OLLAMA_MODEL="''${1}"
}
function _complete_ask_model() {
local IFS=$'\n'
local models=($(ollama list | sed -e "1d" | cut -f1))
_autocomplete_first ''${models[@]}
}
complete -F _complete_ask_model ask_model
'';
}

View file

@ -1,9 +0,0 @@
{ ... }:
{
text = ''
# Launch calculator app.
function calc() {
gnome-calculator
}
'';
}

View file

@ -1,88 +0,0 @@
{ ... }:
{
text = ''
# Save file checksums.
# For file with a name `file` it will create a new file called `.file.sha1` with hash in it.
# All files by default.
# Usage: checksum_create [FILES]
function checksum_create() {
local IFS=$'\n'
local targets=(''${@})
[[ "''${targets}" = "" ]] && targets=($(_ls_file))
process() {
local hashfile=".''${target#./}.sha1"
# Skip if hash exists.
[[ -f "''${hashfile}" ]] && return 0
# Calculate hash.
pv ''${target} | sha1sum > ''${hashfile}
}
_iterate_targets process ''${targets[@]}
}
# Check stored values against actual files.
# All files by default.
# Usage: checksum_check [FILES]
function checksum_check() {
local IFS=$'\n'
local targets=(''${@})
[[ "''${targets}" = "" ]] && targets=($(_ls_file))
process() {
local hashfile=".''${target#./}.sha1"
# Skip if hash doesn't exist.
[[ -f "''${hashfile}" ]] || { _iterate_skip "No hash found."; return 0; }
# Calculate hash.
local stored=$(cat "''${hashfile}" | cut -d\ -f1)
local actual=$(pv "''${target}" | sha1sum | cut -d\ -f1)
if [[ "''${stored}" != "''${actual}" ]]; then
_error "Failed."
return 1
fi
}
_iterate_targets process ''${targets[@]}
}
# Calculate hashes for all files recursively and store in a file called `checksum.sha1`.
function checksum() {
find -type f | parallel -j $(_core_count) -- sha1sum {} >> checksum.sha1
}
# Create checksum for a file.
# Usage: _checksum_create <FILE>
function _checksum_create() {
local path="''${1%/*}"
local name="''${1##*/}"
sha1sum "''${path}/''${name}" > "''${path}/.''${name}.sha1"
}
# Check checksum for a file.
# Usage: _checksum_check <FILE>
function _checksum_check() {
local file="''${1##*\ \ }"
local stored="''${1%%\ \ *}"
# Skip if no file.
[[ -f "''${file}" ]] || return 0
# Check file hash.
local actual=$(sha1sum "''${file}")
actual="''${actual%%\ \ *}"
# Compare values.
if [[ "''${stored}" != "''${actual}" ]]; then
_error "''${file}: Failed."
return 1
fi
return 0
}
'';
}

View file

@ -1,10 +0,0 @@
{ ... }:
{
text = ''
# Add executable flag to file.
# Usage: x <FILES>
function x() {
chmod +x -- "''${@}"
}
'';
}

View file

@ -1,85 +0,0 @@
{ ... }:
{
text = ''
# Attach/create container box in current directory with specified name.
# By default uses current dir name.
# Usage: ca [NAME]
function ca() {
local name="''${1}"
# Set default name.
# [[ "''${name}" = "" ]] && name="main"
[[ "''${name}" = "" ]] && name=$(parse_alnum "''${PWD##*/}")
# Append box prefix.
name="box-''${name}"
# Create container.
docker run \
--privileged \
-d -it \
-h "''${HOSTNAME}''${name#box}" --name "''${name}" \
--workdir /data \
-e XDG_RUNTIME_DIR=/tmp \
-e WAYLAND_DISPLAY=''${WAYLAND_DISPLAY} \
-v ''${XDG_RUNTIME_DIR}/''${WAYLAND_DISPLAY}:/tmp/''${WAYLAND_DISPLAY} \
-v ''${PWD}:/data \
-v ''${HOME}:/root \
debian:latest bash -c bash &> /dev/null
# Attempt to start container.
docker start "''${name}" &> /dev/null
# Attach to running container.
docker attach "''${name}"
}
# Remove container box with specified name.
# By default uses current dir name.
# Usage: ck [NAME]
function ck() {
local name="''${1}"
# Set default name.
[[ "''${name}" = "" ]] && name=$(parse_alnum "''${PWD##*/}")
# Append box prefix.
name="box-''${name}"
# Kill container.
docker kill "''${name}" &> /dev/null
docker rm "''${name}" &> /dev/null
}
# Remove all container boxes.
function cka() {
local IFS=$'\n'
local boxes=$(_get_boxes)
for box in ''${boxes[@]}; do
ck "''${box}"
done
}
# List all container boxes.
function cl() {
_get_boxes
}
# Print all boxes.
function _get_boxes() {
local IFS=$'\n'
local boxes=$(docker ps -a | grep "box-" | sed -e "s/.*box-//")
[[ "''${boxes[@]}" != "" ]] && echo "''${boxes[@]}" || true
}
# Autocomplete with boxes.
function _comp_get_boxes() {
local IFS=$'\n'
_autocomplete_first $(_get_boxes)
}
complete -F _comp_get_boxes ca ck
'';
}

View file

@ -1,21 +0,0 @@
{ ... }:
{
text = ''
export _gdconf_path="''${HOME}/.config/linux/Gnome.dconf"
# Load Gnome settings.
function dconf_load() {
sed -i -e s/voronind/$(whoami)/g ''${_gdconf_path} ; dconf load / < ''${_gdconf_path}
}
# Dump Gnome settings into the file.
# Default name is `gnome.dconf`.
# Do this before changing settings and after, an then run `diff` to find out what to add to the main `gnome.dconf`.
# Usage: dconf_save [FILE]
function dconf_save() {
local name="''${1}"
[[ "''${name}" = "" ]] && name="gnome.dconf"
dconf dump / > "''${name}"
}
'';
}

View file

@ -1,20 +0,0 @@
{ ... }:
{
text = ''
# Create/Attach to the box.
# Uses name `main` by default.
# Usage: da [BOX]
function da() {
local name="''${1}"
[[ "''${name}" = "" ]] && name="main"
# if [[ "''${name}" = "" ]]; then
# help da
# return 2
# fi
# --user 0 is required for rootless docker.
distrobox enter -a '--user=0' "''${name}"
}
'';
}

View file

@ -1,16 +0,0 @@
{ ... }:
{
text = ''
# Wrapped dmenu_path to include my functions.
function _dmenu_path_wrapped() {
c=0
while [ ''${c} -lt 1000 ]; do
echo
((c++))
done
find_function | grep -v ^_
dmenu_path
}
'';
}

View file

@ -6,28 +6,5 @@
function o() {
xdg-open "''${@}"
}
# Play media file from CLI. All files by default.
# Usage: play [FILE]
function play() {
local targets=''${*}
[[ "''${targets}" = "" ]] && targets=$(_ls_file)
mpv --no-video ''${targets}
}
# Play media files shuffled from CLI. All files by default.
# Usage: play_shuffle [FILE]
function play_shuffle() {
local targets=''${*}
[[ "''${targets}" = "" ]] && targets=$(_ls_file)
mpv --no-video --shuffle ''${targets}
}
# Open files app.
function files() {
nautilus
}
'';
}

View file

@ -16,56 +16,10 @@
ethtool -s "''${device}" speed "''${speed}"
}
# Fix nautilus after typing wrong sftp password.
function fix_files_sftp() {
secret-tool clear protocol sftp
}
# Delete lost Gradle lock files.
function fix_gradle_lock() {
cd "''${HOME}/.gradle" && find -type f | grep \\.lock$ | xargs -- rm
cd -
}
# Fix Gnome's broken RDP ffs.
# Usage: fix_gnome_rdp <PASSWORD>
function fix_gnome_rdp() {
local user="''${USERNAME}"
local password="''${1}"
# Check params.
if [[ "''${password}" = "" ]]; then
help fix_gnome_rdp
return 2
fi
# Unlock keyring. PROTIP: Disable password for it in password manager.
pkill -9 -f gnome-keyring-daemon
echo -n "''${user}" | gnome-keyring-daemon --unlock
# Generate keys.
cd /tmp
openssl genrsa -out rdp-tls.key 4096
openssl req -new -key rdp-tls.key -subj "/C=US" | openssl x509 -req -days 730 -signkey rdp-tls.key -out rdp-tls.crt
mkdir -p "''${HOME}/.local/share/gnome-remote-desktop/"
mv rdp-tls.key rdp-tls.crt "''${HOME}/.local/share/gnome-remote-desktop/"
# Configure RDP.
grdctl rdp set-tls-cert "''${HOME}/.local/share/gnome-remote-desktop/rdp-tls.crt"
grdctl rdp set-tls-key "''${HOME}/.local/share/gnome-remote-desktop/rdp-tls.key"
grdctl rdp set-credentials "''${user}" "''${password}"
grdctl rdp disable-view-only
# Start service.
grdctl rdp enable
systemctl --user start gnome-remote-desktop.service
# Show status.
grdctl status --show-credentials
systemctl --user status gnome-remote-desktop.service
# Show extra info.
_warn "You may need to manually restart Desktop sharing via Gnome Settings."
}
'';
}

View file

@ -1,20 +0,0 @@
{ ... }:
{
text = ''
# Render markdown in browser using Gitea API. Because I want consistency with Gitea web render.
# Works only inside LAN.
# Usage: markdown_render <FILE.md>
function markdown_render() {
local IFS=$'\n'
local file="''${1}"
local render="markdown_render.html"
if [[ "''${file}" = "" ]]; then
help markdown_render
return 2
fi
curl -X POST https://git.voronind.com/markdown -d "$(cat ''${file})" > "''${render}" && o "''${render}" && sleep 2 && rm "''${render}"
}
'';
}

View file

@ -1,37 +0,0 @@
{ ... }:
{
text = ''
# Open bluetooth control panel.
function bluetooth() {
blueman-manager
}
# Open network control panel.
function network() {
nm-connection-editor
}
# Show active connections.
function nms() {
nmcli connection show
}
# Start the connection.
# Usage: nu <CONNECTION>
function nmu() {
nmcli connection up "''${@}"
}
# Stop the connection.
# Usage: nd <CONNECTION>
function nmd() {
nmcli connection down "''${@}"
}
function _complete_connections() {
_autocomplete $(nmcli connection show | sed "1d" | cut -d\ -f1)
}
complete -F _complete_connections nmd nmu
'';
}

View file

@ -1,28 +1,6 @@
{ const, ... }:
{ ... }:
{
text = ''
export _nix_system_config="git+${const.url}"
# Rebuild system.
# Optionally force the hostname.
# Usage: nixos_rebuild [HOSTNAME]
function nixos_rebuild() {
local target="''${1}"
[[ "''${target}" = "" ]] && target="''${HOSTNAME}"
nixos-rebuild boot --refresh --option eval-cache false --flake "''${_nix_system_config}#''${target}"
}
# Rebuild and switch system.
# Optionally force the hostname.
# Usage: nixos_switch [HOSTNAME]
function nixos_switch() {
local target="''${1}"
[[ "''${target}" = "" ]] && target="''${HOSTNAME}"
nixos-rebuild switch --refresh --option eval-cache false --flake "''${_nix_system_config}#''${target}"
}
# Spawn shell with specified nix environment.
# Uses flake.nix in current dir by default.
# Usage: shell [NAME]
@ -30,10 +8,7 @@
local target="''${1}"
[[ "''${target}" = "" ]] && target="default"
# Create Nix GC root in .NixRoot{NAME}.
nix build ".#devShells.''${NIX_CURRENT_SYSTEM}.''${target}" -o ".NixRoot''${target^}"
SHELL_NAME="''${target}" nix develop ".#devShells.''${NIX_CURRENT_SYSTEM}.''${target}"
SHELL_NAME="''${target}" nix develop ".#''${target}"
}
# Spawn temporary nix-shell with specified packages.
@ -42,15 +17,13 @@
local IFS=$'\n'
local input=("''${@}")
local pkgs=()
local tag="''${SHELL_NAME}"
local tag="''${1}"
if [[ "''${input}" = "" ]]; then
help tmpshell
return 2
fi
[[ "''${tag}" = "" ]] && tag="''${1}"
for pkg in ''${input[@]}; do
pkgs+=("nixpkgs#''${pkg}")
done
@ -58,35 +31,21 @@
SHELL_NAME="''${tag}" NIXPKGS_ALLOW_UNFREE=1 nix shell --impure ''${pkgs[@]}
}
# Build live image.
function nixos_live() {
nix build "''${_nix_system_config}#nixosConfigurations.live.config.system.build.isoImage" --refresh ''${@}
# Run stuff directrly from Nixpks.
# Usage: nixpkgs_run <REV> <PACKAGE> [COMMAND]
function nixpkgs_run() {
local rev="''${1}"
local pkg="''${2}"
local cmd="''${@:3}"
if [[ "''${pkg}" = "" ]]; then
help nixpkgs_run
return 2
fi
[[ "''${cmd}" = "" ]] && cmd="''${pkg}"
SHELL_NAME="''${pkg}" NIXPKGS_ALLOW_UNFREE=1 nix shell --impure github:NixOS/nixpkgs/''${rev}#''${pkg} -c ''${cmd}
}
# List nixos generations.
function nixos_generations() {
nix-env -p /nix/var/nix/profiles/system --list-generations
}
# Switch nix-on-droid.
function nixdroid_switch() {
nix-on-droid switch --flake "''${_nix_system_config}" ''${@}
}
# Nix auto-run wrapper.
# Usage: , <COMMAND>
function ,() {
NIX_AUTO_RUN=1 ''${@}
}
# Autocomplete with available hosts.
function _comp_hosts() {
local IFS=$'\n'
local targets=($(ls ~/.config/linux/system/host/))
_autocomplete_first ''${targets[@]}
}
complete -F _comp_hosts nix_switch nix_rebuild
'';
}

View file

@ -1,14 +0,0 @@
{ ... }:
{
text = ''
# Suspend system.
function slp() {
systemctl suspend -i
}
# Poweroff.
function bye() {
systemctl poweroff -i
}
'';
}

View file

@ -1,29 +0,0 @@
{ ... }:
{
text = ''
export _flatpakcfg_path="''${HOME}/.config/linux/Flatpak.txt"
# Prune everything unused in docker.
function prune_docker() {
docker system prune --volumes --all
}
# Prune Nix Store.
function prune_nix() {
nix-store --gc
}
# Uninstall flatpaks not listed in the config.
function prune_flatpak() {
local IFS=$'\n'
local config=($(cat ''${_flatpakcfg_path} | cut -f2))
local installed=($(flatpak list --app | cut -f2))
process() {
_contains ''${target} ''${config[@]} || flatpak uninstall ''${target}
}
_iterate_targets process ''${installed[@]}
}
'';
}

View file

@ -1,23 +0,0 @@
{ ... }:
{
text = ''
# Mount FS over ssh. Just extra config for sshfs.
# Usage: ssh_mount <REMOTE> <LOCAL>
function ssh_mount() {
sshfs -o uid=''${UID},auto_unmount "''${@}"
}
# Mount FS over ssh. Just extra config for sshfs.
# Usage: ssh_mount <REMOTE> <LOCAL>
function ssh_mount_ro() {
sshfs -o uid=''${UID},auto_unmount,ro "''${@}"
}
# Generate private an public keys on a local host and print a public key.
function ssh_keygen() {
ssh-keygen && cat ~/.ssh/*.pub
}
complete -o nospace -F _sshfs sshmount
'';
}

View file

@ -1,9 +0,0 @@
{ ... }:
{
text = ''
# Start Steam with Wayland screen share for Link to work.
function steam_link() {
steam -pipewire -pipewire-dmabuf
}
'';
}

View file

@ -1,11 +0,0 @@
{ ... }:
{
text = ''
# Get terminal size.
function tsize() {
local width=$(tput cols)
local height=$(tput lines)
echo "''${width}x''${height}"
}
'';
}

View file

@ -1,21 +0,0 @@
{ ... }:
{
text = ''
# CD into host's primary tmp dir.
function tmp() {
local host="''${HOSTNAME}"
local tmp_path
case "''${host}" in
"desktop"|"home")
tmp_path="/storage/hot/tmp"
;;
*)
tmp_path="''${HOME}/tmp"
;;
esac
cd "''${tmp_path}"
}
'';
}

View file

@ -1,9 +0,0 @@
{ ... }:
{
text = ''
# Open `~/.todo.md` file.
function todo() {
vi ~/.todo.md
}
'';
}

View file

@ -155,22 +155,5 @@
local users=("voronind" "dasha")
echo ''${users[@]}
}
# Force the command to be called twice within the specified period in seconds. Used primarily in important keyboard shortcuts like poweroff.
# Usage: _twice <PERIOD> <COMMAND>
function _twice() {
local IFS=$'\n'
local file="/tmp/.twice"
local period=''${1}
local command="''${@:2}"
if [[ "$(cat ''${file} 2> /dev/null)" = "''${command}" ]]; then
''${command}
return 0
fi
echo "''${command}" > "''${file}"
sleep ''${period}
rm "''${file}" 2> /dev/null
}
'';
}

View file

@ -1,11 +0,0 @@
{ ... }:
{
text = ''
# FRKN.
# SOURCE: https://github.com/bol-van/zapret
function zapret() {
iptables -t mangle -I POSTROUTING -p tcp -m multiport --dports 80,443 -m connbytes --connbytes-dir=original --connbytes-mode=packets --connbytes 1:6 -m mark ! --mark 0x40000000/0x40000000 -j NFQUEUE --queue-num 200 --queue-bypass
nfqws --pidfile=/run/nfqws.pid --qnum=201 ''${@}
}
'';
}

View file

@ -1,61 +0,0 @@
# https://github.com/ollama/ollama
{
pkgsStable,
lib,
config,
...
}:
with lib;
let
pkgs = pkgsStable;
cfg = config.module.ollama;
in
{
options = {
module.ollama = {
enable = mkEnableOption "Local LLM server";
primaryModel = mkOption {
default = "llama3";
type = types.str;
};
models = mkOption {
default = [ cfg.primaryModel ];
type = types.listOf types.str;
};
};
};
config = mkIf cfg.enable {
environment = {
# Specify default model.
variables.OLLAMA_MODEL = cfg.primaryModel;
};
systemd.services = {
# Enable Ollama server.
ollama = {
description = "Ollama LLM server.";
wantedBy = [ "multi-user.target" ];
wants = [ "NetworkManager-wait-online.service" ];
after = [ "NetworkManager-wait-online.service" ];
serviceConfig.Type = "simple";
script = ''
HOME=/root ${getExe pkgs.ollama} serve
'';
};
# Download Ollama models.
ollamamodel = {
description = "Ollama LLM model.";
wantedBy = [ "multi-user.target" ];
wants = [ "ollama.service" ];
after = [ "ollama.service" ];
serviceConfig.Type = "simple";
script = ''
sleep 5
${getExe pkgs.ollama} pull ${concatStringsSep " " cfg.models}
'';
};
};
};
}