262 lines
7.5 KiB
Nix
Executable File
262 lines
7.5 KiB
Nix
Executable File
# This is for global config I DEFINITELY want on all machines, this should only include basic utilities and be relatively small.
|
|
# There is no order for where things are in this, it's a little messy.
|
|
{ pkgs, nix-flatpak, ... }:
|
|
{
|
|
|
|
imports = [
|
|
# nix-flatpak.nixosModules.nix-flatpak
|
|
];
|
|
|
|
# Lix
|
|
nixpkgs.overlays = [
|
|
(final: prev: {
|
|
inherit (prev.lixPackageSets.stable)
|
|
nixpkgs-review
|
|
nix-eval-jobs
|
|
nix-fast-build
|
|
colmena
|
|
;
|
|
})
|
|
];
|
|
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 = "8940";
|
|
src = pkgs.fetchFromGitHub {
|
|
owner = "ggml-org";
|
|
repo = "llama.cpp";
|
|
tag = "b${version}";
|
|
# rev = "6ebf2e0d00d31acfc1a1fa9662e9a7d38bd07bf7"; # https://github.com/ggml-org/llama.cpp/pull/19970
|
|
hash = "sha256-JlJeNO7eID6JvxZMkck136mC/Rvd5v8320tAuQabzhU=";
|
|
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-RAFtsbBGBjteCt5yXhrmHL39rIDJMCFBETgzId2eRRk=";
|
|
# 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"
|
|
"-DGGML_LTO=ON" # Link Time Optimization for overall binary speed
|
|
"-DCMAKE_CUDA_ARCHITECTURES=86" # RTX 3090
|
|
"-DGGML_CUDA=ON"
|
|
"-DGGML_CUDA_FA=ON" # FlashAttention kernels (accelerated attention)
|
|
"-DGGML_CUDA_FA_ALL_QUANTS=ON" # Support for all KV cache quant types in FA
|
|
"-DGGML_CUDA_GRAPHS=ON" # CUDA Graphs for lower overhead inference
|
|
"-DGGML_CUDA_FORCE_CUBLAS=ON" # cuBLAS optimized prompt processing for Ampere+
|
|
"-DGGML_CUDA_PEER_MAX_BATCH_SIZE=256" # Increased for multi-GPU efficiency (split mode)
|
|
"-DGGML_CUDA_COMPRESSION_MODE=speed" # Fast binary loading (CUDA 12.8+)
|
|
"-DGGML_OPENMP=ON" # Optimal multi-threading on CPU
|
|
"-DGGML_LLAMAFILE=ON" # Use llamafile sgemm for faster CPU layers
|
|
"-DGGML_CPU_REPACK=ON" # Optimize Q4_0 quant handling
|
|
"-DGGML_AVX=ON"
|
|
"-DGGML_AVX2=ON"
|
|
"-DGGML_FMA=ON"
|
|
"-DGGML_F16C=ON"
|
|
"-DGGML_AVX512=ON" # Intel AVX-512 extensions
|
|
"-DGGML_AVX512_VNNI=ON" # Vector Neural Network Instructions
|
|
"-DGGML_AVX512_BF16=ON" # Bfloat16 support
|
|
"-DGGML_AVX_VNNI=ON" # VNNI for processors without AVX-512
|
|
"-DGGML_AMX_TILE=ON" # Intel Advanced Matrix Extensions (Sapphire Rapids+)
|
|
"-DGGML_AMX_INT8=ON"
|
|
"-DGGML_AMX_BF16=ON"
|
|
"-DGGML_BLAS=ON" # Uses internal BLAS provided by Nix (blasSupport=true works)
|
|
];
|
|
|
|
postPatch = "";
|
|
|
|
# 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 = {
|
|
LC_ADDRESS = "en_US.UTF-8";
|
|
LC_IDENTIFICATION = "en_US.UTF-8";
|
|
LC_MEASUREMENT = "en_US.UTF-8";
|
|
LC_MONETARY = "en_US.UTF-8";
|
|
LC_NAME = "en_US.UTF-8";
|
|
LC_NUMERIC = "en_US.UTF-8";
|
|
LC_PAPER = "en_US.UTF-8";
|
|
LC_TELEPHONE = "en_US.UTF-8";
|
|
LC_TIME = "en_US.UTF-8";
|
|
};
|
|
|
|
# TODO: Look and find out if there's a better way to configure printers, my Brother needs to be reconnected every boot :/
|
|
services.printing.enable = true;
|
|
|
|
services.avahi = {
|
|
enable = true;
|
|
nssmdns4 = true;
|
|
openFirewall = true;
|
|
publish = {
|
|
enable = true;
|
|
userServices = true;
|
|
};
|
|
};
|
|
|
|
services.pulseaudio.enable = false;
|
|
security.rtkit.enable = true;
|
|
services.pipewire = {
|
|
enable = true;
|
|
alsa.enable = true;
|
|
alsa.support32Bit = true;
|
|
pulse.enable = true;
|
|
jack.enable = true;
|
|
};
|
|
|
|
# programs.adb.enable = true; # Bit heavy but you never know when you might need it...
|
|
|
|
users.users.laythe = {
|
|
isNormalUser = true;
|
|
description = "laythe";
|
|
extraGroups = [
|
|
"networkmanager"
|
|
"wheel"
|
|
"docker"
|
|
"adbusers"
|
|
"jackaudio"
|
|
"podman"
|
|
];
|
|
#To make podman work
|
|
subUidRanges = [
|
|
{
|
|
startUid = 100000;
|
|
count = 65536;
|
|
}
|
|
];
|
|
subGidRanges = [
|
|
{
|
|
startGid = 100000;
|
|
count = 65536;
|
|
}
|
|
];
|
|
};
|
|
|
|
programs.appimage = {
|
|
enable = true;
|
|
binfmt = true;
|
|
package = pkgs.appimage-run.override {
|
|
extraPkgs = pkgs: [
|
|
|
|
];
|
|
};
|
|
};
|
|
|
|
services.flatpak.enable = true;
|
|
programs.nix-ld.enable = true;
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
nix.optimise.automatic = true;
|
|
nix.gc = {
|
|
automatic = true;
|
|
dates = "daily"; # Maybe the solution is to buy more storage for my devices :p
|
|
options = "--delete-older-than 3d";
|
|
};
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
git
|
|
wget
|
|
wineWow64Packages.stable # Heavy but really annoying to not have when you need it
|
|
winetricks
|
|
gparted
|
|
unrar
|
|
# electrum
|
|
qpwgraph
|
|
libimobiledevice
|
|
ifuse
|
|
fastfetch
|
|
gimp # Despite the fact it falls under creative an image editor is too important to leave out.
|
|
zip
|
|
xz
|
|
unzip
|
|
p7zip
|
|
dnsutils
|
|
file
|
|
which
|
|
tree
|
|
gnused
|
|
gnutar
|
|
gawk
|
|
zstd
|
|
lsof
|
|
sysstat
|
|
lm_sensors
|
|
ethtool
|
|
pciutils # lspci
|
|
usbutils # lsusb
|
|
ffmpeg-full
|
|
xbindkeys
|
|
xdotool
|
|
xmodmap
|
|
nixfmt
|
|
units
|
|
android-tools
|
|
jq
|
|
nasctui
|
|
trilium-desktop
|
|
haruna
|
|
(pkgs.runCommand "nvenc-compress" { nativeBuildInputs = [ pkgs.bash ]; }
|
|
''
|
|
mkdir -p $out/bin
|
|
cp ${./nvenc_compress.sh} $out/bin/nvenc-compress
|
|
chmod +x $out/bin/nvenc-compress
|
|
'')
|
|
];
|
|
|
|
fonts.packages = with pkgs; [
|
|
twitter-color-emoji
|
|
];
|
|
|
|
fonts.fontconfig.defaultFonts = {
|
|
emoji = [ "Twitter Color Emoji" ];
|
|
};
|
|
|
|
services.usbmuxd = {
|
|
enable = true;
|
|
package = pkgs.usbmuxd2;
|
|
};
|
|
|
|
nix.settings.experimental-features = [
|
|
"nix-command"
|
|
"flakes"
|
|
];
|
|
}
|