Moved from xdg.config to home.file lib.mkForce
This commit is contained in:
@@ -1,98 +0,0 @@
|
||||
{ config, pkgs, lib, flakeRoot, ... }:
|
||||
|
||||
let
|
||||
# Path to environment file
|
||||
AiRepoEnv = flakeRoot + "/assets/conf/apps/ai/ai.env";
|
||||
|
||||
# Environment file parser
|
||||
parseEnv = lines:
|
||||
lib.foldl' (acc: line:
|
||||
let
|
||||
trimmed = builtins.trim line;
|
||||
in
|
||||
if trimmed == "" || (builtins.stringLength trimmed) > 0 && (builtins.substr 0 1 trimmed) == "#"
|
||||
then acc
|
||||
else
|
||||
let parts = builtins.split "=" trimmed;
|
||||
in
|
||||
if builtins.length parts >= 2
|
||||
then builtins.add (builtins.elemAt parts 0) (builtins.elemAt parts 1) acc
|
||||
else acc
|
||||
) { } (builtins.split "\n" (builtins.readFile (toString AiRepoEnv)));
|
||||
|
||||
envVars = parseEnv;
|
||||
in
|
||||
{
|
||||
# Install required packages
|
||||
home.packages = [
|
||||
pkgs.ollama-vulkan
|
||||
pkgs.zed-editor
|
||||
];
|
||||
|
||||
# Set environment variables
|
||||
home.sessionVariables = {
|
||||
OLLAMA_HOST = envVars.OLLAMA_HOST or "http://127.0.0.1:11434";
|
||||
MISTRAL_API_KEY = envVars.MISTRAL_API_KEY or "";
|
||||
};
|
||||
|
||||
# Configure Ollama service using the correct Home Manager syntax
|
||||
systemd.user.services.ollama = {
|
||||
Unit = {
|
||||
Description = "Ollama service for local AI models";
|
||||
After = [ "network.target" ];
|
||||
Wants = [ "network.target" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
Type = "forking";
|
||||
ExecStart = "${pkgs.ollama-vulkan}/bin/ollama serve";
|
||||
ExecStartPost = ''
|
||||
sleep 5
|
||||
${pkgs.ollama-vulkan}/bin/ollama pull codellama:70b
|
||||
${pkgs.ollama-vulkan}/bin/ollama pull mixtral:8x7b
|
||||
'';
|
||||
Restart = "on-failure";
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ "default.target" ];
|
||||
};
|
||||
};
|
||||
|
||||
# ZED configuration
|
||||
home.file.".config/zed/settings.json".text = lib.mkForce (
|
||||
builtins.toJSON {
|
||||
mistral = {
|
||||
apiKey = envVars.MISTRAL_API_KEY or "";
|
||||
defaultModel = "mistral-pro";
|
||||
};
|
||||
ollama = {
|
||||
endpoint = envVars.OLLAMA_HOST or "http://127.0.0.1:11434";
|
||||
defaultModel = "codellama:70b";
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
# --- Usage Notes ---
|
||||
# 1. Pulling Additional Models:
|
||||
# To add more models later, run:
|
||||
# ollama pull <model-name>
|
||||
# Example: ollama pull llama3:8b
|
||||
#
|
||||
# 2. Switching GPU Backends:
|
||||
# - For NVIDIA: Replace all `ollama-vulkan` with `ollama` (uses CUDA)
|
||||
# - For AMD: Use `ollama-rocm` and ensure ROCm is installed
|
||||
#
|
||||
# 3. ZED Plugin Setup:
|
||||
# - Install the Ollama and Mistral plugins in ZED via the plugin marketplace
|
||||
# - The Ollama plugin will use the local models pulled above
|
||||
# - The Mistral plugin will use the MISTRAL_API_KEY for cloud access
|
||||
#
|
||||
# 4. Security:
|
||||
# - Never commit ./assets/conf/apps/ai.env to version control
|
||||
# - For extra security, encrypt ai.env using sops-nix or age
|
||||
#
|
||||
# 5. Persistent Service:
|
||||
# To keep Ollama running after logout, enable lingering:
|
||||
# loginctl enable-linger $(whoami)
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
xdg.mimeApps.enable = true;
|
||||
xdg.mimeApps.defaultApplications = {
|
||||
"x-scheme-handler/http" = [ "app.zen_browser.zen.desktop" ];
|
||||
"x-scheme-handler/https" = [ "app.zen_browser.zen.desktop" ];
|
||||
"text/html" = [ "app.zen_browser.zen.desktop" ];
|
||||
};
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
{
|
||||
imports = [
|
||||
./apps/ollama.nix
|
||||
#./apps/default-apps.nix
|
||||
./apps/theme.nix
|
||||
./desktop/hypridle.nix
|
||||
./desktop/hyprland.nix
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
{ config, pkgs, lib, flakeRoot, ... }:
|
||||
let
|
||||
repoConf = flakeRoot + "/assets/conf/desktop/notifications/swaync/config.json";
|
||||
repoStyle = flakeRoot + "/assets/conf/desktop/notifications/swaync/style.css";
|
||||
in
|
||||
{
|
||||
home.packages = [
|
||||
pkgs.swaynotificationcenter
|
||||
pkgs.libnotify
|
||||
];
|
||||
# Ensure config directory exists in ~/.config
|
||||
xdg.configFile."swaync/config.json".source = repoConf;
|
||||
xdg.configFile."swaync/style.css".source = repoStyle;
|
||||
# Start swaync automatically (systemd user service)
|
||||
systemd.user.services.swaync = {
|
||||
Unit = {
|
||||
Description = "Sway Notification Center";
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
};
|
||||
Service = {
|
||||
ExecStart = "${pkgs.swaynotificationcenter}/bin/swaync";
|
||||
Restart = "always";
|
||||
};
|
||||
Install = {
|
||||
WantedBy = [ "graphical-session.target" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,201 +0,0 @@
|
||||
{ config, lib, pkgs, flakeRoot, ... }:
|
||||
|
||||
let
|
||||
userRelRoot = "nixos_conf/wallpaperstuff";
|
||||
userAbsRoot = "${config.home.homeDirectory}/${userRelRoot}";
|
||||
picturesDir = "${userAbsRoot}/pictures";
|
||||
repoWallpaperDir = flakeRoot.outPath + "/assets/conf/desktop/wallpaper";
|
||||
repoWallpapersOnly = lib.cleanSourceWith {
|
||||
src = repoWallpaperDir;
|
||||
filter = path: type: true;
|
||||
};
|
||||
daemonRel = ".config/hypr/scripts/hyprpaper-ws-daemon.sh";
|
||||
setRel = ".config/hypr/scripts/set-wallpaper.sh";
|
||||
in
|
||||
{
|
||||
home.packages = [
|
||||
pkgs.hyprpaper
|
||||
pkgs.socat
|
||||
pkgs.jq
|
||||
pkgs.findutils
|
||||
pkgs.coreutils
|
||||
pkgs.gnused
|
||||
pkgs.gawk
|
||||
];
|
||||
|
||||
# Sync wallpapers into a writable directory
|
||||
home.file."${userRelRoot}" = {
|
||||
source = repoWallpapersOnly;
|
||||
recursive = true;
|
||||
};
|
||||
|
||||
# Hyprpaper config
|
||||
home.file.".config/hypr/hyprpaper.conf" = {
|
||||
text = ''
|
||||
ipc = true
|
||||
splash = false
|
||||
'';
|
||||
};
|
||||
|
||||
# Workspace wallpaper daemon
|
||||
home.file."${daemonRel}" = {
|
||||
executable = true;
|
||||
text = ''
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
: "${XDG_RUNTIME_DIR?"XDG_RUNTIME_DIR not set"}"
|
||||
: "${HYPRLAND_INSTANCE_SIGNATURE?"HYPRLAND_INSTANCE_SIGNATURE not set"}"
|
||||
|
||||
SOCK="${XDG_RUNTIME_DIR}/hypr/${HYPRLAND_INSTANCE_SIGNATURE}/.socket2.sock"
|
||||
[[ -S "$SOCK" ]] || { echo "Hyprland socket not found: $SOCK" >&2; exit 1; }
|
||||
|
||||
PICTURES_DIR="${1:-${picturesDir}}" # $1 = eerste argument, ${picturesDir} = default (Bash-variabele)
|
||||
FIT_MODE="fill"
|
||||
HYPR_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/hypr" # Gebruik $HOME als fallback
|
||||
MAP_ROOT="${HYPR_DIR}/hyprpaper/config"
|
||||
|
||||
focused_monitor() {
|
||||
hyprctl -j monitors | jq -r '.[] | select(.focused==true) | .name' | head -n 1
|
||||
}
|
||||
|
||||
map_file_for_monitor() {
|
||||
local mon="$1"
|
||||
echo "${MAP_ROOT}/${mon}/defaults.conf"
|
||||
}
|
||||
|
||||
ensure_map_file() {
|
||||
local mon="$1"
|
||||
local f
|
||||
f="$(map_file_for_monitor "$mon")"
|
||||
mkdir -p "$(dirname "$f")"
|
||||
if [[ ! -f "$f" ]]; then
|
||||
{
|
||||
for i in 1 2 3 4 5 6 7 8 9; do
|
||||
seed="$(ls -1 "${PICTURES_DIR}/${i}."* 2>/dev/null | head -n 1 || true)"
|
||||
echo "w-${i}=${seed}"
|
||||
done
|
||||
} > "$f"
|
||||
fi
|
||||
echo "$f"
|
||||
}
|
||||
|
||||
get_wall_for_ws() {
|
||||
local mon="$1"
|
||||
local wsid="$2"
|
||||
local f key val
|
||||
f="$(ensure_map_file "$mon")"
|
||||
key="w-${wsid}"
|
||||
val="$(awk -F= -v k="$key" '$1==k {sub(/^[[:space:]]+/, "", $2); print $2; exit}' "$f" || true)"
|
||||
echo "$val"
|
||||
}
|
||||
|
||||
apply_wallpaper() {
|
||||
local mon="$1"
|
||||
local wsid="$2"
|
||||
local file
|
||||
file="$(get_wall_for_ws "$mon" "$wsid")"
|
||||
[[ -n "$file" ]] || return 0
|
||||
[[ -f "$file" ]] || return 0
|
||||
hyprctl hyprpaper wallpaper "$mon, $file, $FIT_MODE" >/dev/null
|
||||
}
|
||||
|
||||
mon="$(focused_monitor || true)"
|
||||
wsid="$(hyprctl -j activeworkspace | jq -r '.id' | head -n 1 || true)"
|
||||
[[ -n "$mon" && -n "$wsid" ]] && apply_wallpaper "$mon" "$wsid"
|
||||
|
||||
handle() {
|
||||
local line="$1"
|
||||
case "$line" in
|
||||
workspacev2* )
|
||||
payload="${line#*>>}"
|
||||
wsid="${payload%%,*}"
|
||||
mon="$(focused_monitor || true)"
|
||||
[[ -n "$mon" && -n "$wsid" ]] && apply_wallpaper "$mon" "$wsid"
|
||||
;;
|
||||
focusedmon* )
|
||||
mon="$(focused_monitor || true)"
|
||||
wsid="$(hyprctl -j activeworkspace | jq -r '.id' | head -n 1 || true)"
|
||||
[[ -n "$mon" && -n "$wsid" ]] && apply_wallpaper "$mon" "$wsid"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
socat -U - UNIX-CONNECT:"$SOCK" | while read -r line; do
|
||||
handle "$line" || true
|
||||
done
|
||||
'';
|
||||
};
|
||||
|
||||
# CLI setter
|
||||
home.file."${setRel}" = {
|
||||
executable = true;
|
||||
text = ''
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
HYPR_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
|
||||
MAP_ROOT="${HYPR_DIR}/hyprpaper/config"
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 <workspace_id> <monitor> [wallpaper_path]"
|
||||
}
|
||||
|
||||
wsid="${1:-}"
|
||||
mon="${2:-}"
|
||||
wp="${3:-}"
|
||||
|
||||
[[ -n "$wsid" ]] || { usage; exit 1; }
|
||||
[[ -n "$mon" ]] || { usage; exit 1; }
|
||||
|
||||
cfg="${MAP_ROOT}/${mon}/defaults.conf"
|
||||
mkdir -p "$(dirname "$cfg")"
|
||||
[[ -f "$cfg" ]] || touch "$cfg"
|
||||
|
||||
if [[ -z "$wp" ]]; then
|
||||
wp="$(find "${XDG_CONFIG_HOME:-$HOME/.config}/wallpapers/defaults" -type f 2>/dev/null | shuf -n 1 || true)"
|
||||
[[ -n "$wp" ]] || { echo "No wallpaper found (random). Provide a path as arg 3."; exit 1; }
|
||||
fi
|
||||
|
||||
key="w-${wsid}"
|
||||
if ! grep -q "^${key}=" "$cfg"; then
|
||||
echo "${key}=" >> "$cfg"
|
||||
fi
|
||||
|
||||
sed -i "s|^${key}=.*|${key}= ${wp}|g" "$cfg"
|
||||
|
||||
curws="$(hyprctl -j monitors | jq -r --arg m "$mon" '.[] | select(.name==$m) | .activeWorkspace.id' | head -n 1 || true)"
|
||||
if [[ "$curws" == "$wsid" ]]; then
|
||||
hyprctl hyprpaper wallpaper "$mon, $wp, fill" >/dev/null
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
# Services
|
||||
systemd.user.services.hyprpaper = {
|
||||
Unit = {
|
||||
Description = "hyprpaper wallpaper daemon";
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
After = [ "graphical-session.target" ];
|
||||
};
|
||||
Service = {
|
||||
ExecStart = "${pkgs.hyprpaper}/bin/hyprpaper";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 1;
|
||||
};
|
||||
Install = { WantedBy = [ "graphical-session.target" ]; };
|
||||
};
|
||||
|
||||
systemd.user.services.hyprpaper-ws-daemon = {
|
||||
Unit = {
|
||||
Description = "Workspace->wallpaper mapping daemon (hyprpaper + socket2)";
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
After = [ "graphical-session.target" "hyprpaper.service" ];
|
||||
};
|
||||
Service = {
|
||||
ExecStart = "${pkgs.bash}/bin/bash ${config.home.homeDirectory}/${daemonRel} ${picturesDir}";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 1;
|
||||
};
|
||||
Install = { WantedBy = [ "graphical-session.target" ]; };
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user