commit ce26fcb59c91b61832e5089c8203ea3c5479fa67 Author: TheK0tYaRa Date: Thu Feb 12 16:11:22 2026 +0200 initial diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6860ecf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.old/ \ No newline at end of file diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..a00266f --- /dev/null +++ b/configuration.nix @@ -0,0 +1,241 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +{ + config, + # lib, + pkgs, + # inputs, + ... +}: + +{ + nixpkgs.config.allowUnfree = true; + + imports = [ + ./hardware-configuration.nix + ]; + + fileSystems = { + "/mnt/gentoo" = { + device = "/dev/disk/by-label/NVME_GENTOO"; + fsType = "xfs"; + }; + "/mnt/HDD_A_DATA" = { + device = "/dev/disk/by-label/HDD_A_DATA"; + fsType = "ext4"; + }; + "/mnt/HDD_B_1TB" = { + device = "/dev/disk/by-label/HDD_B_1TB"; + fsType = "ext4"; + }; + # dirmounts + "/home/thek0tyara/Documents" = { + depends = [ "/mnt/HDD_B_1TB" ]; + device = "/mnt/HDD_B_1TB/home-backup/Documents"; + fsType = "none"; + options = [ "bind" ]; + }; + "/home/thek0tyara/Downloads" = { + depends = [ "/mnt/HDD_B_1TB" ]; + device = "/mnt/HDD_B_1TB/home-backup/Downloads"; + fsType = "none"; + options = [ "bind" ]; + }; + "/home/thek0tyara/.cache" = { + depends = [ "/mnt/HDD_A_DATA" ]; + device = "/mnt/HDD_A_DATA/_CACHE"; + fsType = "none"; + options = [ "bind" ]; + }; + "/home/thek0tyara/.lmstudio" = { + depends = [ "/mnt/HDD_A_DATA" ]; + device = "/mnt/HDD_A_DATA/_LMSTUDIO"; + fsType = "none"; + options = [ "bind" ]; + }; + }; + + nix = { + settings = { + experimental-features = [ + "nix-command" + "flakes" + ]; + auto-optimise-store = true; + substituters = [ + "https://nix-community.cachix.org" + "https://cache.nixos.org" + ]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; + extraOptions = "!include ${config.age.secrets."github/token.ro.age".path}"; + }; + + boot = { + loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = false; + }; + kernelPackages = pkgs.linuxPackages_latest; + extraModulePackages = with config.boot.kernelPackages; [ + v4l2loopback + amneziawg + ]; + }; + + networking = { + hostName = "testenv"; + nameservers = [ "10.20.0.1" ]; + enableIPv6 = false; + hosts."127.0.0.1" = [ "domain.local" ]; + }; + systemd.network.networks."enp5s0" = { + matchConfig.Name = "enp5s0"; + address = [ "10.20.0.201/24" ]; + routes = [ { Gateway = "10.20.0.1"; } ]; + linkConfig.RequiredForOnline = "no"; + }; + + # networking.wireguard = { + # interfaces = { + # # wg200 = { + # # ips = [ + # # "10.20.0.201/32" + # # ]; + # # peers = [ + # # { + # # allowedIPs = [ + # # "10.20.0.0/24" + # # ]; + # # endpoint = "10.20.0.1:51821"; + # # persistentKeepalive = 15; + # # publicKey = "EskQEQkC/5t/RyYzrmHLj0HpaiDTEOPgBkbqRcC2d1g="; + # # } + # # ]; + # # privateKeyFile = config.age.secrets."wg/syscon0.key".path; + # # }; + # # syscon0 = { + # # ips = [ + # # "10.1.1.200/32" + # # ]; + # # peers = [ + # # { + # # allowedIPs = [ + # # "10.0.0.0/16" + # # "100.0.0.0/24" + # # "10.1.1.0/24" + # # ]; + # # endpoint = "87.251.77.150:60886"; + # # persistentKeepalive = 15; + # # publicKey = "uWoxsevoib1+mX3qAtogSxX2M3R6hSu4AfG+nEFgh2I="; + # # #publicKeyFile = ""; # why not you stupid bastard? + # # } + # # ]; + # # privateKeyFile = config.age.secrets."wg/syscon0.key".path; + # # }; + # }; + # }; + time.timeZone = "Europe/Kiev"; + + i18n.defaultLocale = "en_US.UTF-8"; + + fonts.packages = with pkgs; [ + noto-fonts + noto-fonts-cjk-sans + noto-fonts-color-emoji + liberation_ttf + font-awesome + ]; + + # users.defaultUserShell = pkgs.fish; + users.users.thek0tyara = { + isNormalUser = true; + extraGroups = [ + "wheel" + "disk" + "dialout" + "video" + "render" + "docker" + "kvm" + "libvirt" + "input" + "users" + "plugdev" + "lxc" + "pipewire" + ]; + packages = with pkgs; [ + # swaylock + swaybg + # swayimg + swayidle + fuzzel + xwayland-satellite + gamescope + telegram-desktop + ladybird + krita + meld + pavucontrol + pwvucontrol + ffmpegthumbnailer + libsForQt5.qt5.qtwayland + qt6Packages.qt6ct + lxappearance + ncdu + ffmpeg-full + mpv + xdotool + tree + hyperfine + unrar + unzip + xarchiver + nmap + ]; + }; + + programs = { + niri.enable = true; + gnome-terminal.enable = true; + thunar.enable = true; + winbox = { + enable = true; + package = pkgs.winbox4; + }; + gnupg.agent = { + enable = true; + enableSSHSupport = true; + }; + }; + + services = { + openssh.enable = true; + tor = { + enable = true; + torsocks = { + enable = true; + }; + xrdp = { + # enable = true; + audio.enable = true; + sslKey = "/secrets/xrdp/key.pem"; # TODO move those + sslCert = "/secrets/xrdp/cert.pem"; # TODO move those + }; + }; + }; + + networking.firewall.enable = false; + + # Copy the NixOS configuration file and link it from the resulting system + # (/run/current-system/configuration.nix). This is useful in case you + # accidentally delete configuration.nix. + # system.copySystemConfiguration = true; + + system.stateVersion = "25.11"; +} diff --git a/custom/default.nix b/custom/default.nix new file mode 100644 index 0000000..33c7cf4 --- /dev/null +++ b/custom/default.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + imports = [ + ./hm + ]; +} \ No newline at end of file diff --git a/custom/hm/default.nix b/custom/hm/default.nix new file mode 100644 index 0000000..02597cb --- /dev/null +++ b/custom/hm/default.nix @@ -0,0 +1,7 @@ +{ ... }: +{ + imports = [ + ./programs + ./services + ]; +} \ No newline at end of file diff --git a/custom/hm/programs/default.nix b/custom/hm/programs/default.nix new file mode 100644 index 0000000..07f9c5a --- /dev/null +++ b/custom/hm/programs/default.nix @@ -0,0 +1,23 @@ +{ lib, ... }: +let + here = ./.; + entries = builtins.readDir here; + names = lib.attrNames entries; + + nixFiles = + builtins.filter + (n: entries.${n} == "regular" && lib.hasSuffix ".nix" n && n != "default.nix") + names; + + subdirDefaultNix = + builtins.filter + (d: entries.${d} == "directory" + && builtins.pathExists (here + "/${d}/default.nix")) + names; + +in +{ + imports = + (map (n: here + "/${n}") nixFiles) + ++ (map (d: here + "/${d}/default.nix") subdirDefaultNix); +} diff --git a/custom/hm/programs/llama-cpp/default.nix b/custom/hm/programs/llama-cpp/default.nix new file mode 100644 index 0000000..75e646e --- /dev/null +++ b/custom/hm/programs/llama-cpp/default.nix @@ -0,0 +1,84 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.programs.llama-cpp; + + defaultArgsBash = + lib.concatStringsSep " " (map lib.escapeShellArg cfg.defaultArgs); + + globalEosTextBash = + lib.escapeShellArg (lib.concatStringsSep "\n" cfg.eosStrings); + + presetBash = + lib.concatMapStringsSep "\n" (p: '' + PRESET_PATHS[${lib.escapeShellArg p.name}]=${lib.escapeShellArg p.path} + PRESET_ALIAS[${lib.escapeShellArg p.name}]=${lib.escapeShellArg (p.alias or p.name)} + PRESET_EOS_TEXT[${lib.escapeShellArg p.name}]=${lib.escapeShellArg (lib.concatStringsSep "\n" (p.eosStrings or []))} + '') cfg.presets; + + template = builtins.readFile ./llama-serve.sh; + + scriptText = lib.replaceStrings + [ + "@server_bin@" + "@default_args@" + "@global_eos_text@" + "@preset_bash@" + ] + [ + "${cfg.package}/bin/${cfg.serverBinary}" + defaultArgsBash + globalEosTextBash + presetBash + ] + template; + + wrapper = pkgs.writeShellScriptBin cfg.wrapperName scriptText; + +in { + options.programs.llama-cpp = { + enable = lib.mkEnableOption "llama.cpp wrapper for llama-server"; + + package = lib.mkPackageOption pkgs "llama-cpp" { }; + + serverBinary = lib.mkOption { + type = lib.types.str; + default = "llama-server"; + }; + + wrapperName = lib.mkOption { + type = lib.types.str; + default = "llama-serve"; + }; + + defaultArgs = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + description = "Args always passed to llama-server before user args."; + }; + + eosStrings = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + }; + + presets = lib.mkOption { + type = lib.types.listOf (lib.types.submodule ({ ... }: { + options = { + name = lib.mkOption { type = lib.types.str; }; + path = lib.mkOption { type = lib.types.str; }; + alias = lib.mkOption { type = lib.types.nullOr lib.types.str; default = null; }; + eosStrings = lib.mkOption { type = lib.types.listOf lib.types.str; default = [ ]; }; + }; + })); + default = [ ]; + }; + }; + + config = lib.mkIf cfg.enable { + home.packages = [ + cfg.package + wrapper + ]; + }; +} diff --git a/custom/hm/programs/llama-cpp/llama-serve.sh b/custom/hm/programs/llama-cpp/llama-serve.sh new file mode 100644 index 0000000..31f3966 --- /dev/null +++ b/custom/hm/programs/llama-cpp/llama-serve.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +set -euo pipefail + +SERVER_BIN="@server_bin@" +DEFAULT_ARGS=( @default_args@ ) +GLOBAL_EOS_TEXT=@global_eos_text@ + +declare -A PRESET_PATHS +declare -A PRESET_ALIAS +declare -A PRESET_EOS_TEXT +@preset_bash@ + +usage() { + cat >&2 <<'EOF' +Usage: + llama-serve [llama-server args...] + +If matches programs.llama-cpp.presets[].name, its path/alias/eosStrings are used. +Global eosStrings + preset eosStrings are appended as repeated --reverse-prompt entries. +EOF + if ((${#PRESET_PATHS[@]})); then + echo >&2 + echo "Presets:" >&2 + for k in "${!PRESET_PATHS[@]}"; do + echo " $k -> ${PRESET_PATHS[$k]}" >&2 + done + fi + exit 2 +} + +((${#} >= 1)) || usage + +spec="$1" +shift || true + +model_path="" +model_alias="" +preset_eos="" + +if [[ -n "${PRESET_PATHS[$spec]+x}" ]]; then + model_path="${PRESET_PATHS[$spec]}" + model_alias="${PRESET_ALIAS[$spec]:-$spec}" + preset_eos="${PRESET_EOS_TEXT[$spec]:-}" +else + model_path="$spec" + model_alias="" + preset_eos="" +fi + +# expand ~/... +if [[ "$model_path" == "~/"* ]]; then + model_path="$HOME/${model_path#~/}" +fi + +# if [[ ! -f "$model_path" ]]; then +# echo "Model not found: $model_path" >&2 +# exit 1 +# fi +model_flag="-m" +model_spec="$model_path" + +# If arg1 doesn't resolve to an existing local file, treat it as a Hugging Face repo spec. +if [[ ! -f "$model_path" ]]; then + model_flag="-hf" +fi + +args=( "${DEFAULT_ARGS[@]}" ) + +add_reverse_prompts_from_text() { + local text="$1" + [[ -n "$text" ]] || return 0 + while IFS= read -r line; do + [[ -n "$line" ]] || continue + args+=( "--reverse-prompt" "$line" ) + done <<<"$text" +} + +add_reverse_prompts_from_text "$GLOBAL_EOS_TEXT" +add_reverse_prompts_from_text "$preset_eos" + +# Optional: set REST API alias when preset provides one (llama-server supports --alias). :contentReference[oaicite:3]{index=3} +if [[ -n "$model_alias" ]]; then + args+=( "--alias" "$model_alias" ) +fi + +# exec "$SERVER_BIN" -m "$model_path" "${args[@]}" "$@" +exec "$SERVER_BIN" "$model_flag" "$model_spec" "${args[@]}" "$@" diff --git a/custom/hm/programs/n8n.nix b/custom/hm/programs/n8n.nix new file mode 100644 index 0000000..041d0e3 --- /dev/null +++ b/custom/hm/programs/n8n.nix @@ -0,0 +1,114 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.programs.n8n; + + valToString = v: + if builtins.isBool v then (if v then "true" else "false") + else if builtins.isInt v then builtins.toString v + else if builtins.isPath v then builtins.toString v + else v; + + envList = + lib.mapAttrsToList (k: v: "${k}=${valToString v}") cfg.settings; + + extraArgsStr = + lib.optionalString (cfg.extraArgs != [ ]) (" " + lib.escapeShellArgs cfg.extraArgs); +in +{ + options.programs.n8n = { + enable = lib.mkEnableOption "n8n (user-level)"; + + package = lib.mkOption { + type = lib.types.package; + default = pkgs.n8n; + defaultText = "pkgs.n8n"; + description = "n8n package to run."; + }; + + dataDir = lib.mkOption { + type = lib.types.str; + default = "${config.xdg.dataHome}/n8n"; + description = "Working/data directory for n8n (contains sqlite and config state)."; + }; + + settings = lib.mkOption { + type = lib.types.attrsOf (lib.types.oneOf [ + lib.types.str + lib.types.int + lib.types.bool + lib.types.path + ]); + default = { }; + description = '' + Environment variables for n8n, e.g. { + N8N_HOST = "127.0.0.1"; + N8N_PORT = 5678; + N8N_PROTOCOL = "http"; + } + ''; + }; + + environmentFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; + default = null; + description = "Optional EnvironmentFile (systemd) for secrets, e.g. ~/.config/n8n/secrets.env"; + }; + + extraArgs = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + description = "Extra CLI args passed to `n8n`."; + }; + + service = { + enable = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Whether to create a systemd user service for n8n."; + }; + + wantedBy = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ "default.target" ]; + description = "Systemd user targets to hook the service into."; + }; + }; + }; + + config = lib.mkIf cfg.enable { + home.packages = [ cfg.package ]; + + # Ensure data dir exists (user tmpfiles) + systemd.user.tmpfiles.rules = [ + "d ${cfg.dataDir} 0700 - - -" + ]; + + systemd.user.services.n8n = lib.mkIf cfg.service.enable { + Unit = { + Description = "n8n automation (user)"; + After = [ "network-online.target" ]; + Wants = [ "network-online.target" ]; + }; + + Service = { + Type = "simple"; + WorkingDirectory = cfg.dataDir; + + ExecStart = "${cfg.package}/bin/n8n${extraArgsStr}"; + + # Env vars (non-secret) + Environment = envList; + + # Secrets via file (optional) + EnvironmentFile = lib.mkIf (cfg.environmentFile != null) cfg.environmentFile; + + Restart = "on-failure"; + RestartSec = "5s"; + }; + + Install = { + WantedBy = cfg.service.wantedBy; + }; + }; + }; +} diff --git a/custom/hm/services/default.nix b/custom/hm/services/default.nix new file mode 100644 index 0000000..07f9c5a --- /dev/null +++ b/custom/hm/services/default.nix @@ -0,0 +1,23 @@ +{ lib, ... }: +let + here = ./.; + entries = builtins.readDir here; + names = lib.attrNames entries; + + nixFiles = + builtins.filter + (n: entries.${n} == "regular" && lib.hasSuffix ".nix" n && n != "default.nix") + names; + + subdirDefaultNix = + builtins.filter + (d: entries.${d} == "directory" + && builtins.pathExists (here + "/${d}/default.nix")) + names; + +in +{ + imports = + (map (n: here + "/${n}") nixFiles) + ++ (map (d: here + "/${d}/default.nix") subdirDefaultNix); +} diff --git a/custom/hm/services/qdrant.nix b/custom/hm/services/qdrant.nix new file mode 100644 index 0000000..49d57d9 --- /dev/null +++ b/custom/hm/services/qdrant.nix @@ -0,0 +1,96 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.services.qdrant; + + configRelPath = ".config/qdrant/config.yaml"; + configPath = "${config.home.homeDirectory}/${configRelPath}"; + + defaultSettings = { + log_level = "INFO"; + service = { + host = "127.0.0.1"; + http_port = 6333; + grpc_port = 6334; + }; + storage = { + storage_path = "${cfg.dataDir}/storage"; + snapshots_path = "${cfg.dataDir}/snapshots"; + }; + }; + + effectiveSettings = lib.recursiveUpdate defaultSettings cfg.settings; + + yaml = pkgs.formats.yaml {}; + configFile = yaml.generate "qdrant-config.yaml" effectiveSettings; + + envList = lib.mapAttrsToList (k: v: "${k}=${toString v}") cfg.environment; + + extraArgsStr = + lib.concatStringsSep " " (map lib.escapeShellArg cfg.extraArgs); +in +{ + options.services.qdrant = { + enable = lib.mkEnableOption "Qdrant (user-level)"; + + package = lib.mkOption { + type = lib.types.package; + default = pkgs.qdrant; + }; + + dataDir = lib.mkOption { + type = lib.types.str; + default = "${config.home.homeDirectory}/.local/share/qdrant"; + }; + + # Мержится поверх defaultSettings + settings = lib.mkOption { + type = lib.types.attrs; + default = {}; + }; + + # Если нужно прокинуть QDRANT__... переменные (они имеют максимальный приоритет) + environment = lib.mkOption { + type = lib.types.attrsOf lib.types.str; + default = {}; + }; + + extraArgs = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = []; + }; + }; + + config = lib.mkIf cfg.enable { + home.packages = [ cfg.package ]; + + # symlink в ~/.config/qdrant/config.yaml -> nix store + home.file."${configRelPath}".source = configFile; + + # автоматический start/stop/restart при home-manager switch + systemd.user.startServices = "sd-switch"; # default true, но фиксируем явно :contentReference[oaicite:1]{index=1} + + systemd.user.services.qdrant = { + Unit = { + Description = "Qdrant (user)"; + After = [ "default.target" ]; + }; + + Service = { + ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p ${cfg.dataDir}/storage ${cfg.dataDir}/snapshots"; + ExecStart = "${cfg.package}/bin/qdrant --config-path ${configPath} ${extraArgsStr}"; + # WorkingDirectory = cfg.dataDir; + + Restart = "on-failure"; + RestartSec = 3; + + # ENV в формате ["K=V" ...] + Environment = envList; + }; + + Install = { + WantedBy = [ "default.target" ]; + }; + }; + }; +} diff --git a/custom/overlays/default.nix b/custom/overlays/default.nix new file mode 100644 index 0000000..27a89c2 --- /dev/null +++ b/custom/overlays/default.nix @@ -0,0 +1 @@ +final: prev: (import ../pkgs { pkgs = final; lib = prev.lib; }) diff --git a/custom/pkgs/by-name/an/anything-llm/default.nix b/custom/pkgs/by-name/an/anything-llm/default.nix new file mode 100644 index 0000000..87f9e9d --- /dev/null +++ b/custom/pkgs/by-name/an/anything-llm/default.nix @@ -0,0 +1,114 @@ +{ + lib, + stdenv, + fetchFromGitHub, + nodejs_20, + yarn, + fetchYarnDeps, + fixup-yarn-lock, + python3, + pkg-config, + # makeWrapper, + # openssl, + # sqlite, + vips, + vite, +}: + +let + pname = "anything-llm"; + version = "1.10.0"; + + src = fetchFromGitHub { + owner = "Mintplex-Labs"; + repo = "anything-llm"; + rev = "v${version}"; + hash = "sha256-W7wpgEJxo+IfIVRAWJNTmJL4RezO4NdlQEpV6dJp5IA="; + fetchSubmodules = true; + }; + + offlineCacheFrontend = fetchYarnDeps { + yarnLock = "${src}/frontend/yarn.lock"; + hash = "sha256-ebAV+1Ux4aL6hIodfaRVjEUFSWQplI7c7sybTEzucdw="; + }; + + offlineCacheServer = fetchYarnDeps { + yarnLock = "${src}/server/yarn.lock"; + hash = "sha256-+agJhFItPGLBUGLhhdNATiHuId51sDWQbG/Z1FyIVWM="; + }; +in +stdenv.mkDerivation { + inherit pname version src; + + nativeBuildInputs = [ + nodejs_20 + yarn + python3 + pkg-config + stdenv.cc # чтобы был компилятор/линкер + fixup-yarn-lock + vite + ]; + buildInputs = [ + vips + nodejs_20.dev + ]; + + # важно: чтобы sharp не пытался скачать vendor-libvips и не игнорировал системный + SHARP_FORCE_GLOBAL_LIBVIPS = "1"; # всегда пытаться использовать global libvips :contentReference[oaicite:0]{index=0} + npm_config_build_from_source = "sharp"; # просим sharp собираться из исходников :contentReference[oaicite:1]{index=1} + + configurePhase = '' + export HOME="$(mktemp -d)" + + pushd server + fixup-yarn-lock yarn.lock + yarn config --offline set yarn-offline-mirror "${offlineCacheServer}" + + # 1) ставим deps без postinstall'ов (иначе sharp полезет в сеть) + yarn install --offline --frozen-lockfile --ignore-scripts --no-progress + + # 2) теперь собираем sharp из исходников против system libvips + export PKG_CONFIG_PATH="${vips.dev}/lib/pkgconfig:${vips}/lib/pkgconfig:$PKG_CONFIG_PATH" + export LD_LIBRARY_PATH="${vips}/lib:$LD_LIBRARY_PATH" + export npm_config_nodedir="${nodejs_20.dev}" + + # yarn v1: rebuild прогоняет lifecycle для native-модулей + ${nodejs_20}/bin/npm rebuild sharp --build-from-source --nodedir="${nodejs_20.dev}" + popd + ''; + + postPatch = '' + # frontend: build without Qt/X11 postbuild + substituteInPlace frontend/package.json \ + --replace '"build": "vite build && node scripts/postbuild.js"' '"build": "vite build"' + ''; + + buildPhase = '' + runHook preBuild + (export QT_QPA_PLATFORM=offscreen QTWEBENGINE_DISABLE_SANDBOX=1 QTWEBENGINE_CHROMIUM_FLAGS="--headless --disable-gpu --no-sandbox" + cd frontend && yarn build) # --offline + # server/collector build steps, если нужны, добавите отдельно + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + mkdir -p $out/lib/${pname} $out/bin + cp -r frontend server collector $out/lib/${pname}/ + + makeWrapper ${nodejs_20}/bin/node $out/bin/anything-llm-server \ + --chdir $out/lib/${pname}/server \ + --set NODE_ENV production \ + --set-default PORT 3001 \ + --add-flags "index.js" + runHook postInstall + ''; + + meta = with lib; { + description = "AnythingLLM (server + frontend + collector)"; + homepage = "https://github.com/Mintplex-Labs/anything-llm"; + license = licenses.mit; + platforms = platforms.linux; + }; +} diff --git a/custom/pkgs/by-name/lm/lmstudio/default.nix b/custom/pkgs/by-name/lm/lmstudio/default.nix new file mode 100644 index 0000000..46d5ea3 --- /dev/null +++ b/custom/pkgs/by-name/lm/lmstudio/default.nix @@ -0,0 +1,82 @@ +{ + lib, + fetchurl, + appimageTools, + imagemagick, +}: + +let + pname = "lmstudio"; + version = "0.4.2-2"; + + url = "https://installers.lmstudio.ai/linux/x64/${version}/LM-Studio-${version}-x64.AppImage"; + + src = fetchurl { + inherit url; + hash = "sha256-JxGlqgsuLcW81mOIcntVFSHv19zSFouIChgz/egc+J0="; + }; + + contents = appimageTools.extractType2 { inherit pname version src; }; +in +appimageTools.wrapType2 { + inherit pname version src; + + nativeBuildInputs = [ imagemagick ]; + + extraInstallCommands = '' + set -euo pipefail + + mkdir -p "$out/share/applications" + mkdir -p "$out/share/icons/hicolor/256x256/apps" + + # ---- desktop: create fresh, never edit in place ---- + desktopSrc="$(find "${contents}" -type f -name '*.desktop' | head -n1 || true)" + if [ -n "$desktopSrc" ]; then + tmp="$(mktemp)" + + # Rewrite keys deterministically; keep everything else. + awk -v exec="${pname}" -v icon="${pname}" ' + BEGIN{hasExec=0;hasTry=0;hasIcon=0} + /^Exec=/{print "Exec="exec; hasExec=1; next} + /^TryExec=/{print "TryExec="exec; hasTry=1; next} + /^Icon=/{print "Icon="icon; hasIcon=1; next} + {print} + END{ + if(!hasExec) print "Exec="exec + if(!hasTry) print "TryExec="exec + if(!hasIcon) print "Icon="icon + } + ' "$desktopSrc" > "$tmp" + + rm -f "$out/share/applications/${pname}.desktop" + install -m444 "$tmp" "$out/share/applications/${pname}.desktop" + rm -f "$tmp" + fi + + # ---- icon: pick one, convert to canonical name ---- + icon="" + for cand in \ + "${contents}/.DirIcon" \ + "${contents}/AppIcon.png" \ + "${contents}/usr/share/icons/hicolor/512x512/apps/"*.png \ + "${contents}/usr/share/icons/hicolor/256x256/apps/"*.png \ + ; do + if [ -f "$cand" ]; then icon="$cand"; break; fi + done + if [ -z "$icon" ]; then + icon="$(find "${contents}" -type f -name '*.png' | head -n1 || true)" + fi + + if [ -n "$icon" ]; then + magick "$icon" -resize 256x256 "$out/share/icons/hicolor/256x256/apps/${pname}.png" + fi + ''; + + meta = with lib; { + description = "LM Studio (AppImage)"; + homepage = "https://lmstudio.ai/"; + license = licenses.unfreeRedistributable; + platforms = [ "x86_64-linux" ]; + mainProgram = pname; + }; +} diff --git a/custom/pkgs/by-name/st/stable-diffusion-cpp/default.nix b/custom/pkgs/by-name/st/stable-diffusion-cpp/default.nix new file mode 100644 index 0000000..73b5e95 --- /dev/null +++ b/custom/pkgs/by-name/st/stable-diffusion-cpp/default.nix @@ -0,0 +1,120 @@ +{ + description = "stable-diffusion.cpp as a NixOS programs.* module (system nixpkgs)"; + + outputs = { self, ... }: { + nixosModules.default = { config, lib, pkgs, ... }: + let + cfg = config.programs.stable-diffusion-cpp; + + builtPackage = + pkgs.stdenv.mkDerivation { + pname = "stable-diffusion-cpp"; + version = "git"; + + src = pkgs.fetchFromGitHub { + owner = "leejet"; + repo = "stable-diffusion.cpp"; + rev = "master-453-4ff2c8c"; # pin to a commit for reproducibility + hash = "sha256-0Hl3M6NQK1ZfIH4eIdy/XiPZTeBCnRCtode88NipPp4="; + fetchSubmodules = true; + }; + + nativeBuildInputs = with pkgs; [ cmake ninja pkg-config ]; + + buildInputs = + (lib.optionals cfg.vulkan.enable (with pkgs; [ + vulkan-headers + vulkan-loader + shaderc + ])); + + cmakeFlags = [ + "-DCMAKE_BUILD_TYPE=Release" + "-DCMAKE_POLICY_VERSION_MINIMUM=3.5" + "-DSD_VULKAN=${if cfg.vulkan.enable then "ON" else "OFF"}" + ]; + + installPhase = '' + runHook preInstall + mkdir -p $out/bin + cp -v bin/sd $out/bin/ || cp -v sd $out/bin/ + runHook postInstall + ''; + }; + + selectedPackage = if cfg.package != null then cfg.package else builtPackage; + + extraEnvArgs = + lib.concatStringsSep " \\\n " + (lib.mapAttrsToList (k: v: + "--set ${lib.escapeShellArg k} ${lib.escapeShellArg v}" + ) cfg.extraEnv); + + wrappedPackage = + pkgs.symlinkJoin { + name = "${selectedPackage.pname or "stable-diffusion-cpp"}"; + paths = [ selectedPackage ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + if [ -x "$out/bin/sd" ]; then + wrapProgram "$out/bin/sd" \ + ${lib.optionalString (cfg.vulkan.enable && cfg.vulkan.icdFile != null) + "--set-default VK_ICD_FILENAMES ${lib.escapeShellArg (toString cfg.vulkan.icdFile)}"} \ + ${lib.optionalString (cfg.vulkan.enable && cfg.vulkan.prefixOpenGLXdgDataDirs) + "--prefix XDG_DATA_DIRS : /run/opengl-driver/share"} \ + ${extraEnvArgs} + fi + ''; + }; + + finalPackage = if cfg.wrap then wrappedPackage else selectedPackage; + in { + options.programs.stable-diffusion-cpp = { + enable = lib.mkEnableOption "stable-diffusion.cpp"; + + package = lib.mkOption { + type = lib.types.nullOr lib.types.package; + default = null; + description = "Override the package used (otherwise build from upstream source)."; + }; + + wrap = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Wrap the sd binary to inject environment variables."; + }; + + extraEnv = lib.mkOption { + type = lib.types.attrsOf lib.types.str; + default = { }; + description = "Extra environment variables added to the sd wrapper."; + }; + + vulkan = { + enable = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Build with Vulkan support (toggles -DSD_VULKAN and Vulkan deps)."; + }; + + icdFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; + default = null; + example = /run/opengl-driver/share/vulkan/icd.d/intel_icd.x86_64.json; + description = "Optional VK_ICD_FILENAMES value to select a Vulkan ICD."; + }; + + prefixOpenGLXdgDataDirs = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Prefix XDG_DATA_DIRS with /run/opengl-driver/share (useful for Vulkan layers/ICDs on NixOS)."; + }; + }; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ finalPackage ]; + }; + }; + }; +} diff --git a/custom/pkgs/default.nix b/custom/pkgs/default.nix new file mode 100644 index 0000000..bbed60d --- /dev/null +++ b/custom/pkgs/default.nix @@ -0,0 +1,25 @@ +{ pkgs, lib, ... }: +let + byName = ./by-name; + + dirs = path: + lib.attrNames (lib.filterAttrs (_: t: t == "directory") (builtins.readDir path)); + + packagesFromByName = base: + lib.foldl' (acc: shorthand: + let + shorthandDir = base + "/${shorthand}"; + names = dirs shorthandDir; + addOne = name: + let + pkgDir = shorthandDir + "/${name}"; + def = pkgDir + "/default.nix"; + in + if builtins.pathExists def + then { ${name} = pkgs.callPackage pkgDir { }; } + else { }; + in + acc // lib.foldl' (a: n: a // addOne n) { } names + ) { } (dirs base); +in +packagesFromByName byName diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..af56449 --- /dev/null +++ b/flake.lock @@ -0,0 +1,1110 @@ +{ + "nodes": { + "agenix": { + "inputs": { + "darwin": "darwin", + "home-manager": "home-manager_4", + "nixpkgs": [ + "ragenix", + "nixpkgs" + ], + "systems": "systems_6" + }, + "locked": { + "lastModified": 1736955230, + "narHash": "sha256-uenf8fv2eG5bKM8C/UvFaiJMZ4IpUFaQxk9OH5t/1gA=", + "owner": "ryantm", + "repo": "agenix", + "rev": "e600439ec4c273cf11e06fe4d9d906fb98fa097c", + "type": "github" + }, + "original": { + "owner": "ryantm", + "repo": "agenix", + "type": "github" + } + }, + "classified": { + "inputs": { + "flake-utils": "flake-utils_2", + "naersk": "naersk", + "nixpkgs": [ + "intel-hw", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1764756337, + "narHash": "sha256-XX4dxkM0ucoqgavjn78XLrXCrdv+RD4ZZvwZVfvr5ds=", + "owner": "GoldsteinE", + "repo": "classified", + "rev": "3bb7e22be468efc5a3c1b232d92a41a5a8c33ac0", + "type": "github" + }, + "original": { + "owner": "GoldsteinE", + "repo": "classified", + "type": "github" + } + }, + "comoji": { + "inputs": { + "nixpkgs": [ + "intel-hw", + "nixpkgs" + ], + "utils": "utils" + }, + "locked": { + "lastModified": 1720509565, + "narHash": "sha256-yZ0yj6jzLtaaAuJgphoBQOJytxwOysHhZ/qJLf4KDJ0=", + "owner": "MordragT", + "repo": "comoji", + "rev": "beb26945a125a08c6ed68bd1fa3dee609e9410db", + "type": "github" + }, + "original": { + "owner": "MordragT", + "repo": "comoji", + "type": "github" + } + }, + "cosmic-unstable": { + "inputs": { + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1767324719, + "narHash": "sha256-RD1IR25udmtmTIPfocuhuIzOK2C+M9nhTQ3mEfARECo=", + "owner": "ninelore", + "repo": "nixpkgs-cosmic-unstable", + "rev": "063c9631e355f6143f36f375aa2f96f7c22fdb0b", + "type": "github" + }, + "original": { + "owner": "ninelore", + "repo": "nixpkgs-cosmic-unstable", + "type": "github" + } + }, + "crane": { + "locked": { + "lastModified": 1766774972, + "narHash": "sha256-8qxEFpj4dVmIuPn9j9z6NTbU+hrcGjBOvaxTzre5HmM=", + "owner": "ipetkov", + "repo": "crane", + "rev": "01bc1d404a51a0a07e9d8759cd50a7903e218c82", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "crane_2": { + "locked": { + "lastModified": 1741481578, + "narHash": "sha256-JBTSyJFQdO3V8cgcL08VaBUByEU6P5kXbTJN6R0PFQo=", + "owner": "ipetkov", + "repo": "crane", + "rev": "bb1c9567c43e4434f54e9481eb4b8e8e0d50f0b5", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "darwin": { + "inputs": { + "nixpkgs": [ + "ragenix", + "agenix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1700795494, + "narHash": "sha256-gzGLZSiOhf155FW7262kdHo2YDeugp3VuIFb4/GGng0=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "4b9b83d5a92e8c1fbfd8eb27eda375908c11ec4d", + "type": "github" + }, + "original": { + "owner": "lnl7", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, + "disko": { + "inputs": { + "nixpkgs": [ + "intel-hw", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1766150702, + "narHash": "sha256-P0kM+5o+DKnB6raXgFEk3azw8Wqg5FL6wyl9jD+G5a4=", + "owner": "nix-community", + "repo": "disko", + "rev": "916506443ecd0d0b4a0f4cf9d40a3c22ce39b378", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, + "dw-proton": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1770872764, + "narHash": "sha256-n9/S8Y1HY6wr8hYGyq7ySuJB2KdF2kyWho+ofBLfvmA=", + "owner": "imaviso", + "repo": "dwproton-flake", + "rev": "dd410d71c5ea1baa0ffff2686676d20d1f671893", + "type": "github" + }, + "original": { + "owner": "imaviso", + "repo": "dwproton-flake", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "intel-hw", + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1767250179, + "narHash": "sha256-PnQdWvPZqHp+7yaHWDFX3NYSKaOy0fjkwpR+rIQC7AY=", + "owner": "nix-community", + "repo": "fenix", + "rev": "a3eaf682db8800962943a77ab77c0aae966f9825", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "monthly", + "repo": "fenix", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1761588595, + "narHash": "sha256-XKUZz9zewJNUj46b4AJdiRZJAvSZ0Dqj2BNfXvFlJC4=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1761588595, + "narHash": "sha256-XKUZz9zewJNUj46b4AJdiRZJAvSZ0Dqj2BNfXvFlJC4=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "intel-hw", + "nur", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733312601, + "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_7" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "ghostty": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "home-manager": "home-manager", + "nixpkgs": "nixpkgs_2", + "zig": "zig", + "zon2nix": "zon2nix" + }, + "locked": { + "lastModified": 1770888240, + "narHash": "sha256-FwF56DWjzQfWaQrQR61JkvpkYlu8lEWulXoK9sLVtTk=", + "owner": "ghostty-org", + "repo": "ghostty", + "rev": "2868677af50af301ebe4ec1c7f79ad31dcd67cd3", + "type": "github" + }, + "original": { + "owner": "ghostty-org", + "ref": "tip", + "repo": "ghostty", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "intel-hw", + "lanzaboote", + "pre-commit", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "ghostty", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1770586272, + "narHash": "sha256-Ucci8mu8QfxwzyfER2DQDbvW9t1BnTUJhBmY7ybralo=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "b1f916ba052341edc1f80d4b2399f1092a4873ca", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1770818644, + "narHash": "sha256-DYS4jIRpRoKOzJjnR/QqEd/MlT4OZZpt8CrBLv+cjsE=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "0acbd1180697de56724821184ad2c3e6e7202cd7", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager_3": { + "inputs": { + "nixpkgs": [ + "intel-hw", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1767104570, + "narHash": "sha256-GKgwu5//R+cLdKysZjGqvUEEOGXXLdt93sNXeb2M/Lk=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "e4e78a2cbeaddd07ab7238971b16468cc1d14daf", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager_4": { + "inputs": { + "nixpkgs": [ + "ragenix", + "agenix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703113217, + "narHash": "sha256-7ulcXOk63TIT2lVDSExj7XzFx09LpdSAPtvgtM7yQPE=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "3bfaacf46133c037bb356193bd2f1765d9dc82c1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "intel-hw": { + "inputs": { + "classified": "classified", + "comoji": "comoji", + "cosmic-unstable": "cosmic-unstable", + "disko": "disko", + "fenix": "fenix", + "home-manager": "home-manager_3", + "lanzaboote": "lanzaboote", + "nixpkgs": "nixpkgs_4", + "nu-env": "nu-env", + "nur": "nur", + "templates": "templates", + "valhali": "valhali" + }, + "locked": { + "lastModified": 1767389413, + "narHash": "sha256-3l9DWMTIaVUC++5l2oSBZYP86QYjFusD7J3BqivPRZk=", + "owner": "MordragT", + "repo": "nixos", + "rev": "999ab929a2073cd4b1a72fa8944743de19d4c41b", + "type": "github" + }, + "original": { + "owner": "MordragT", + "repo": "nixos", + "type": "github" + } + }, + "lanzaboote": { + "inputs": { + "crane": "crane", + "nixpkgs": [ + "intel-hw", + "nixpkgs" + ], + "pre-commit": "pre-commit", + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1767013031, + "narHash": "sha256-p8ANXBakAtfX/aEhLbU6w0tuQe3nrBvLdHbKirJP7ug=", + "owner": "nix-community", + "repo": "lanzaboote", + "rev": "c2a82339373daee8cbbcad5f51f22ae6b71069e0", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "lanzaboote", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": [ + "intel-hw", + "classified", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1739824009, + "narHash": "sha256-fcNrCMUWVLMG3gKC5M9CBqVOAnJtyRvGPxptQFl5mVg=", + "owner": "nix-community", + "repo": "naersk", + "rev": "e5130d37369bfa600144c2424270c96f0ef0e11d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "niri": { + "inputs": { + "nixpkgs": "nixpkgs_7", + "rust-overlay": "rust-overlay_2" + }, + "locked": { + "lastModified": 1764399944, + "narHash": "sha256-FC9eYtSmplgxllCX4/3hJq5J3sXWKLSc7at8ZUxycVw=", + "owner": "YaLTeR", + "repo": "niri", + "rev": "b35bcae35b3f9665043c335e55ed5828af77db85", + "type": "github" + }, + "original": { + "owner": "YaLTeR", + "ref": "v25.11", + "repo": "niri", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1752687322, + "narHash": "sha256-RKwfXA4OZROjBTQAl9WOZQFm7L8Bo93FQwSJpAiSRvo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6e987485eb2c77e5dcc5af4e3c70843711ef9251", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1770537093, + "narHash": "sha256-XV30uo8tXuxdzuV8l3sojmlPRLd/8tpMsOp4lNzLGUo=", + "rev": "fef9403a3e4d31b0a23f0bacebbec52c248fbb51", + "type": "tarball", + "url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.05pre942631.fef9403a3e4d/nixexprs.tar.xz" + }, + "original": { + "type": "tarball", + "url": "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1767116409, + "narHash": "sha256-5vKw92l1GyTnjoLzEagJy5V5mDFck72LiQWZSOnSicw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "cad22e7d996aea55ecab064e84834289143e44a0", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1767116409, + "narHash": "sha256-5vKw92l1GyTnjoLzEagJy5V5mDFck72LiQWZSOnSicw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "cad22e7d996aea55ecab064e84834289143e44a0", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1767116409, + "narHash": "sha256-5vKw92l1GyTnjoLzEagJy5V5mDFck72LiQWZSOnSicw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "cad22e7d996aea55ecab064e84834289143e44a0", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_6": { + "locked": { + "lastModified": 1757584362, + "narHash": "sha256-XeTX/w16rUNUNBsfaOVCDoMMa7Xu7KvIMT7tn1zIEcg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d33e926c80e6521a55da380a4c4c44a7462af405", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_7": { + "locked": { + "lastModified": 1757967192, + "narHash": "sha256-/aA9A/OBmnuOMgwfzdsXRusqzUpd8rQnQY8jtrHK+To=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0d7c15863b251a7a50265e57c1dca1a7add2e291", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_8": { + "locked": { + "lastModified": 1770562336, + "narHash": "sha256-ub1gpAONMFsT/GU2hV6ZWJjur8rJ6kKxdm9IlCT0j84=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d6c71932130818840fc8fe9509cf50be8c64634f", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_9": { + "locked": { + "lastModified": 1741379970, + "narHash": "sha256-Wh7esNh7G24qYleLvgOSY/7HlDUzWaL/n4qzlBePpiw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "36fd87baa9083f34f7f5027900b62ee6d09b1f2f", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nu-env": { + "inputs": { + "nixpkgs": [ + "intel-hw", + "nixpkgs" + ], + "utils": "utils_2" + }, + "locked": { + "lastModified": 1761290947, + "narHash": "sha256-AOOalZPOCh8uFVcs8qxyVeq7P+tfXxCs/aU8o+7uuSo=", + "owner": "MordragT", + "repo": "nu-env", + "rev": "ae30257182842068d97481f8fbbe850ca623b10f", + "type": "github" + }, + "original": { + "owner": "MordragT", + "repo": "nu-env", + "type": "github" + } + }, + "nur": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "lastModified": 1767367154, + "narHash": "sha256-D7q0hcj+X0hesIhkDksvuyXbHagkGhfci+fV15wGwWM=", + "owner": "nix-community", + "repo": "NUR", + "rev": "c87d1f269298544231967f0e8f614333cf93b923", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "NUR", + "type": "github" + } + }, + "pre-commit": { + "inputs": { + "flake-compat": "flake-compat_2", + "gitignore": "gitignore", + "nixpkgs": [ + "intel-hw", + "lanzaboote", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1765911976, + "narHash": "sha256-t3T/xm8zstHRLx+pIHxVpQTiySbKqcQbK+r+01XVKc0=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "b68b780b69702a090c8bb1b973bab13756cc7a27", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "ragenix": { + "inputs": { + "agenix": "agenix", + "crane": "crane_2", + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_9", + "rust-overlay": "rust-overlay_3" + }, + "locked": { + "lastModified": 1741508717, + "narHash": "sha256-iQf1WdNxaApOFHIx4RLMRZ4f8g+8Xp0Z1/E/Mz2rLxY=", + "owner": "yaxitech", + "repo": "ragenix", + "rev": "2a2bea99d74927e54adf53cbf113219def67d5c9", + "type": "github" + }, + "original": { + "owner": "yaxitech", + "ref": "2025.03.09", + "repo": "ragenix", + "type": "github" + } + }, + "root": { + "inputs": { + "dw-proton": "dw-proton", + "ghostty": "ghostty", + "home-manager": "home-manager_2", + "intel-hw": "intel-hw", + "niri": "niri", + "nixpkgs": "nixpkgs_8", + "ragenix": "ragenix" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1767191410, + "narHash": "sha256-cCZGjubgDWmstvFkS6eAw2qk2ihgWkycw55u2dtLd70=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "a9026e6d5068172bf5a0d52a260bb290961d1cb4", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "intel-hw", + "lanzaboote", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1766976750, + "narHash": "sha256-w+o3AIBI56tzfMJRqRXg9tSXnpQRN5hAT15o2t9rxYw=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "9fe44e7f05b734a64a01f92fc51ad064fb0a884f", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_2": { + "inputs": { + "nixpkgs": [ + "niri", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1757989933, + "narHash": "sha256-9cpKYWWPCFhgwQTww8S94rTXgg8Q8ydFv9fXM6I8xQM=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "8249aa3442fb9b45e615a35f39eca2fe5510d7c3", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_3": { + "inputs": { + "nixpkgs": [ + "ragenix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1741400194, + "narHash": "sha256-tEpgT+q5KlGjHSm8MnINgTPErEl8YDzX3Eps8PVc09g=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "16b6045a232fea0e9e4c69e55a6e269607dd8e3f", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_5": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_6": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_7": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "templates": { + "inputs": { + "nixpkgs": "nixpkgs_6" + }, + "locked": { + "lastModified": 1757668691, + "narHash": "sha256-u2wObcXReO6+4xPFuqa2xewizOLPyA9YhIKQ4+iR+W4=", + "owner": "MordragT", + "repo": "nix-templates", + "rev": "322aef20cabb300e05692a444b172ff8c421f524", + "type": "github" + }, + "original": { + "owner": "MordragT", + "repo": "nix-templates", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "utils_2": { + "inputs": { + "systems": "systems_4" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "utils_3": { + "inputs": { + "systems": "systems_5" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "valhali": { + "inputs": { + "nixpkgs": [ + "intel-hw", + "nixpkgs" + ], + "utils": "utils_3" + }, + "locked": { + "lastModified": 1739726009, + "narHash": "sha256-bkpAPGVW8ovf1wHHABGu8tASQxUxWFKpZVQeRhnPOJo=", + "owner": "MordragT", + "repo": "valhali", + "rev": "0e30d664b2e9c9d42145ddcb6f2723a49c4496c1", + "type": "github" + }, + "original": { + "owner": "MordragT", + "repo": "valhali", + "type": "github" + } + }, + "zig": { + "inputs": { + "flake-compat": [ + "ghostty", + "flake-compat" + ], + "flake-utils": [ + "ghostty", + "flake-utils" + ], + "nixpkgs": [ + "ghostty", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1763295135, + "narHash": "sha256-sGv/NHCmEnJivguGwB5w8LRmVqr1P72OjS+NzcJsssE=", + "owner": "mitchellh", + "repo": "zig-overlay", + "rev": "64f8b42cfc615b2cf99144adf2b7728c7847c72a", + "type": "github" + }, + "original": { + "owner": "mitchellh", + "repo": "zig-overlay", + "type": "github" + } + }, + "zon2nix": { + "inputs": { + "nixpkgs": [ + "ghostty", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1768231828, + "narHash": "sha256-wL/8Iij4T2OLkhHcc4NieOjf7YeJffaUYbCiCqKv/+0=", + "owner": "jcollie", + "repo": "zon2nix", + "rev": "c28e93f3ba133d4c1b1d65224e2eebede61fd071", + "type": "github" + }, + "original": { + "owner": "jcollie", + "repo": "zon2nix", + "rev": "c28e93f3ba133d4c1b1d65224e2eebede61fd071", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6b369f3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,260 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + ragenix.url = "github:yaxitech/ragenix/2025.03.09"; + niri.url = "github:YaLTeR/niri/v25.11"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + ghostty.url = "github:ghostty-org/ghostty/tip"; + # ghostty.url = [ + # "github:ghostty-org/ghostty/1.3.0" + # "github:ghostty-org/ghostty/tip" + # ]; + dw-proton.url = "github:imaviso/dwproton-flake"; + intel-hw.url = "github:MordragT/nixos"; + # + }; + outputs = + inputs@{ + # self, + nixpkgs, + ragenix, + home-manager, + ghostty, + intel-hw, + ... + }: + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + in + { + devShells.${system}.default = pkgs.mkShell { + packages = [ + ragenix.packages.x86_64-linux.default + ]; + }; + nixosConfigurations.testenv = nixpkgs.lib.nixosSystem { + inherit system; + # + specialArgs = { inherit inputs; }; + modules = [ + ragenix.nixosModules.default + ( + { + pkgs, + pkgdefault, + ... + }: + { + _module.args = { + pkgdefault = pkg: pkg.packages.${pkgs.stdenv.hostPlatform.system}.default; + }; + nixpkgs.overlays = [ + intel-hw.overlays.default + (import ./custom/overlays) + (final: prev: { + llama-cpp = prev.llama-cpp.overrideAttrs (old: { + src = prev.fetchFromGitHub { + owner = "ggml-org"; + repo = "llama.cpp"; + tag = "b7897"; + hash = "sha256-cc2tqEQEZCBEOQ+xJzmVK8ROjfsWOi6T2iX3KjpaAIU="; + }; + nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.curl ]; + }); + pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ + (pyFinal: pyPrev: { + haystack-ai = pyPrev.haystack-ai.overridePythonAttrs (old: rec { + version = "2.23.0"; + + src = final.fetchFromGitHub { + owner = "deepset-ai"; + repo = "haystack"; + rev = "v${version}"; + hash = "sha256-KFgRKdhbHgjtpiuAeFq+0t0EUKKLOavbVplb0QnI/r8="; + }; + + propagatedBuildInputs = + old.propagatedBuildInputs + ++ (with pyPrev; [ + docstring-parser + filetype + haystack-experimental # ./custom/pkgs/by-category/python3Packages/ha/haystack-experimental/default.nix + jinja2 + openai + ]); + + meta = (old.meta or { }) // { + broken = false; + }; + }); + }) + ]; + winetricks = prev.winetricks.overrideAttrs ( + old: + let + version = "20260125"; + in + { + inherit version; + + src = final.fetchurl { + url = "https://github.com/Winetricks/winetricks/archive/refs/tags/${version}.tar.gz"; + hash = "sha256-KJC9n7ut5GOOWLSZmiNycxkt8DtYUWrnuHceCcItL1Y="; + }; + } + ); + }) + ]; + hardware = { + graphics = { + enable = true; + extraPackages = ( + with pkgs; + [ + intel-media-driver + intel-ocl + vpl-gpu-rt + intel-compute-runtime + ] + ); + # ++ (with inputs.intel-hw.packages."${system}"; [ + # # oneapi-dal + # # oneapi-dpl + # # oneapi-ccl + # ]); + # enable32Bit = true; + }; + enableRedistributableFirmware = true; + }; + nix.settings = { + # keep-logs = true; + trusted-users = [ + "root" + "thek0tyara" + ]; + download-buffer-size = 160000000; + }; + age = { + secrets = { + "wg/syscon0.key".file = ./secrets/wg/syscon0.key.age; + "github/token.ro.age" = { + file = ./secrets/github/token.ro.age; + owner = "root"; + group = "wheel"; + mode = "0440"; + }; + }; + identityPaths = [ "/root/.ssh/id_ed25519" ]; + }; + environment = { + sessionVariables = { + LIBVA_DRIVER_NAME = "iHD"; + + LLAMA_CACHE = "/home/thek0tyara/Downloads/llm"; + + CCACHE_DIR = "/mnt/HDD_A_DATA/ccache"; + # LLVM = "1"; + + # UV_CACHE_DIR = ""; + # PIP_CACHE_DIR = ""; + # PYTHONPYCACHEPREFIX = ""; + }; + systemPackages = with pkgs; [ + ccache + sccache + (pkgdefault inputs.ragenix) + devenv + htop + + # gpu + vulkan-tools + libva-utils + intel-gpu-tools + pciutils + inxi + mesa-demos + + # xwayland + xhost + + # llm + # llama-cpp-vulkan + + git + nixpkgs-fmt + nixd + nil # apple-cursor + android-tools + ]; + }; + security.polkit = { + enable = true; + }; + programs = { + # amnezia-vpn.enable = true; + ccache.enable = true; + nix-ld = { + enable = true; + libraries = with pkgs; [ + stdenv.cc.cc.lib + ]; + }; + obs-studio.enableVirtualCamera = true; + steam = { + enable = true; + extraCompatPackages = [ + inputs.dw-proton.packages.${system}.dw-proton + ]; + }; + traceroute.enable = true; + ydotool = { + enable = true; + group = "wheel"; + }; + }; + services = { + displayManager = { + enable = true; + defaultSession = "niri"; + }; + locate.enable = true; + pipewire = { + enable = true; + pulse.enable = true; + }; + xserver = { + enable = true; + displayManager.lightdm.enable = true; + + xkb = { + layout = "us,ru"; + options = "grp:alt_shift_toggle"; + }; + }; + }; + } + ) + ./configuration.nix + # + home-manager.nixosModules.default + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + + extraSpecialArgs = { + inherit system; + inherit ghostty; + }; + + users.thek0tyara = ./home.nix; + }; + } + ]; + }; + }; +} diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 0000000..95f4d17 --- /dev/null +++ b/hardware-configuration.nix @@ -0,0 +1,33 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-label/NVME_NIXOS"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-label/NVME_ESP"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + swapDevices = + [{ device = "/dev/disk/by-label/NVME_SWAP"; } + ]; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..a8adc55 --- /dev/null +++ b/home.nix @@ -0,0 +1,454 @@ +{ + config, + pkgs, + system, + ghostty, + ... +}: +# let +# vesktopNoFuses = pkgs.vesktop.overrideAttrs (old: { +# nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.jq ]; +# postPatch = (old.postPatch or "") + '' +# tmp="$(mktemp)" +# jq 'del(.build.electronFuses)' package.json > "$tmp" +# mv "$tmp" package.json +# ''; +# }); +# in +{ + imports = [ + ./custom/hm + ]; + + gtk = { + enable = true; + colorScheme = "dark"; + theme = { + name = "Adwaita-dark"; + package = pkgs.gnome-themes-extra; + }; + iconTheme = { + name = "Papirus-Dark"; + package = pkgs.papirus-icon-theme; + }; + cursorTheme = { + name = "macOS"; + package = pkgs.apple-cursor; + size = 28; + }; + }; + home = { + stateVersion = "25.11"; + + pointerCursor = { + enable = true; + gtk.enable = true; + x11 = { + enable = true; + # defaultCursor = ""; + }; + dotIcons.enable = true; + package = pkgs.apple-cursor; + name = "macOS"; + size = 26; + }; + shell = { + enableFishIntegration = true; + }; + packages = with pkgs; [ + vlc + prismlauncher + jq + xfce4-taskmanager + gparted + python312Packages.huggingface-hub + tor-browser + winetricks + wineWowPackages.full + iperf + sshuttle + + lmstudio + + dig + libnotify + + # kdePackages.kdenlive + python312 + + # python314Packages.haystack-ai # TODO + # anything-llm + + ### NEVER USE THIS GARBAGE + # flowblade pitivi koboldcpp + ]; + sessionVariables = { + DESKTOP = ":0"; + OLLAMA_HOST = "10.20.0.201:11434"; + }; + }; + xdg = { + mimeApps = { + enable = true; + defaultApplications = { + "text/html" = "firefox.desktop"; + "x-scheme-handler/http" = "firefox.desktop"; + "x-scheme-handler/https" = "firefox.desktop"; + + "x-scheme-handler/tg" = "org.telegram.desktop.desktop"; + + "x-scheme-handler/discord" = "vesktop.desktop"; + + "image/jpeg" = "swayimg.desktop"; + "image/png" = "swayimg.desktop"; + "image/webp" = "swayimg.desktop"; + }; + }; + configFile."obsidian/.keep".text = ""; + }; + systemd.user = { + startServices = "sd-switch"; + services = { + prepare2watch = { + Unit = { + Description = "prepare videos to get later"; + }; + Service = { + Type = "oneshot"; + WorkingDirectory = "${config.home.homeDirectory}/Downloads/1/"; + ExecStart = '' + ${pkgs.util-linux}/bin/flock -n %t/prepare2watch.lock ${pkgs.fish}/bin/fish ./prepare2watch.fish + ''; + }; + }; + }; + paths = { + prepare2watch = { + Unit = { + Description = "Watch ${config.home.homeDirectory}/Downloads/1/list"; + }; + Path = { + PathChanged = "${config.home.homeDirectory}/Downloads/1/list"; + PathModified = "${config.home.homeDirectory}/Downloads/1/list"; + Unit = "prepare2watch.service"; + }; + Install = { + WantedBy = [ "default.target" ]; + }; + }; + }; + }; + services = { + ollama = { + # enable = true; + # acceleration = vulkan; + package = pkgs.ollama-vulkan; + host = "10.20.0.201"; + environmentVariables = { + OLLAMA_MAX_LOADED_MODELS = "1"; + OLLAMA_NUM_PARALLEL = "1"; + OLLAMA_FLASH_ATTENTION = "1"; + OLLAMA_KV_CACHE_TYPE = "q8_0"; + # OLLAMA_CONTEXT_LENGTH = "16000"; + OLLAMA_MODELS = "/home/thek0tyara/Downloads/llm/ollama"; + }; + }; + polkit-gnome.enable = true; + qdrant = { + enable = true; + dataDir = "/mnt/HDD_A_DATA/services/lib/qdrant"; + settings = { + storage = { + # storage_path = "/mnt/HDD_A_DATA/services/lib/qdrant/storage"; + # snapshots_path = "/mnt/HDD_A_DATA/services/lib/qdrant/snapshots"; + hnsw_index = { + on_disk = true; + }; + }; + service = { + host = "127.0.0.1"; + http_port = 6333; + grpc_port = 6334; + }; + telemetry_disabled = true; + }; + }; + }; + programs = { + ### custom + n8n = { + # enable = true; + settings = { + N8N_HOST = "127.0.0.1"; + N8N_PORT = 5678; + N8N_PROTOCOL = "http"; + }; + # environmentFile = ~/.config/n8n/secrets.env; + # extraArgs = [ ]; + }; + llama-cpp = { + # enable = true; + package = pkgs.llama-cpp.override { + vulkanSupport = true; + rpcSupport = true; + }; + defaultArgs = [ + "--host" + "127.0.0.1" + "--port" + "8080" + "--jinja" + "-fa" + "on" + ]; + # eosStrings = [ "<|im_end|>" ]; + presets = [ + { + name = "codegeex4"; + path = "/home/thek0tyara/Downloads/llm/codegeex4-all-9b.Q8_0.gguf"; + eosStrings = [ "<|im_end|>" ]; + } + ]; + }; + opencode = { + enable = true; + settings = { + compaction = { + auto = true; + prune = true; + }; + watcher = { + ignore = [ + ".git/**" + ]; + }; + + plugin = [ + "@zenobius/opencode-skillful" # lazy load + ]; + + default_agent = "plan"; + + tools = { + skill = false; + "qdrant_*" = false; + }; + + mcp = { + qdrant = { + type = "local"; + command = [ + "${pkgs.uv}/bin/uvx" + "-qq" + "mcp-server-qdrant" + ]; + enabled = true; + timeout = 5000; + environment = { + QDRANT_URL = "http://127.0.0.1:6333"; + COLLECTION_NAME = "opencode_memory"; + + # Debug only: + # FASTMCP_LOG_LEVEL = "DEBUG"; + # FASTMCP_DEBUG = "true"; + }; + }; + }; + + # Agents: features retained, but only injected when invoked + agent = { + plan = { + mode = "primary"; + tools = { + write = false; + edit = false; + bash = false; + skill = false; + "qdrant_*" = false; + }; + }; + + build = { + mode = "primary"; + tools = { + write = true; + edit = true; + bash = true; + skill = false; + "qdrant_*" = false; + }; + }; + + memory = { + mode = "subagent"; + description = "Opt-in semantic memory via Qdrant MCP"; + tools = { + "qdrant_*" = true; + }; + }; + + skills = { + mode = "subagent"; + description = "Opt-in skills tool"; + tools = { + skill = true; + }; + }; + }; + + theme = "opencode"; + autoupdate = false; + share = "manual"; + + server = { + port = 4096; + hostname = "127.0.0.1"; + }; + provider = { + "ollama" = { + npm = "@ai-sdk/openai-compatible"; + name = "Ollama (local)"; + options = { + baseURL = "http://10.20.0.201:11434/v1"; + }; + models = { + "qwen2.5-coder:7b" = { + name = "qwen2.5-coder"; + }; + "qwen3:8b" = { + name = "qwen3"; + }; + }; + }; + }; + }; + rules = '' + # Global rules (thin) + - Prefer on-demand file loading over preloading large docs. + - Use MCP/skills only via dedicated subagents. + ''; + }; + ### default + aria2.enable = true; + btop.enable = true; + command-not-found.enable = true; + direnv.enable = true; + eza = { + enable = true; + git = true; + icons = "auto"; + }; + fastfetch.enable = true; + firefox = { + enable = true; + package = pkgs.firefox; + languagePacks = [ "en-US" ]; + }; + fish = { + enable = true; + functions = { + fish_greeting = ""; + }; + }; + # + ghostty = { + enable = true; + package = ghostty.packages.${system}.default; + settings = { + theme = "dark"; + term = "xterm-256color"; + scrollback-limit = 1000000; + }; + themes = { + dark = { + background = "171421"; + # cursor-color = "f5e0dc"; + foreground = "D0CFCC"; + palette = [ + "0=#171421" + "1=#C01C28" + "2=#26A269" + "3=#A2734C" + "4=#12488B" + "5=#A347BA" + "6=#2AA1B3" + "7=#D0CFCC" + "8=#5E5C64" + "9=#F66151" + "10=#33D17A" + "11=#E9AD0C" + "12=#2A7BDE" + "13=#C061CB" + "14=#33C7DE" + "15=#FFFFFF" + ]; + # selection-background = "171421"; + # selection-foreground = "D0CFCC"; + }; + }; + }; + # + lutris = { + # enable = true; + # defaultWinePackage = pkgs.wineWowPackages.full; + runners = { + wine = { + settings = { + runner = { + # runner_executable = "${pkgs.wineWowPackages.full}/bin/wine"; + }; + system = { + game_path = "/home/thek0tyara/Documents/lutris"; + disable_runtime = false; + prefer_system_libs = true; + }; + }; + }; + }; + }; + nix-your-shell.enable = true; + obs-studio = { + enable = true; + plugins = with pkgs.obs-studio-plugins; [ + wlrobs + obs-pipewire-audio-capture + ]; + }; + obsidian.enable = true; + starship.enable = true; + swayimg.enable = true; + swaylock.enable = true; + uv = { + enable = true; # TODO move to nativeBuildInputs of needing + settings = { + python-downloads = "never"; + python-preference = "only-system"; + # pip.index-url = "https://pypi.org/simple"; + }; + }; + vesktop = { + enable = true; + # package = vesktopNoFuses; + # settings = { TODO }; + }; + vscode.enable = true; + waybar.enable = true; + yt-dlp = { + enable = true; + package = pkgs.yt-dlp; + settings = { + embed-thumbnail = true; + downloader = "aria2c"; + }; + # extraConfig = '' + # --extractor-args "youtube:player_client=default,ios,-android_sdkless" + # ''; + }; + zed-editor = { + enable = true; + themes = { + "name" = "Ayu Dark"; + }; + }; + }; +} diff --git a/secrets/github/token.ro.age b/secrets/github/token.ro.age new file mode 100644 index 0000000..13cfe25 --- /dev/null +++ b/secrets/github/token.ro.age @@ -0,0 +1,5 @@ +age-encryption.org/v1 +-> ssh-ed25519 7NTRpQ lXccnDI4sBAGeSu6yndyzRcf+VtdlKx61bbpHOQPXAQ +VI0/OLgIskzCLnF6zPxdgeawiE86A0jUoyryPjiXtf8 +--- I2kD2ndIYOk5EikyVgCE3LKT4sGEQ3J6aC0odY9r1eg +"';=4 Du~b( m܎y^vk.љdyfMD3|_؛[@Ty \ No newline at end of file diff --git a/secrets/secrets.nix b/secrets/secrets.nix new file mode 100644 index 0000000..d8cf6de --- /dev/null +++ b/secrets/secrets.nix @@ -0,0 +1,8 @@ +let + thek0tyara = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDb6p1jwL8lemLf1SwhmuA/WSkQ2zG/xp7Aa9t6CLL23"; + users = [ thek0tyara ]; +in +{ + "wg/syscon0.key.age".publicKeys = [ thek0tyara ]; + "github/token.ro.age".publicKeys = [ thek0tyara ]; +} diff --git a/secrets/wg/syscon0.key.age b/secrets/wg/syscon0.key.age new file mode 100644 index 0000000..c015c03 --- /dev/null +++ b/secrets/wg/syscon0.key.age @@ -0,0 +1,5 @@ +age-encryption.org/v1 +-> ssh-ed25519 7NTRpQ WII0w2ms+1pqCbh4VgBw1f0ORw6+p0HBYLCy0t2sujs +kVRyWFFJo/d9RlMDZsr9S+Ue9+IO3ysU0ytZFjJZszs +--- yq9NNt4S1FuQ6r8NPWON7J5DErJq/2RZBHMkBOse4rI +FTP{hW˥|:Zb\ 릘)Up2 DzυyYφ_e 6hg+- \ No newline at end of file