diff --git a/flake.lock b/flake.lock index 7fb24b0..8efac46 100755 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1764998300, - "narHash": "sha256-fZatn/KLfHLDXnF0wy7JxXqGaZmGDTVufT4o/AOlj44=", + "lastModified": 1772060133, + "narHash": "sha256-VuyRptb8v1lVGMlLp4/1vRX3Efwec0CN0S6mKmDPzLg=", "owner": "nix-community", "repo": "home-manager", - "rev": "27a6182347ccae90a88231ae0dc5dfa7d15815bb", + "rev": "ce9b6e52500a0ea0ec48f0bbf6d7a3e431d9dfa4", "type": "github" }, "original": { @@ -21,13 +21,38 @@ "type": "github" } }, - "impermanence": { + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "impermanence", + "nixpkgs" + ] + }, "locked": { - "lastModified": 1737831083, - "narHash": "sha256-LJggUHbpyeDvNagTUrdhe/pRVp4pnS6wVKALS782gRI=", + "lastModified": 1768598210, + "narHash": "sha256-kkgA32s/f4jaa4UG+2f8C225Qvclxnqs76mf8zvTVPg=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "c47b2cc64a629f8e075de52e4742de688f930dc6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "impermanence": { + "inputs": { + "home-manager": "home-manager_2", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1769548169, + "narHash": "sha256-03+JxvzmfwRu+5JafM0DLbxgHttOQZkUtDWBmeUkN8Y=", "owner": "nix-community", "repo": "impermanence", - "rev": "4b3e914cdf97a5b536a889e939fb2fd2b043a170", + "rev": "7b1d382faf603b6d264f58627330f9faa5cba149", "type": "github" }, "original": { @@ -38,11 +63,27 @@ }, "nixpkgs": { "locked": { - "lastModified": 1764950072, - "narHash": "sha256-BmPWzogsG2GsXZtlT+MTcAWeDK5hkbGRZTeZNW42fwA=", + "lastModified": 1768564909, + "narHash": "sha256-Kell/SpJYVkHWMvnhqJz/8DqQg2b6PguxVWOuadbHCc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "f61125a668a320878494449750330ca58b78c557", + "rev": "e4bae1bd10c9c57b2cf517953ab70060a828ee6f", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1771848320, + "narHash": "sha256-0MAd+0mun3K/Ns8JATeHT1sX28faLII5hVLq0L3BdZU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2fc6539b481e1d2569f25f8799236694180c0993", "type": "github" }, "original": { @@ -86,4 +127,4 @@ }, "root": "root", "version": 7 -} +} \ No newline at end of file diff --git a/global/default.nix b/global/default.nix index eecbc60..338fd46 100755 --- a/global/default.nix +++ b/global/default.nix @@ -20,6 +20,66 @@ ]; nix.package = pkgs.lixPackageSets.stable.lix; + nixpkgs.config.packageOverrides = pkgs: { + + # Stolen from https://www.nijho.lt/post/llama-nixos/ + llama-cpp = + (pkgs.llama-cpp.override { + cudaSupport = true; + rocmSupport = false; + metalSupport = false; + # Enable BLAS for optimized CPU layer performance (OpenBLAS) + # This is crucial for models using split-mode or CPU offloading + blasSupport = true; + }).overrideAttrs + (oldAttrs: rec { + version = "8184"; + src = pkgs.fetchFromGitHub { + owner = "aagit"; + repo = "llama.cpp"; + # tag = "b${version}"; + rev = "6ebf2e0d00d31acfc1a1fa9662e9a7d38bd07bf7"; # https://github.com/ggml-org/llama.cpp/pull/19970 + hash = "sha256-xryajW0Cs1d+WDijspMTW21FDaZP9Grkb+uErMQCQ48="; + leaveDotGit = true; + postFetch = '' + git -C "$out" rev-parse --short HEAD > $out/COMMIT + find "$out" -name .git -print0 | xargs -0 rm -rf + ''; + }; + # Must update npm deps hash to match the new version's webui dependencies + npmDepsHash = "sha256-FKjoZTKm0ddoVdpxzYrRUmTiuafEfbKc4UD2fz2fb8A="; + # Enable native CPU optimizations for massively better CPU performance + # This enables AVX, AVX2, AVX-512, FMA, etc. for your specific CPU + # NOTE: This is intentionally opposite of nixpkgs (which uses -DGGML_NATIVE=off + # for reproducible builds). We sacrifice portability for faster CPU layers. + cmakeFlags = (oldAttrs.cmakeFlags or [ ]) ++ [ + "-DGGML_NATIVE=ON" + "-DCMAKE_CUDA_ARCHITECTURES=86" # RTX 3090 - needed since sandbox has no GPU + ]; + + # Disable Nix's NIX_ENFORCE_NO_NATIVE which strips -march=native flags + # See: https://github.com/NixOS/nixpkgs/issues/357736 + # See: https://github.com/NixOS/nixpkgs/pull/377484 (intentionally contradicts this) + preConfigure = '' + export NIX_ENFORCE_NO_NATIVE=0 + ${oldAttrs.preConfigure or ""} + ''; + }); + + # llama-swap from GitHub releases + llama-swap = pkgs.runCommand "llama-swap" { } '' + mkdir -p $out/bin + tar -xzf ${ + pkgs.fetchurl { + url = "https://github.com/mostlygeek/llama-swap/releases/download/v190/llama-swap_190_linux_amd64.tar.gz"; + hash = "sha256-WAfmJ4YiVH/UYq++l2Ut6oLqkd270HgG7eV+6FG/0Oc="; + } + } -C $out/bin + chmod +x $out/bin/llama-swap + ''; + + }; + # 🇺🇸 i18n.defaultLocale = "en_US.UTF-8"; i18n.extraLocaleSettings = { @@ -57,7 +117,7 @@ jack.enable = true; }; - programs.adb.enable = true; # Bit heavy but you never know when you might need it... + # programs.adb.enable = true; # Bit heavy but you never know when you might need it... users.users.laythe = { isNormalUser = true; @@ -110,11 +170,11 @@ environment.systemPackages = with pkgs; [ git wget - wineWowPackages.stable # Heavy but really annoying to not have when you need it + wineWow64Packages.stable # Heavy but really annoying to not have when you need it winetricks gparted unrar - electrum + # electrum qpwgraph libimobiledevice ifuse @@ -144,6 +204,7 @@ xmodmap nixfmt units + android-tools ]; services.usbmuxd = { diff --git a/machines/homepc/configuration.nix b/machines/homepc/configuration.nix index a841fbe..8be6ba5 100755 --- a/machines/homepc/configuration.nix +++ b/machines/homepc/configuration.nix @@ -39,10 +39,81 @@ # }; # This is here because I don't have another computer that could run local AI, and regardless the packages would be different on every one. + # TODO: honestly, while I currently only have one pc that can run local AI, might change in the future. + # And this config is getting a bit complicated for a single pc config + # Should be moved to it's own shit environment.systemPackages = with pkgs; [ ollama-cuda + opencode + llama-cpp + llama-swap ]; + services.ollama = { + enable = true; + package = pkgs.ollama-cuda; + environmentVariables = { + OLLAMA_NUM_PARALLEL = "1"; + OLLAMA_FLASH_ATTENTION = "1"; + OLLAMA_KV_CACHE_TYPE = "q4_0"; + OLLAMA_CONTEXT_LENGTH = "16384"; + }; + }; + + # Configure llama-swap as a systemd service + systemd.services.llama-swap = { + description = "llama-swap - OpenAI compatible proxy with automatic model swapping"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + Type = "simple"; + User = "laythe"; + Group = "users"; + # Point to your declarative config file + ExecStart = "${pkgs.llama-swap}/bin/llama-swap --config /etc/llama-swap/config.yaml --listen 0.0.0.0:9292 --watch-config"; + Restart = "always"; + RestartSec = 10; + + # Environment for CUDA support + Environment = [ + "PATH=/run/current-system/sw/bin" + "LD_LIBRARY_PATH=/run/opengl-driver/lib:/run/opengl-driver-32/lib" + ]; + }; + }; + + # As long as this is here the models are declarative. llama-server will grab them if not downloaded already. + environment.etc."llama-swap/config.yaml".text = '' + models: + "Qwen3.5-35B-A3B-GGUF": + cmd: llama-server --port ''${PORT} -hf unsloth/Qwen3.5-35B-A3B-GGUF:Q4_K_S --ctx-size 128000 --temp 0.6 --top-p 0.95 --top-k 20 --min-p 0.00 -np 1 --cpu-moe --fit-target 256 --ubatch-size 1024 -fa on --slots --slot-save-path /home/laythe/llamapcache --jinja -kvu --no-mmproj --swa-checkpoints 32 + ttl: 2400 + "Qwen3-1.7B-GGUF": + cmd: llama-server --port ''${PORT} -hf unsloth/Qwen3-1.7B-GGUF:Q4_K_S --ctx-size 32768 --temp 0.6 --top-p 0.95 --top-k 20 --min-p 0.00 -fa on --jinja -kvu + ttl: 120 + "Qwen3-8B-GGUF": + cmd: llama-server --port ''${PORT} -hf unsloth/Qwen3-8B-GGUF:Q4_K_S --ctx-size 32768 --temp 0.6 --top-p 0.95 --top-k 20 --min-p 0.00 -fa on --jinja -kvu -np 1 + ttl: 120 + "Qwen3-4B-Claude-Opus-Distill": + cmd: llama-server --port ''${PORT} -hf TeichAI/Qwen3-4B-Thinking-2507-Claude-4.5-Opus-High-Reasoning-Distill-GGUF:Q4_K_M --ctx-size 32768 --temp 0.6 --top-p 0.95 --top-k 20 --min-p 0.00 -fa on --jinja -kvu -np 1 --fit-target 256 + ttl: 120 + "Qwen3.5-9B-Thinking": + cmd: "llama-server --port ''${PORT} -hf unsloth/Qwen3.5-9B-GGUF:Q4_K_M --ctx-size 32000 --temp 0.6 --top-p 0.95 --top-k 20 --min-p 0.00 -fa on --jinja -kvu -np 1 --fit-target 256 --chat-template-kwargs '{\"enable_thinking\": true}' --no-mmproj" + ttl: 120 + "Qwen3.5-4B-Thinking": + cmd: "llama-server --port ''${PORT} -hf unsloth/Qwen3.5-4B-GGUF:Q4_K_M --ctx-size 64000 --temp 0.6 --top-p 0.95 --top-k 20 --min-p 0.00 -fa on --jinja -kvu -np 1 --fit-target 256 --chat-template-kwargs '{\"enable_thinking\": true}'" + ttl: 120 + "Qwen3.5-9B-Non-Thinking": + cmd: "llama-server --port ''${PORT} -hf unsloth/Qwen3.5-9B-GGUF:Q4_K_M --ctx-size 32000 --temp 0.7 --top-p 0.8 --top-k 20 --min-p 0.00 -fa on --jinja -kvu -np 1 --fit-target 256 --no-mmproj" + ttl: 120 + "Qwen3.5-4B-Non-Thinking": + cmd: "llama-server --port ''${PORT} -hf unsloth/Qwen3.5-4B-GGUF:Q4_K_M --ctx-size 64000 --temp 0.7 --top-p 0.8 --top-k 20 --min-p 0.00 -fa on --jinja -kvu -np 1 --fit-target 256" + ttl: 120 + "Qwen3.5-0.8B-Non-Thinking": + cmd: "llama-server --port ''${PORT} -hf unsloth/Qwen3.5-0.8B-GGUF:Q4_K_M --ctx-size 64000 --temp 0.7 --top-p 0.8 --top-k 20 --min-p 0.00 -fa on --jinja -kvu -np 1 --fit-target 256" + ttl: 120''; + # Set your time zone. # time.timeZone = "Europe/Amsterdam"; @@ -113,7 +184,7 @@ # networking.firewall.allowedTCPPorts = [ ... ]; # networking.firewall.allowedUDPPorts = [ ... ]; # Or disable the firewall altogether. - # networking.firewall.enable = false; + 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 diff --git a/modules/communication/default.nix b/modules/communication/default.nix index 789b68f..a66cd76 100755 --- a/modules/communication/default.nix +++ b/modules/communication/default.nix @@ -5,5 +5,6 @@ jami element-desktop signal-desktop + praat ]; } diff --git a/modules/development/default.nix b/modules/development/default.nix index 3fcfb15..13c90a9 100755 --- a/modules/development/default.nix +++ b/modules/development/default.nix @@ -2,19 +2,23 @@ { environment.systemPackages = with pkgs; [ antigravity # Free Gemini 3 credits was too good of an offer to not take up, even if it requires selling my soul. + chromium ]; home-manager.sharedModules = [ - ({ pkgs, ... }: { - programs.vscode = { - enable = true; - extensions = with pkgs.vscode-extensions; [ - jnoortheen.nix-ide - ]; - userSettings = { - "editor.formatOnSave" = true; + ( + { pkgs, ... }: + { + programs.vscode = { + enable = true; + extensions = with pkgs.vscode-extensions; [ + jnoortheen.nix-ide + ]; + userSettings = { + "editor.formatOnSave" = true; + }; }; - }; - }) + } + ) ]; -} \ No newline at end of file +} diff --git a/modules/fabrication/default.nix b/modules/fabrication/default.nix index 742887f..ba424ff 100755 --- a/modules/fabrication/default.nix +++ b/modules/fabrication/default.nix @@ -1,7 +1,7 @@ -{pkgs, ...}: +{ pkgs, ... }: { environment.systemPackages = with pkgs; [ kicad - cura + # cura ]; -} \ No newline at end of file +} diff --git a/modules/gaming/default.nix b/modules/gaming/default.nix index 45f0aac..81be047 100755 --- a/modules/gaming/default.nix +++ b/modules/gaming/default.nix @@ -1,4 +1,4 @@ -{pkgs, environment, ...}: +{ pkgs, environment, ... }: { programs.steam = { enable = true; @@ -13,4 +13,4 @@ lutris prismlauncher ]; -} \ No newline at end of file +} diff --git a/modules/kde/default.nix b/modules/kde/default.nix index 27ba72a..25868fb 100755 --- a/modules/kde/default.nix +++ b/modules/kde/default.nix @@ -9,6 +9,7 @@ environment.systemPackages = with pkgs; [ kdePackages.kate + kdePackages.filelight # kdePackages.kdeconnect-kde ]; diff --git a/modules/virtualization/default.nix b/modules/virtualization/default.nix index e58fdc1..7d64261 100755 --- a/modules/virtualization/default.nix +++ b/modules/virtualization/default.nix @@ -1,4 +1,4 @@ -{pkgs, ...}: +{ pkgs, ... }: { environment.systemPackages = with pkgs; [ qemu @@ -6,7 +6,7 @@ ]; programs.virt-manager.enable = true; - users.groups.libvirtd.members = ["laythe"]; + users.groups.libvirtd.members = [ "laythe" ]; virtualisation.libvirtd.enable = true; virtualisation.spiceUSBRedirection.enable = true; virtualisation.libvirtd.qemu.swtpm.enable = true; @@ -14,5 +14,6 @@ virtualisation.podman = { enable = true; dockerCompat = true; + enableNvidia = true; }; -} \ No newline at end of file +}