From c146f846de0f5a68d3566ce5478fec655b6ad84f Mon Sep 17 00:00:00 2001 From: TheK0tYaRa Date: Wed, 4 Mar 2026 01:02:47 +0200 Subject: [PATCH 1/6] fixup --- configuration.nix | 17 +------- custom/modules/default.nix | 13 ++++++ custom/modules/kernel.nix | 88 ++++++++++++++++++++++++++++++++++++++ custom/override.nix | 4 +- devenv.nix | 2 +- flake.lock | 72 +++++++++++++++++++++++-------- flake.nix | 46 ++++++++++++++++---- home.nix | 38 +++++++++++++--- 8 files changed, 228 insertions(+), 52 deletions(-) create mode 100644 custom/modules/default.nix create mode 100644 custom/modules/kernel.nix diff --git a/configuration.nix b/configuration.nix index dab15d9..c65d8bc 100644 --- a/configuration.nix +++ b/configuration.nix @@ -89,18 +89,6 @@ 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" ]; @@ -204,16 +192,13 @@ xdotool tree hyperfine - unrar - unzip - xarchiver nmap ]; }; programs = { gnome-terminal.enable = true; - thunar.enable = true; # TODO: replace + # thunar.enable = true; # TODO: replace winbox = { enable = true; package = pkgs.winbox4; diff --git a/custom/modules/default.nix b/custom/modules/default.nix new file mode 100644 index 0000000..1c2f431 --- /dev/null +++ b/custom/modules/default.nix @@ -0,0 +1,13 @@ +{ + pkgs, + lib, + kernel-src, + ... +}: + +let + linuxMainline = import ./kernel.nix { inherit pkgs lib kernel-src; }; +in +{ + boot.kernelPackages = pkgs.linuxPackagesFor linuxMainline; +} diff --git a/custom/modules/kernel.nix b/custom/modules/kernel.nix new file mode 100644 index 0000000..18fc764 --- /dev/null +++ b/custom/modules/kernel.nix @@ -0,0 +1,88 @@ +{ + pkgs, + lib, + kernel-src, + structuredExtraConfig ? { }, + kernelPatches ? [ ], + extraConfig ? "", +}: + +let + makefile = builtins.readFile "${kernel-src}/Makefile"; + lines = lib.splitString "\n" makefile; + + get = + name: + let + line = lib.findFirst ( + l: lib.hasPrefix "${name} =" (lib.strings.trim l) + ) (throw "Makefile missing ${name}") lines; + in + lib.strings.trim (lib.removePrefix "${name} =" (lib.strings.trim line)); + + V = get "VERSION"; + P = get "PATCHLEVEL"; + S = get "SUBLEVEL"; + E = get "EXTRAVERSION"; + + kver = "${V}.${P}.${S}${E}"; +in +pkgs.callPackage ( + { buildLinux, ... }@args: + let + llvm = pkgs.llvmPackages_latest; + clang = "${llvm.clang}/bin/clang"; + clangpp = "${llvm.clang}/bin/clang++"; + lld = "${llvm.lld}/bin/ld.lld"; + llvmbin = "${llvm.llvm}/bin"; + + structuredExtraConfig' = + (with lib.kernel; { + # LTO_CLANG_THIN = yes; # i should find the correct one + # LTO_CLANG_FULL = no; + # LTO_NONE = no; + }) + // structuredExtraConfig; + in + buildLinux ( + args + // { + inherit kernelPatches extraConfig; + + version = kver; + modDirVersion = kver; + src = kernel-src; + + nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ + llvm.clang + llvm.lld + llvm.llvm + ]; + + makeFlags = (args.makeFlags or [ ]) ++ [ + "LLVM=1" + "LLVM_IAS=1" + + # needed due to build script retardation + "CC=${clang}" + "HOSTCC=${clang}" + "HOSTCXX=${clangpp}" + "LD=${lld}" + "HOSTLD=${lld}" + + "AR=${llvmbin}/llvm-ar" + "NM=${llvmbin}/llvm-nm" + "STRIP=${llvmbin}/llvm-strip" + "OBJCOPY=${llvmbin}/llvm-objcopy" + "OBJDUMP=${llvmbin}/llvm-objdump" + "READELF=${llvmbin}/llvm-readelf" + ]; + + structuredExtraConfig = structuredExtraConfig'; + + ignoreConfigErrors = true; + + extraMeta.branch = "${V}.${P}"; + } + ) +) { } diff --git a/custom/override.nix b/custom/override.nix index 49fbd95..d86ab82 100644 --- a/custom/override.nix +++ b/custom/override.nix @@ -1,11 +1,11 @@ final: prev: { llama-cpp = prev.llama-cpp.overrideAttrs (old: rec { - version = "8018"; + version = "8124"; src = prev.fetchFromGitHub { owner = "ggml-org"; repo = "llama.cpp"; tag = "b${version}"; - hash = "sha256-V60fAIZHVse3mD4Q7LodL2UxspdZorDDsSqlB/lMyGE="; + hash = old.src.hash; }; # nativeBuildInputs = old.nativeBuildInputs ++ [ prev.pkgs.curl ]; }); diff --git a/devenv.nix b/devenv.nix index 561165f..957a409 100644 --- a/devenv.nix +++ b/devenv.nix @@ -17,7 +17,7 @@ nix flake check ''; build.exec = '' - nixos-rebuild switch --sudo --flake '.#' + nixos-rebuild switch --sudo --flake '.#' $@ ''; }; diff --git a/flake.lock b/flake.lock index c10dab8..e156fea 100644 --- a/flake.lock +++ b/flake.lock @@ -395,11 +395,11 @@ ] }, "locked": { - "lastModified": 1772218752, - "narHash": "sha256-G8nArvOTZXU8DRvrzAdz3Elcj6kA/vMtvY9mrGLATtA=", + "lastModified": 1772569491, + "narHash": "sha256-bdr6ueeXO1Xg91sFkuvaysYF0mVdwHBpdyhTjBEWv+s=", "owner": "nix-community", "repo": "home-manager", - "rev": "f3a30376bb9eb2f6f61816be7d6ed954b6d2a3b9", + "rev": "924e61f5c2aeab38504028078d7091077744ab17", "type": "github" }, "original": { @@ -481,6 +481,24 @@ "type": "github" } }, + "kernel-src": { + "flake": false, + "locked": { + "lastModified": 1772558248, + "narHash": "sha256-xv9+ldZjWEMJZVPTi5w7O4SDOI0lz5NcWvjgQGE1HCg=", + "ref": "drm-tip", + "rev": "cfc20c776480fda8c1b0517b187bb71ec0781cd4", + "shallow": true, + "type": "git", + "url": "https://gitlab.freedesktop.org/drm/tip.git" + }, + "original": { + "ref": "drm-tip", + "shallow": true, + "type": "git", + "url": "https://gitlab.freedesktop.org/drm/tip.git" + } + }, "lanzaboote": { "inputs": { "crane": "crane", @@ -537,11 +555,11 @@ "xwayland-satellite-unstable": "xwayland-satellite-unstable" }, "locked": { - "lastModified": 1772211154, - "narHash": "sha256-BdXKcWd1LE+APzyaJ/xszDXcA5KKPenjNyC5VOd3x4E=", + "lastModified": 1772572827, + "narHash": "sha256-d91kXM4t1G0KQ/MB0LTP514IslsDu6ZBt4HQE7hVvzs=", "owner": "sodiboo", "repo": "niri-flake", - "rev": "599b3f8d4215470dd50066119c81007b2670b6e1", + "rev": "7592181859ad2ab12913bbede47b45481b2b2938", "type": "github" }, "original": { @@ -583,6 +601,22 @@ "type": "github" } }, + "nix-flatpak": { + "locked": { + "lastModified": 1767983141, + "narHash": "sha256-7ZCulYUD9RmJIDULTRkGLSW1faMpDlPKcbWJLYHoXcs=", + "owner": "gmodena", + "repo": "nix-flatpak", + "rev": "440818969ac2cbd77bfe025e884d0aa528991374", + "type": "github" + }, + "original": { + "owner": "gmodena", + "ref": "latest", + "repo": "nix-flatpak", + "type": "github" + } + }, "nix-index-database": { "inputs": { "nixpkgs": [ @@ -590,11 +624,11 @@ ] }, "locked": { - "lastModified": 1771734689, - "narHash": "sha256-/phvMgr1yutyAMjKnZlxkVplzxHiz60i4rc+gKzpwhg=", + "lastModified": 1772341813, + "narHash": "sha256-/PQ0ubBCMj/MVCWEI/XMStn55a8dIKsvztj4ZVLvUrQ=", "owner": "nix-community", "repo": "nix-index-database", - "rev": "8f590b832326ab9699444f3a48240595954a4b10", + "rev": "a2051ff239ce2e8a0148fa7a152903d9a78e854f", "type": "github" }, "original": { @@ -636,11 +670,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1772047000, - "narHash": "sha256-7DaQVv4R97cii/Qdfy4tmDZMB2xxtyIvNGSwXBBhSmo=", + "lastModified": 1772465433, + "narHash": "sha256-ywy9troNEfpgh0Ee+zaV1UTgU8kYBVKtvPSxh6clYGU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1267bb4920d0fc06ea916734c11b0bf004bbe17e", + "rev": "c581273b8d5bdf1c6ce7e0a54da9841e6a763913", "type": "github" }, "original": { @@ -681,11 +715,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1771848320, - "narHash": "sha256-0MAd+0mun3K/Ns8JATeHT1sX28faLII5hVLq0L3BdZU=", + "lastModified": 1772542754, + "narHash": "sha256-WGV2hy+VIeQsYXpsLjdr4GvHv5eECMISX1zKLTedhdg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2fc6539b481e1d2569f25f8799236694180c0993", + "rev": "8c809a146a140c5c8806f13399592dbcb1bb5dc4", "type": "github" }, "original": { @@ -809,8 +843,10 @@ "dw-proton": "dw-proton", "home-manager": "home-manager", "intel-hw": "intel-hw", + "kernel-src": "kernel-src", "mypkgs": "mypkgs", "niri-flake": "niri-flake", + "nix-flatpak": "nix-flatpak", "nix-index-database": "nix-index-database", "nixpkgs": "nixpkgs_4", "ragenix": "ragenix" @@ -1128,11 +1164,11 @@ "xwayland-satellite-unstable": { "flake": false, "locked": { - "lastModified": 1771787042, - "narHash": "sha256-7bM6Y4KldhKnfopSALF8XALxcX7ehkomXH9sPl4MXp0=", + "lastModified": 1772429643, + "narHash": "sha256-M+bAeCCcjBnVk6w/4dIVvXvpJwOKnXjwi/lDbaN6Yws=", "owner": "Supreeeme", "repo": "xwayland-satellite", - "rev": "33c344fee50504089a447a8fef5878cf4f6215fc", + "rev": "10f985b84cdbcc3bbf35b3e7e43d1b2a84fa9ce2", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 30309d9..1f79ae5 100644 --- a/flake.nix +++ b/flake.nix @@ -20,7 +20,12 @@ }; dw-proton.url = "github:imaviso/dwproton-flake"; intel-hw.url = "github:MordragT/nixos"; - # + nix-flatpak.url = "github:gmodena/nix-flatpak/latest"; + kernel-src = { + # url = "git+https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git?ref=master"; + url = "git+https://gitlab.freedesktop.org/drm/tip.git?shallow=1&ref=drm-tip"; + flake = false; + }; }; outputs = inputs@{ @@ -31,6 +36,8 @@ nix-index-database, niri-flake, intel-hw, + nix-flatpak, + kernel-src, ... }: let @@ -40,15 +47,21 @@ { nixosConfigurations.testenv = nixpkgs.lib.nixosSystem { inherit system; - specialArgs = { inherit inputs; }; + specialArgs = { + inherit inputs; + kernel-src = inputs.kernel-src; + }; modules = [ + ./custom/modules ragenix.nixosModules.default niri-flake.nixosModules.niri nix-index-database.nixosModules.default + nix-flatpak.nixosModules.nix-flatpak ( { pkgs, pkgdefault, + config, ... }: { @@ -61,13 +74,6 @@ (import ./custom/override.nix) niri-flake.overlays.niri ]; - # boot.kernelPatches = [ - # { - # name = "name"; - # patch = null; - # extraConfig = ""; - # } - # ]; hardware = { graphics = { @@ -98,6 +104,27 @@ ]; download-buffer-size = 160000000; }; + boot = { + loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = false; + }; + # kernelPackages = pkgs.linuxPackages_testing; + extraModulePackages = with config.boot.kernelPackages; [ + v4l2loopback + # amneziawg + ]; + # kernelPatches = [ + # { + # name = "7.0-rc fixup"; + # extraConfig = '' + # ''; + # } + # ]; + }; + # nixpkgs.config.permittedInsecurePackages = [ + # "olm-3.2.16" + # ]; age = { secrets = { # "wg/syscon0.key".file = ./secrets/wg/syscon0.key.age; @@ -207,6 +234,7 @@ enable = true; defaultSession = "niri"; }; + flatpak.enable = true; locate.enable = true; pipewire = { enable = true; diff --git a/home.nix b/home.nix index 6a516e8..f6f6d2f 100644 --- a/home.nix +++ b/home.nix @@ -8,6 +8,7 @@ { imports = [ ./custom/hm + inputs.nix-flatpak.homeManagerModules.nix-flatpak ]; gtk = { @@ -52,11 +53,16 @@ arch-install-scripts kdocker # tray the untrayable xwayland-satellite - xdg-desktop-portal-gtk - xdg-desktop-portal-wlr winboat xfce4-taskmanager + ### file management + cosmic-files + lxqt.lxqt-archiver + unrar + unzip + p7zip + ### development # idea-community-bin @@ -70,7 +76,6 @@ lmstudio - ### social # fluffychat @@ -149,7 +154,18 @@ "image/png" = "swayimg.desktop"; "image/webp" = "swayimg.desktop"; - "application/zip" = "xarchiver.desktop"; + "application/zip" = "lxqt-archiver.desktop"; + }; + }; + portal = { + enable = true; + extraPortals = with pkgs; [ + xdg-desktop-portal-gtk + xdg-desktop-portal-wlr + xdg-desktop-portal-gnome + ]; + config = { + common.default = "*"; }; }; configFile."obsidian/.keep".text = ""; @@ -187,6 +203,11 @@ }; }; services = { + flatpak = { + packages = [ + "org.vinegarhq.Sober" + ]; + }; mako.enable = true; ollama = { # enable = true; @@ -199,6 +220,7 @@ OLLAMA_KV_CACHE_TYPE = "q8_0"; # OLLAMA_CONTEXT_LENGTH = "16000"; OLLAMA_MODELS = "/home/thek0tyara/Downloads/llm/ollama"; + XDG_DATA_DIRS = "empty"; }; }; podman = { @@ -550,7 +572,11 @@ "--always-new-process" ]; "Mod+R".action.spawn = "fuzzel"; - "Mod+Shift+L".action.spawn = "swaylock --color 030303"; + "Mod+Shift+L".action.spawn = [ + "swaylock" + "--color" + "030303" + ]; "Scroll_Lock" = { # toggle microphone @@ -804,7 +830,7 @@ # ''; }; zed-editor = { - enable = true; + # enable = true; themes = { "name" = "Ayu Dark"; }; From 44561593a0a1b24f0e43bba3e078ad303aaaaa57 Mon Sep 17 00:00:00 2001 From: TheK0tYaRa Date: Wed, 4 Mar 2026 07:08:24 +0200 Subject: [PATCH 2/6] fixup2 --- custom/modules/kernel.nix | 22 +------ custom/modules/llvm-ccache-stdenv.nix | 91 +++++++++++++++++++++++++++ custom/override.nix | 36 +++++++++-- flake.nix | 10 ++- 4 files changed, 134 insertions(+), 25 deletions(-) create mode 100644 custom/modules/llvm-ccache-stdenv.nix diff --git a/custom/modules/kernel.nix b/custom/modules/kernel.nix index 18fc764..060e65f 100644 --- a/custom/modules/kernel.nix +++ b/custom/modules/kernel.nix @@ -31,14 +31,10 @@ pkgs.callPackage ( { buildLinux, ... }@args: let llvm = pkgs.llvmPackages_latest; - clang = "${llvm.clang}/bin/clang"; - clangpp = "${llvm.clang}/bin/clang++"; - lld = "${llvm.lld}/bin/ld.lld"; - llvmbin = "${llvm.llvm}/bin"; structuredExtraConfig' = (with lib.kernel; { - # LTO_CLANG_THIN = yes; # i should find the correct one + LTO_CLANG_THIN = yes; # LTO_CLANG_FULL = no; # LTO_NONE = no; }) @@ -49,6 +45,8 @@ pkgs.callPackage ( // { inherit kernelPatches extraConfig; + stdenv = llvm.stdenv; + version = kver; modDirVersion = kver; src = kernel-src; @@ -62,20 +60,6 @@ pkgs.callPackage ( makeFlags = (args.makeFlags or [ ]) ++ [ "LLVM=1" "LLVM_IAS=1" - - # needed due to build script retardation - "CC=${clang}" - "HOSTCC=${clang}" - "HOSTCXX=${clangpp}" - "LD=${lld}" - "HOSTLD=${lld}" - - "AR=${llvmbin}/llvm-ar" - "NM=${llvmbin}/llvm-nm" - "STRIP=${llvmbin}/llvm-strip" - "OBJCOPY=${llvmbin}/llvm-objcopy" - "OBJDUMP=${llvmbin}/llvm-objdump" - "READELF=${llvmbin}/llvm-readelf" ]; structuredExtraConfig = structuredExtraConfig'; diff --git a/custom/modules/llvm-ccache-stdenv.nix b/custom/modules/llvm-ccache-stdenv.nix new file mode 100644 index 0000000..c5650a4 --- /dev/null +++ b/custom/modules/llvm-ccache-stdenv.nix @@ -0,0 +1,91 @@ +{ config, lib, ... }: + +let + cfg = config.programs.ccache; +in +{ + config = lib.mkIf cfg.enable { + # ccache должен быть виден из sandbox + nix.settings.extra-sandbox-paths = [ cfg.cacheDir ]; + + nixpkgs.overlays = [ + (final: prev: + let + llvm = prev.llvmPackages_latest; + + realClang = llvm.clang-unwrapped; + realClangLib = prev.lib.getLib realClang; + + # "unwrapped clang", но с ccache + per-package CCACHE_DIR + clangUnwrappedCcache = + prev.stdenvNoCC.mkDerivation { + pname = "clang-unwrapped-ccache"; + version = realClang.version; + + outputs = [ "out" "lib" ]; + dontUnpack = true; + + installPhase = '' + mkdir -p "$out/bin" "$lib/lib" + + mkwrap() { + local name="$1" + local real="$2" + cat > "$out/bin/$name" <<'EOF' + #!${prev.bash}/bin/bash + set -euo pipefail + + # base cache dir from NixOS module + base='${cfg.cacheDir}' + + # prefer pname (no version), fallback to name, and strip "-..." if present + pkg="${pname:-${name:-unknown}}" + pkg="${pkg%%-[0-9]*}" + + mkdir -p "$base/$pkg" + export CCACHE_DIR="$base/$pkg" + export CCACHE_UMASK=007 + + # improves hit rate for repeated local rebuilds + export CCACHE_BASEDIR="${NIX_BUILD_TOP:-/build}" + export CCACHE_COMPRESS=1 + export CCACHE_SLOPPINESS=random_seed,time_macros + + exec ${prev.ccache}/bin/ccache __REAL__ "$@" + EOF + substituteInPlace "$out/bin/$name" --replace "__REAL__" "$real" + chmod +x "$out/bin/$name" + } + + mkwrap clang ${realClang}/bin/clang + mkwrap clang++ ${realClang}/bin/clang++ + + ln -s "$out/bin/clang" "$out/bin/cc" + ln -s "$out/bin/clang++" "$out/bin/c++" + + # make lib.getLib(stdenv.cc.cc) point to real clang builtin headers + ln -s ${realClangLib}/lib/clang "$lib/lib/clang" + ''; + + meta = (realClang.meta or { }) // { + mainProgram = "clang"; + }; + }; + + # Wrapped clang package that points its "unwrapped" to our ccache one + clangWrappedCcache = llvm.clang.override { cc = clangUnwrappedCcache; }; + + # New stdenv: same llvm stdenv, but compiler wrapper uses our ccache-unwrapped clang + llvmCcacheStdenv = prev.overrideCC llvm.stdenv clangWrappedCcache; + + in + { + llvmPackages_latest = llvm // { + stdenv = llvmCcacheStdenv; + clang = clangWrappedCcache; + clang-unwrapped = clangUnwrappedCcache; + }; + }) + ]; + }; +} \ No newline at end of file diff --git a/custom/override.nix b/custom/override.nix index d86ab82..1b007ea 100644 --- a/custom/override.nix +++ b/custom/override.nix @@ -1,4 +1,28 @@ final: prev: { + ccacheWrapper = prev.ccacheWrapper.override { + extraConfig = '' + export CCACHE_COMPRESS=1 + export CCACHE_SLOPPINESS=random_seed,time_macros + export CCACHE_DIR="/home/thek0tyara/Documents/cache/ccache/" + export CCACHE_UMASK=007 + if [ ! -d "$CCACHE_DIR" ]; then + echo "=====" + echo "Directory '$CCACHE_DIR' does not exist" + echo "Please create it with:" + echo " sudo mkdir -m0770 '$CCACHE_DIR'" + echo " sudo chown root:nixbld '$CCACHE_DIR'" + echo "=====" + exit 1 + fi + if [ ! -w "$CCACHE_DIR" ]; then + echo "=====" + echo "Directory '$CCACHE_DIR' is not accessible for user $(whoami)" + echo "Please verify its access permissions" + echo "=====" + exit 1 + fi + ''; + }; llama-cpp = prev.llama-cpp.overrideAttrs (old: rec { version = "8124"; src = prev.fetchFromGitHub { @@ -13,11 +37,13 @@ final: prev: { (pyFinal: pyPrev: { sseclient-py = pyPrev.sseclient-py.overridePythonAttrs (old: rec { format = "pyproject"; - nativeBuildInputs = (old.nativeBuildInputs or []) ++ (with pyPrev; [ - hatchling - #pypaBuildHook - #pypaInstallHook - ]); + nativeBuildInputs = + (old.nativeBuildInputs or [ ]) + ++ (with pyPrev; [ + hatchling + #pypaBuildHook + #pypaInstallHook + ]); doCheck = false; }); diff --git a/flake.nix b/flake.nix index 1f79ae5..926e62d 100644 --- a/flake.nix +++ b/flake.nix @@ -53,6 +53,7 @@ }; modules = [ ./custom/modules + ./custom/modules/llvm-ccache-stdenv.nix ragenix.nixosModules.default niri-flake.nixosModules.niri nix-index-database.nixosModules.default @@ -102,6 +103,7 @@ "root" "thek0tyara" ]; + extra-sandbox-paths = [ config.programs.ccache.cacheDir ]; download-buffer-size = 160000000; }; boot = { @@ -202,7 +204,13 @@ }; }; programs = { - ccache.enable = true; + ccache = { + enable = true; + ccacheDir = "/home/thek0tyara/Documents/cache/ccache/"; + packageNames = [ + # "linux" + ]; + }; niri = { enable = true; package = pkgs.niri-stable; From dbde18d4a2a8243d694a14b5f6a7f9e6fef59e3d Mon Sep 17 00:00:00 2001 From: TheK0tYaRa Date: Thu, 5 Mar 2026 17:58:47 +0200 Subject: [PATCH 3/6] fixup3 --- custom/modules/kernel.nix | 17 ++-- custom/modules/llvm-ccache-stdenv.nix | 25 +++-- custom/override.nix | 56 ++++++----- devenv.nix | 2 +- flake.lock | 130 ++++++++++++++++++-------- flake.nix | 51 +++++++--- home.nix | 25 ++++- 7 files changed, 210 insertions(+), 96 deletions(-) diff --git a/custom/modules/kernel.nix b/custom/modules/kernel.nix index 060e65f..4ddd67d 100644 --- a/custom/modules/kernel.nix +++ b/custom/modules/kernel.nix @@ -30,7 +30,7 @@ in pkgs.callPackage ( { buildLinux, ... }@args: let - llvm = pkgs.llvmPackages_latest; + # llvm = pkgs.llvmPackages_latest; structuredExtraConfig' = (with lib.kernel; { @@ -45,21 +45,24 @@ pkgs.callPackage ( // { inherit kernelPatches extraConfig; - stdenv = llvm.stdenv; + stdenv = pkgs.llvmPackages_latest.stdenv; version = kver; modDirVersion = kver; src = kernel-src; - nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ - llvm.clang - llvm.lld - llvm.llvm - ]; + # nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ + # llvm.clang + # llvm.lld + # llvm.llvm + # ]; makeFlags = (args.makeFlags or [ ]) ++ [ "LLVM=1" "LLVM_IAS=1" + + "CC=${pkgs.ccache}/bin/ccache clang" + "HOSTCC=${pkgs.ccache}/bin/ccache clang" ]; structuredExtraConfig = structuredExtraConfig'; diff --git a/custom/modules/llvm-ccache-stdenv.nix b/custom/modules/llvm-ccache-stdenv.nix index c5650a4..351f2bf 100644 --- a/custom/modules/llvm-ccache-stdenv.nix +++ b/custom/modules/llvm-ccache-stdenv.nix @@ -3,9 +3,8 @@ let cfg = config.programs.ccache; in -{ +if false then { config = lib.mkIf cfg.enable { - # ccache должен быть виден из sandbox nix.settings.extra-sandbox-paths = [ cfg.cacheDir ]; nixpkgs.overlays = [ @@ -35,19 +34,31 @@ in #!${prev.bash}/bin/bash set -euo pipefail + # Kernel probes compiler via: $CC -E -P -x c - + # Bypass ccache + filesystem touching for preprocess-only probes. + for arg in "$@"; do + if [ "$arg" = "-E" ]; then + exec __REAL__ "$@" + fi + done + # base cache dir from NixOS module base='${cfg.cacheDir}' # prefer pname (no version), fallback to name, and strip "-..." if present - pkg="${pname:-${name:-unknown}}" - pkg="${pkg%%-[0-9]*}" + pkg="''${pname-}" + if [ -z "$pkg" ]; then pkg="''${name-unknown}"; fi + pkg="''${pkg%%-[0-9]*}" - mkdir -p "$base/$pkg" + # If cache dir isn't writable/mounted in sandbox yet, don't break compiler detection. + if ! mkdir -p "$base/$pkg" 2>/dev/null; then + exec __REAL__ "$@" + fi export CCACHE_DIR="$base/$pkg" export CCACHE_UMASK=007 # improves hit rate for repeated local rebuilds - export CCACHE_BASEDIR="${NIX_BUILD_TOP:-/build}" + export CCACHE_BASEDIR="''${NIX_BUILD_TOP:-/build}" export CCACHE_COMPRESS=1 export CCACHE_SLOPPINESS=random_seed,time_macros @@ -88,4 +99,4 @@ in }) ]; }; -} \ No newline at end of file +} else {} \ No newline at end of file diff --git a/custom/override.nix b/custom/override.nix index 1b007ea..5dd54e3 100644 --- a/custom/override.nix +++ b/custom/override.nix @@ -1,28 +1,36 @@ final: prev: { - ccacheWrapper = prev.ccacheWrapper.override { - extraConfig = '' - export CCACHE_COMPRESS=1 - export CCACHE_SLOPPINESS=random_seed,time_macros - export CCACHE_DIR="/home/thek0tyara/Documents/cache/ccache/" - export CCACHE_UMASK=007 - if [ ! -d "$CCACHE_DIR" ]; then - echo "=====" - echo "Directory '$CCACHE_DIR' does not exist" - echo "Please create it with:" - echo " sudo mkdir -m0770 '$CCACHE_DIR'" - echo " sudo chown root:nixbld '$CCACHE_DIR'" - echo "=====" - exit 1 - fi - if [ ! -w "$CCACHE_DIR" ]; then - echo "=====" - echo "Directory '$CCACHE_DIR' is not accessible for user $(whoami)" - echo "Please verify its access permissions" - echo "=====" - exit 1 - fi - ''; - }; + # ccacheWrapper = prev.ccacheWrapper.override { + # extraConfig = '' + # export CCACHE_COMPRESS=1 + # export CCACHE_SLOPPINESS=random_seed,time_macros + # export CCACHE_COMPILERCHECK=content + # export CCACHE_DIR="/home/thek0tyara/Documents/cache/ccache/" + # export CCACHE_UMASK=007 + # if [ ! -d "$CCACHE_DIR" ]; then + # echo "=====" + # echo "Directory '$CCACHE_DIR' does not exist" + # echo "Please create it with:" + # echo " sudo mkdir -m0770 '$CCACHE_DIR'" + # echo " sudo chown root:nixbld '$CCACHE_DIR'" + # echo "=====" + # exit 1 + # fi + # if [ ! -w "$CCACHE_DIR" ]; then + # echo "=====" + # echo "Directory '$CCACHE_DIR' is not accessible for user $(whoami)" + # echo "Please verify its access permissions" + # echo "=====" + # exit 1 + # fi + # ''; + # }; + # xdg-desktop-portal-cosmic = prev.xdg-desktop-portal-cosmic.overrideAttrs (old: { + # postPatch = (old.postPatch or "") + '' + # unitDir="$out/lib/systemd/user" + # ln -sfn org.freedesktop.impl.portal.desktop.cosmic.service \ + # "$unitDir/xdg-desktop-portal-cosmic.service" + # ''; + # }); llama-cpp = prev.llama-cpp.overrideAttrs (old: rec { version = "8124"; src = prev.fetchFromGitHub { diff --git a/devenv.nix b/devenv.nix index 957a409..e2ac278 100644 --- a/devenv.nix +++ b/devenv.nix @@ -17,7 +17,7 @@ nix flake check ''; build.exec = '' - nixos-rebuild switch --sudo --flake '.#' $@ + sudo nixos-rebuild switch --flake '.#' $@ ''; }; diff --git a/flake.lock b/flake.lock index e156fea..fec81e8 100644 --- a/flake.lock +++ b/flake.lock @@ -27,11 +27,11 @@ "systems": "systems_5" }, "locked": { - "lastModified": 1736955230, - "narHash": "sha256-uenf8fv2eG5bKM8C/UvFaiJMZ4IpUFaQxk9OH5t/1gA=", + "lastModified": 1761656077, + "narHash": "sha256-lsNWuj4Z+pE7s0bd2OKicOFq9bK86JE0ZGeKJbNqb94=", "owner": "ryantm", "repo": "agenix", - "rev": "e600439ec4c273cf11e06fe4d9d906fb98fa097c", + "rev": "9ba0d85de3eaa7afeab493fed622008b6e4924f5", "type": "github" }, "original": { @@ -94,11 +94,11 @@ }, "crane_3": { "locked": { - "lastModified": 1741481578, - "narHash": "sha256-JBTSyJFQdO3V8cgcL08VaBUByEU6P5kXbTJN6R0PFQo=", + "lastModified": 1760924934, + "narHash": "sha256-tuuqY5aU7cUkR71sO2TraVKK2boYrdW3gCSXUkF4i44=", "owner": "ipetkov", "repo": "crane", - "rev": "bb1c9567c43e4434f54e9481eb4b8e8e0d50f0b5", + "rev": "c6b4d5308293d0d04fcfeee92705017537cad02f", "type": "github" }, "original": { @@ -116,11 +116,11 @@ ] }, "locked": { - "lastModified": 1700795494, - "narHash": "sha256-gzGLZSiOhf155FW7262kdHo2YDeugp3VuIFb4/GGng0=", + "lastModified": 1744478979, + "narHash": "sha256-dyN+teG9G82G+m+PX/aSAagkC+vUv0SgUw3XkPhQodQ=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "4b9b83d5a92e8c1fbfd8eb27eda375908c11ec4d", + "rev": "43975d782b418ebf4969e9ccba82466728c2851b", "type": "github" }, "original": { @@ -297,6 +297,24 @@ "type": "github" } }, + "flake-utils_2": { + "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" + } + }, "git-hooks": { "inputs": { "flake-compat": "flake-compat", @@ -395,11 +413,11 @@ ] }, "locked": { - "lastModified": 1772569491, - "narHash": "sha256-bdr6ueeXO1Xg91sFkuvaysYF0mVdwHBpdyhTjBEWv+s=", + "lastModified": 1772633327, + "narHash": "sha256-jl+DJB2DUx7EbWLRng+6HNWW/1/VQOnf0NsQB4PlA7I=", "owner": "nix-community", "repo": "home-manager", - "rev": "924e61f5c2aeab38504028078d7091077744ab17", + "rev": "5a75730e6f21ee624cbf86f4915c6e7489c74acc", "type": "github" }, "original": { @@ -438,11 +456,11 @@ ] }, "locked": { - "lastModified": 1703113217, - "narHash": "sha256-7ulcXOk63TIT2lVDSExj7XzFx09LpdSAPtvgtM7yQPE=", + "lastModified": 1745494811, + "narHash": "sha256-YZCh2o9Ua1n9uCvrvi5pRxtuVNml8X2a03qIFfRKpFs=", "owner": "nix-community", "repo": "home-manager", - "rev": "3bfaacf46133c037bb356193bd2f1765d9dc82c1", + "rev": "abfad3d2958c9e6300a883bd443512c55dfeb1be", "type": "github" }, "original": { @@ -484,10 +502,10 @@ "kernel-src": { "flake": false, "locked": { - "lastModified": 1772558248, - "narHash": "sha256-xv9+ldZjWEMJZVPTi5w7O4SDOI0lz5NcWvjgQGE1HCg=", + "lastModified": 1772720557, + "narHash": "sha256-lfOprDbqvgOqHzLuhsiuXdHk20qQJ9b8t97zOkTBxu4=", "ref": "drm-tip", - "rev": "cfc20c776480fda8c1b0517b187bb71ec0781cd4", + "rev": "9565ad1c312903452467b9f685c59e2f47f512e5", "shallow": true, "type": "git", "url": "https://gitlab.freedesktop.org/drm/tip.git" @@ -555,11 +573,11 @@ "xwayland-satellite-unstable": "xwayland-satellite-unstable" }, "locked": { - "lastModified": 1772572827, - "narHash": "sha256-d91kXM4t1G0KQ/MB0LTP514IslsDu6ZBt4HQE7hVvzs=", + "lastModified": 1772698812, + "narHash": "sha256-7+K/VaZ7TXUeUGSYshg8wC3UsRZHB+M4x6r38Q1B79c=", "owner": "sodiboo", "repo": "niri-flake", - "rev": "7592181859ad2ab12913bbede47b45481b2b2938", + "rev": "5641625ef950f024e3e0e3f38bb91f876290c0be", "type": "github" }, "original": { @@ -670,11 +688,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1772465433, - "narHash": "sha256-ywy9troNEfpgh0Ee+zaV1UTgU8kYBVKtvPSxh6clYGU=", + "lastModified": 1772598333, + "narHash": "sha256-YaHht/C35INEX3DeJQNWjNaTcPjYmBwwjFJ2jdtr+5U=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c581273b8d5bdf1c6ce7e0a54da9841e6a763913", + "rev": "fabb8c9deee281e50b1065002c9828f2cf7b2239", "type": "github" }, "original": { @@ -715,11 +733,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1772542754, - "narHash": "sha256-WGV2hy+VIeQsYXpsLjdr4GvHv5eECMISX1zKLTedhdg=", + "lastModified": 1772624091, + "narHash": "sha256-QKyJ0QGWBn6r0invrMAK8dmJoBYWoOWy7lN+UHzW1jc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "8c809a146a140c5c8806f13399592dbcb1bb5dc4", + "rev": "80bdc1e5ce51f56b19791b52b2901187931f5353", "type": "github" }, "original": { @@ -731,11 +749,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1741379970, - "narHash": "sha256-Wh7esNh7G24qYleLvgOSY/7HlDUzWaL/n4qzlBePpiw=", + "lastModified": 1761672384, + "narHash": "sha256-o9KF3DJL7g7iYMZq9SWgfS1BFlNbsm6xplRjVlOCkXI=", "owner": "nixos", "repo": "nixpkgs", - "rev": "36fd87baa9083f34f7f5027900b62ee6d09b1f2f", + "rev": "08dacfca559e1d7da38f3cf05f1f45ee9bfd213c", "type": "github" }, "original": { @@ -824,16 +842,15 @@ "rust-overlay": "rust-overlay_3" }, "locked": { - "lastModified": 1741508717, - "narHash": "sha256-iQf1WdNxaApOFHIx4RLMRZ4f8g+8Xp0Z1/E/Mz2rLxY=", + "lastModified": 1761832913, + "narHash": "sha256-VCNVjjuRvrKPiYYwqhE3BAKIaReiKXGpxGp27lZ0MFM=", "owner": "yaxitech", "repo": "ragenix", - "rev": "2a2bea99d74927e54adf53cbf113219def67d5c9", + "rev": "83bccfdea758241999f32869fb6b36f7ac72f1ac", "type": "github" }, "original": { "owner": "yaxitech", - "ref": "2025.03.09", "repo": "ragenix", "type": "github" } @@ -849,7 +866,8 @@ "nix-flatpak": "nix-flatpak", "nix-index-database": "nix-index-database", "nixpkgs": "nixpkgs_4", - "ragenix": "ragenix" + "ragenix": "ragenix", + "sccache": "sccache" } }, "rust-analyzer-src": { @@ -921,11 +939,11 @@ ] }, "locked": { - "lastModified": 1741400194, - "narHash": "sha256-tEpgT+q5KlGjHSm8MnINgTPErEl8YDzX3Eps8PVc09g=", + "lastModified": 1761791894, + "narHash": "sha256-myRIDh+PxaREz+z9LzbqBJF+SnTFJwkthKDX9zMyddY=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "16b6045a232fea0e9e4c69e55a6e269607dd8e3f", + "rev": "59c45eb69d9222a4362673141e00ff77842cd219", "type": "github" }, "original": { @@ -934,6 +952,27 @@ "type": "github" } }, + "sccache": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1772653484, + "narHash": "sha256-kHwbXkMrlKxo261U0oamF4YXGuUBbwexa8BWYErgKv0=", + "owner": "mozilla", + "repo": "sccache", + "rev": "30ed851a2b56ff3d754117895c76dbd8d10bbf13", + "type": "github" + }, + "original": { + "owner": "mozilla", + "repo": "sccache", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, @@ -1024,6 +1063,21 @@ "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_3" diff --git a/flake.nix b/flake.nix index 926e62d..445286c 100644 --- a/flake.nix +++ b/flake.nix @@ -5,7 +5,7 @@ url = "git+https://git.sys-con.ru/thek0tyara/nixpkgs-extension.git"; inputs.nixpkgs.follows = "nixpkgs"; }; - ragenix.url = "github:yaxitech/ragenix/2025.03.09"; + ragenix.url = "github:yaxitech/ragenix"; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; @@ -26,6 +26,10 @@ url = "git+https://gitlab.freedesktop.org/drm/tip.git?shallow=1&ref=drm-tip"; flake = false; }; + sccache = { + url = "github:mozilla/sccache"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = inputs@{ @@ -38,11 +42,26 @@ intel-hw, nix-flatpak, kernel-src, + sccache, ... }: let system = "x86_64-linux"; - # pkgs = nixpkgs.legacyPackages.${system}; + # pkgs = nixpkgs.${system}.packages; + pkgs = nixpkgs { + inherit system; + overlays = [ sccache.overlays.default ]; + }; + # + # sccacheWrapper = pkgs.writeShellScriptBin "clang-sccache" '' + # export SCCACHE_DIR=/var/cache/sccache + # exec ${pkgs.sccache}/bin/sccache ${pkgs.llvmPackages_latest.clang}/bin/clang "$@" + # ''; + # stdenvSccache = pkgs.overrideCC pkgs.llvmPackages_latest.stdenv ( + # pkgs.llvmPackages_latest.clang.override { + # cc = sccacheWrapper; + # } + # ); in { nixosConfigurations.testenv = nixpkgs.lib.nixosSystem { @@ -52,8 +71,8 @@ kernel-src = inputs.kernel-src; }; modules = [ - ./custom/modules - ./custom/modules/llvm-ccache-stdenv.nix + # ./custom/modules + # ./custom/modules/llvm-ccache-stdenv.nix ragenix.nixosModules.default niri-flake.nixosModules.niri nix-index-database.nixosModules.default @@ -145,7 +164,7 @@ LLAMA_CACHE = "/home/thek0tyara/Downloads/llm"; - CCACHE_DIR = "/mnt/HDD_A_DATA/ccache"; + # CCACHE_DIR = "/mnt/HDD_A_DATA/ccache"; # LLVM = "1"; # UV_CACHE_DIR = ""; @@ -154,7 +173,7 @@ }; systemPackages = with pkgs; [ ### compiler - ccache + # ccache sccache (pkgdefault inputs.ragenix) devenv @@ -197,6 +216,10 @@ command = "/run/current-system/sw/bin/nix"; options = [ "NOPASSWD" ]; } + { + command = "/run/current-system/sw/bin/nixos-rebuild"; + options = [ "NOPASSWD" ]; + } ]; groups = [ "wheel" ]; } @@ -204,16 +227,16 @@ }; }; programs = { - ccache = { - enable = true; - ccacheDir = "/home/thek0tyara/Documents/cache/ccache/"; - packageNames = [ - # "linux" - ]; - }; + # ccache = { + # enable = true; + # cacheDir = "/home/thek0tyara/Documents/cache/ccache/"; + # packageNames = [ + # # "linux" + # ]; + # }; niri = { enable = true; - package = pkgs.niri-stable; + package = pkgs.niri; }; nix-ld = { enable = true; diff --git a/home.nix b/home.nix index f6f6d2f..3bfdcf9 100644 --- a/home.nix +++ b/home.nix @@ -55,6 +55,7 @@ xwayland-satellite winboat xfce4-taskmanager + xdg-desktop-portal-cosmic ### file management cosmic-files @@ -66,6 +67,10 @@ ### development # idea-community-bin + ### visuals + gnome-themes-extra + papirus-icon-theme + ### vlc jq @@ -73,8 +78,7 @@ tor-browser iperf sshuttle - - lmstudio + nautilus ### social # fluffychat @@ -86,6 +90,10 @@ vintagestory prismlauncher + ### neural networks + dsearch + lmstudio + # kdePackages.kdenlive (python313.withPackages ( py: with py; [ @@ -162,10 +170,17 @@ extraPortals = with pkgs; [ xdg-desktop-portal-gtk xdg-desktop-portal-wlr - xdg-desktop-portal-gnome + # xdg-desktop-portal-gnome + xdg-desktop-portal-cosmic ]; config = { - common.default = "*"; + common = { + default = [ + "gtk" + ]; + "org.freedesktop.impl.portal.FileChooser" = "gnome"; + # "org.freedesktop.impl.portal.ScreenCast" = "gnome"; + }; }; }; configFile."obsidian/.keep".text = ""; @@ -450,7 +465,7 @@ sudo nix-store --optimise ''; xdg-fix = '' - systemctl --user restart xdg-desktop-portal xdg-desktop-portal-gtk xdg-desktop-portal-wlr xdg-desktop-portal-gnome + systemctl --user restart 'xdg-desktop-portal*' ''; }; }; From 33f5ff901997bf1e1e300b32452a050098a6dccc Mon Sep 17 00:00:00 2001 From: TheK0tYaRa Date: Sat, 7 Mar 2026 10:53:27 +0200 Subject: [PATCH 4/6] fixup --- .gitignore | 3 + custom/modules/kernel.nix | 84 +++++++++++++++++---- custom/modules/llvm-ccache-stdenv.nix | 102 -------------------------- custom/override.nix | 50 +++++++++++++ devenv.nix | 2 +- flake.lock | 18 ++--- flake.nix | 20 ++--- home.nix | 13 +++- 8 files changed, 152 insertions(+), 140 deletions(-) delete mode 100644 custom/modules/llvm-ccache-stdenv.nix diff --git a/.gitignore b/.gitignore index d90015c..ee74d74 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ devenv.local.yaml # ide .vscode/settings.json + +# nix +result diff --git a/custom/modules/kernel.nix b/custom/modules/kernel.nix index 4ddd67d..d37e611 100644 --- a/custom/modules/kernel.nix +++ b/custom/modules/kernel.nix @@ -5,6 +5,8 @@ structuredExtraConfig ? { }, kernelPatches ? [ ], extraConfig ? "", + sccacheDir ? "/var/cache/sccache", + enforceSccache ? true, }: let @@ -30,7 +32,41 @@ in pkgs.callPackage ( { buildLinux, ... }@args: let - # llvm = pkgs.llvmPackages_latest; + llvm = pkgs.llvmPackages_latest; + + # buildLinux uses common-flags.nix which sets CC to the *unwrapped* compiler: + # CC=${lib.getExe stdenv.cc.cc} + # and appends extraMakeFlags at the end. :contentReference[oaicite:1]{index=1} + realClang = lib.getExe llvm.clang-unwrapped; + + # Host tools are built with buildPackages.stdenv.cc (see common-flags HOSTCC). :contentReference[oaicite:2]{index=2} + buildPkgs = args.buildPackages or pkgs.buildPackages; + realHostCC = lib.getExe' buildPkgs.stdenv.cc "${buildPkgs.stdenv.cc.targetPrefix}cc"; + realHostCXX = lib.getExe' buildPkgs.stdenv.cc "${buildPkgs.stdenv.cc.targetPrefix}c++"; + + clangSccache = pkgs.writeShellScriptBin "clang" '' + set -euo pipefail + : "''${SCCACHE_ENFORCE_MARKER:?SCCACHE_ENFORCE_MARKER is not set}" + : > "''${SCCACHE_ENFORCE_MARKER}" + export SCCACHE_DIR=${lib.escapeShellArg sccacheDir} + exec ${pkgs.sccache}/bin/sccache ${realClang} "$@" + ''; + + hostccSccache = pkgs.writeShellScriptBin "cc" '' + set -euo pipefail + : "''${SCCACHE_ENFORCE_MARKER:?SCCACHE_ENFORCE_MARKER is not set}" + : > "''${SCCACHE_ENFORCE_MARKER}" + export SCCACHE_DIR=${lib.escapeShellArg sccacheDir} + exec ${pkgs.sccache}/bin/sccache ${realHostCC} "$@" + ''; + + hostcxxSccache = pkgs.writeShellScriptBin "c++" '' + set -euo pipefail + : "''${SCCACHE_ENFORCE_MARKER:?SCCACHE_ENFORCE_MARKER is not set}" + : > "''${SCCACHE_ENFORCE_MARKER}" + export SCCACHE_DIR=${lib.escapeShellArg sccacheDir} + exec ${pkgs.sccache}/bin/sccache ${realHostCXX} "$@" + ''; structuredExtraConfig' = (with lib.kernel; { @@ -45,25 +81,45 @@ pkgs.callPackage ( // { inherit kernelPatches extraConfig; - stdenv = pkgs.llvmPackages_latest.stdenv; - version = kver; modDirVersion = kver; src = kernel-src; - # nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ - # llvm.clang - # llvm.lld - # llvm.llvm - # ]; + stdenv = llvm.stdenv; - makeFlags = (args.makeFlags or [ ]) ++ [ - "LLVM=1" - "LLVM_IAS=1" + extraMakeFlags = + (args.extraMakeFlags or [ ]) + ++ [ + "LLVM=1" + "LLVM_IAS=1" + ] + ++ lib.optionals enforceSccache [ + "CC=${lib.getExe clangSccache}" + "HOSTCC=${lib.getExe hostccSccache}" + "HOSTCXX=${lib.getExe hostcxxSccache}" + ]; - "CC=${pkgs.ccache}/bin/ccache clang" - "HOSTCC=${pkgs.ccache}/bin/ccache clang" - ]; + # Enforce that the wrappers were actually invoked at least once. + # sccache is a compiler wrapper; this is the contract we’re enforcing. :contentReference[oaicite:4]{index=4} + preBuild = + (args.preBuild or "") + + lib.optionalString enforceSccache '' + export SCCACHE_ENFORCE_MARKER="$NIX_BUILD_TOP/.sccache-used" + rm -f "$SCCACHE_ENFORCE_MARKER" + ${pkgs.sccache}/bin/sccache --start-server || true + ${pkgs.sccache}/bin/sccache --zero-stats || true + ''; + + postBuild = + (args.postBuild or "") + + lib.optionalString enforceSccache '' + if [ ! -e "$SCCACHE_ENFORCE_MARKER" ]; then + echo "FATAL: sccache enforcement failed: compiler wrappers were not invoked." + echo "This means buildLinux did not use your CC/HOSTCC overrides." + exit 1 + fi + ${pkgs.sccache}/bin/sccache --show-stats --stats-format text || true + ''; structuredExtraConfig = structuredExtraConfig'; diff --git a/custom/modules/llvm-ccache-stdenv.nix b/custom/modules/llvm-ccache-stdenv.nix deleted file mode 100644 index 351f2bf..0000000 --- a/custom/modules/llvm-ccache-stdenv.nix +++ /dev/null @@ -1,102 +0,0 @@ -{ config, lib, ... }: - -let - cfg = config.programs.ccache; -in -if false then { - config = lib.mkIf cfg.enable { - nix.settings.extra-sandbox-paths = [ cfg.cacheDir ]; - - nixpkgs.overlays = [ - (final: prev: - let - llvm = prev.llvmPackages_latest; - - realClang = llvm.clang-unwrapped; - realClangLib = prev.lib.getLib realClang; - - # "unwrapped clang", но с ccache + per-package CCACHE_DIR - clangUnwrappedCcache = - prev.stdenvNoCC.mkDerivation { - pname = "clang-unwrapped-ccache"; - version = realClang.version; - - outputs = [ "out" "lib" ]; - dontUnpack = true; - - installPhase = '' - mkdir -p "$out/bin" "$lib/lib" - - mkwrap() { - local name="$1" - local real="$2" - cat > "$out/bin/$name" <<'EOF' - #!${prev.bash}/bin/bash - set -euo pipefail - - # Kernel probes compiler via: $CC -E -P -x c - - # Bypass ccache + filesystem touching for preprocess-only probes. - for arg in "$@"; do - if [ "$arg" = "-E" ]; then - exec __REAL__ "$@" - fi - done - - # base cache dir from NixOS module - base='${cfg.cacheDir}' - - # prefer pname (no version), fallback to name, and strip "-..." if present - pkg="''${pname-}" - if [ -z "$pkg" ]; then pkg="''${name-unknown}"; fi - pkg="''${pkg%%-[0-9]*}" - - # If cache dir isn't writable/mounted in sandbox yet, don't break compiler detection. - if ! mkdir -p "$base/$pkg" 2>/dev/null; then - exec __REAL__ "$@" - fi - export CCACHE_DIR="$base/$pkg" - export CCACHE_UMASK=007 - - # improves hit rate for repeated local rebuilds - export CCACHE_BASEDIR="''${NIX_BUILD_TOP:-/build}" - export CCACHE_COMPRESS=1 - export CCACHE_SLOPPINESS=random_seed,time_macros - - exec ${prev.ccache}/bin/ccache __REAL__ "$@" - EOF - substituteInPlace "$out/bin/$name" --replace "__REAL__" "$real" - chmod +x "$out/bin/$name" - } - - mkwrap clang ${realClang}/bin/clang - mkwrap clang++ ${realClang}/bin/clang++ - - ln -s "$out/bin/clang" "$out/bin/cc" - ln -s "$out/bin/clang++" "$out/bin/c++" - - # make lib.getLib(stdenv.cc.cc) point to real clang builtin headers - ln -s ${realClangLib}/lib/clang "$lib/lib/clang" - ''; - - meta = (realClang.meta or { }) // { - mainProgram = "clang"; - }; - }; - - # Wrapped clang package that points its "unwrapped" to our ccache one - clangWrappedCcache = llvm.clang.override { cc = clangUnwrappedCcache; }; - - # New stdenv: same llvm stdenv, but compiler wrapper uses our ccache-unwrapped clang - llvmCcacheStdenv = prev.overrideCC llvm.stdenv clangWrappedCcache; - - in - { - llvmPackages_latest = llvm // { - stdenv = llvmCcacheStdenv; - clang = clangWrappedCcache; - clang-unwrapped = clangUnwrappedCcache; - }; - }) - ]; - }; -} else {} \ No newline at end of file diff --git a/custom/override.nix b/custom/override.nix index 5dd54e3..d869133 100644 --- a/custom/override.nix +++ b/custom/override.nix @@ -31,6 +31,56 @@ final: prev: { # "$unitDir/xdg-desktop-portal-cosmic.service" # ''; # }); + # codex = prev.codex.overrideAttrs ( + # old: + # let + # version = "0.111.0"; + # src = prev.fetchFromGitHub { + # owner = "openai"; + # repo = "codex"; + # tag = "rust-v${version}"; + # hash = "sha256-hdR70BhiMg9G/ibLCeHnRSY3PcGZDv0vnqBCbzSRD6I="; + # }; + # in + # { + # cargoDeps = old.cargoDeps.overrideAttrs (_: { + # inherit src; + # name = "codex-${version}-vendor.tar.gz"; + # sourceRoot = "${src.name}/codex-rs"; + # outputHash = "sha256-FR0GQenZ6CFhHUdi3FnuwIsqo0argAJo5STBwlGCsdg="; + # outputHashMode = "recursive"; + # }); + # } + # ); + codex = prev.codex.overrideAttrs ( + old: + let + version = "0.111.0"; + src = prev.fetchFromGitHub { + owner = "openai"; + repo = "codex"; + tag = "rust-v${version}"; + hash = "sha256-hdR70BhiMg9G/ibLCeHnRSY3PcGZDv0vnqBCbzSRD6I="; + }; + in + { + inherit version src; + sourceRoot = "${src.name}/codex-rs"; + + cargoDeps = prev.rustPlatform.fetchCargoVendor { + inherit src; + sourceRoot = "${src.name}/codex-rs"; + hash = "sha256-h+TIwNz+A6aYcMACWl//LiavABITZxwYa4CvawR/0RQ="; + }; + + buildInputs = (old.buildInputs or [ ]) ++ [ prev.libcap ]; + + preBuild = (old.preBuild or "") + '' + export CARGO_PROFILE_RELEASE_LTO=thin + export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=8 + ''; + } + ); llama-cpp = prev.llama-cpp.overrideAttrs (old: rec { version = "8124"; src = prev.fetchFromGitHub { diff --git a/devenv.nix b/devenv.nix index e2ac278..957a409 100644 --- a/devenv.nix +++ b/devenv.nix @@ -17,7 +17,7 @@ nix flake check ''; build.exec = '' - sudo nixos-rebuild switch --flake '.#' $@ + nixos-rebuild switch --sudo --flake '.#' $@ ''; }; diff --git a/flake.lock b/flake.lock index fec81e8..047c74a 100644 --- a/flake.lock +++ b/flake.lock @@ -413,11 +413,11 @@ ] }, "locked": { - "lastModified": 1772633327, - "narHash": "sha256-jl+DJB2DUx7EbWLRng+6HNWW/1/VQOnf0NsQB4PlA7I=", + "lastModified": 1772845525, + "narHash": "sha256-Dp5Ir2u4jJDGCgeMRviHvEQDe+U37hMxp6RSNOoMMPc=", "owner": "nix-community", "repo": "home-manager", - "rev": "5a75730e6f21ee624cbf86f4915c6e7489c74acc", + "rev": "27b93804fbef1544cb07718d3f0a451f4c4cd6c0", "type": "github" }, "original": { @@ -502,10 +502,10 @@ "kernel-src": { "flake": false, "locked": { - "lastModified": 1772720557, - "narHash": "sha256-lfOprDbqvgOqHzLuhsiuXdHk20qQJ9b8t97zOkTBxu4=", + "lastModified": 1772838933, + "narHash": "sha256-77MlrOVBethsi2wbq0eQx+m6AzNoBWCD8b82B1yUX04=", "ref": "drm-tip", - "rev": "9565ad1c312903452467b9f685c59e2f47f512e5", + "rev": "fce8d7fb2107068c269b868d51aba5f9cf85998a", "shallow": true, "type": "git", "url": "https://gitlab.freedesktop.org/drm/tip.git" @@ -960,11 +960,11 @@ ] }, "locked": { - "lastModified": 1772653484, - "narHash": "sha256-kHwbXkMrlKxo261U0oamF4YXGuUBbwexa8BWYErgKv0=", + "lastModified": 1772751120, + "narHash": "sha256-4cBOTPXv6Pkqa6qL1SH3UZTShciQWpyKJy3c3cQEU8I=", "owner": "mozilla", "repo": "sccache", - "rev": "30ed851a2b56ff3d754117895c76dbd8d10bbf13", + "rev": "2b65ac80ed3a3ff63c41711d65ae10106a163a09", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 445286c..85ce8b7 100644 --- a/flake.nix +++ b/flake.nix @@ -52,16 +52,6 @@ inherit system; overlays = [ sccache.overlays.default ]; }; - # - # sccacheWrapper = pkgs.writeShellScriptBin "clang-sccache" '' - # export SCCACHE_DIR=/var/cache/sccache - # exec ${pkgs.sccache}/bin/sccache ${pkgs.llvmPackages_latest.clang}/bin/clang "$@" - # ''; - # stdenvSccache = pkgs.overrideCC pkgs.llvmPackages_latest.stdenv ( - # pkgs.llvmPackages_latest.clang.override { - # cc = sccacheWrapper; - # } - # ); in { nixosConfigurations.testenv = nixpkgs.lib.nixosSystem { @@ -72,7 +62,6 @@ }; modules = [ # ./custom/modules - # ./custom/modules/llvm-ccache-stdenv.nix ragenix.nixosModules.default niri-flake.nixosModules.niri nix-index-database.nixosModules.default @@ -122,9 +111,15 @@ "root" "thek0tyara" ]; - extra-sandbox-paths = [ config.programs.ccache.cacheDir ]; + extra-sandbox-paths = [ + "/var/cache/sccache" + ]; download-buffer-size = 160000000; }; + systemd.tmpfiles.rules = [ + # setgid, чтобы файлы/папки сохраняли группу nixbld + "d /var/cache/sccache 2770 root nixbld - -" + ]; boot = { loader = { systemd-boot.enable = true; @@ -165,6 +160,7 @@ LLAMA_CACHE = "/home/thek0tyara/Downloads/llm"; # CCACHE_DIR = "/mnt/HDD_A_DATA/ccache"; + # SCCACHE_DIR = "/home/thek0tyara/Documents/cache/sccache"; # LLVM = "1"; # UV_CACHE_DIR = ""; diff --git a/home.nix b/home.nix index 3bfdcf9..ac2696b 100644 --- a/home.nix +++ b/home.nix @@ -66,6 +66,7 @@ ### development # idea-community-bin + sccache ### visuals gnome-themes-extra @@ -170,7 +171,7 @@ extraPortals = with pkgs; [ xdg-desktop-portal-gtk xdg-desktop-portal-wlr - # xdg-desktop-portal-gnome + xdg-desktop-portal-gnome xdg-desktop-portal-cosmic ]; config = { @@ -179,7 +180,7 @@ "gtk" ]; "org.freedesktop.impl.portal.FileChooser" = "gnome"; - # "org.freedesktop.impl.portal.ScreenCast" = "gnome"; + "org.freedesktop.impl.portal.ScreenCast" = "gnome"; }; }; }; @@ -434,6 +435,14 @@ ### default aria2.enable = true; btop.enable = true; + codex = { + enable = true; + settings = { + model = "gpt-5.4"; + approval_policy = "on-request"; + model_reasoning_effort = "medium"; + }; + }; # command-not-found.enable = true; direnv = { enable = true; From e650dfe222d2b98d2c35e7172cac884c59054914 Mon Sep 17 00:00:00 2001 From: TheK0tYaRa Date: Sat, 7 Mar 2026 23:47:21 +0200 Subject: [PATCH 5/6] fixup --- devenv.lock | 80 ++++++++--------------------------------------------- flake.lock | 24 ++++++++-------- home.nix | 3 +- 3 files changed, 25 insertions(+), 82 deletions(-) diff --git a/devenv.lock b/devenv.lock index 987f72f..8ded817 100644 --- a/devenv.lock +++ b/devenv.lock @@ -3,10 +3,11 @@ "devenv": { "locked": { "dir": "src/modules", - "lastModified": 1771066302, + "lastModified": 1772909021, + "narHash": "sha256-XardsHAeueL09beWx7Z6g0Rb8GZyg5cYz4wqpOkAhcw=", "owner": "cachix", "repo": "devenv", - "rev": "1b355dec9bddbaddbe4966d6fc30d7aa3af8575b", + "rev": "ff810b7556261e3034f3a8f7006acdb7ff9b26b2", "type": "github" }, "original": { @@ -16,71 +17,16 @@ "type": "github" } }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1767039857, - "owner": "NixOS", - "repo": "flake-compat", - "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "flake-compat", - "type": "github" - } - }, - "git-hooks": { - "inputs": { - "flake-compat": "flake-compat", - "gitignore": "gitignore", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1770726378, - "owner": "cachix", - "repo": "git-hooks.nix", - "rev": "5eaaedde414f6eb1aea8b8525c466dc37bba95ae", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "git-hooks.nix", - "type": "github" - } - }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "git-hooks", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1762808025, - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "cb5e3fdca1de58ccbc3ef53de65bd372b48f567c", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, "nixpkgs": { "inputs": { "nixpkgs-src": "nixpkgs-src" }, "locked": { - "lastModified": 1770434727, + "lastModified": 1772749504, + "narHash": "sha256-eqtQIz0alxkQPym+Zh/33gdDjkkch9o6eHnMPnXFXN0=", "owner": "cachix", "repo": "devenv-nixpkgs", - "rev": "8430f16a39c27bdeef236f1eeb56f0b51b33d348", + "rev": "08543693199362c1fddb8f52126030d0d374ba2e", "type": "github" }, "original": { @@ -93,11 +39,11 @@ "nixpkgs-src": { "flake": false, "locked": { - "lastModified": 1769922788, - "narHash": "sha256-H3AfG4ObMDTkTJYkd8cz1/RbY9LatN5Mk4UF48VuSXc=", + "lastModified": 1772173633, + "narHash": "sha256-MOH58F4AIbCkh6qlQcwMycyk5SWvsqnS/TCfnqDlpj4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "207d15f1a6603226e1e223dc79ac29c7846da32e", + "rev": "c0f3d81a7ddbc2b1332be0d8481a672b4f6004d6", "type": "github" }, "original": { @@ -110,14 +56,10 @@ "root": { "inputs": { "devenv": "devenv", - "git-hooks": "git-hooks", - "nixpkgs": "nixpkgs", - "pre-commit-hooks": [ - "git-hooks" - ] + "nixpkgs": "nixpkgs" } } }, "root": "root", "version": 7 -} +} \ No newline at end of file diff --git a/flake.lock b/flake.lock index 047c74a..dbc26c7 100644 --- a/flake.lock +++ b/flake.lock @@ -573,11 +573,11 @@ "xwayland-satellite-unstable": "xwayland-satellite-unstable" }, "locked": { - "lastModified": 1772698812, - "narHash": "sha256-7+K/VaZ7TXUeUGSYshg8wC3UsRZHB+M4x6r38Q1B79c=", + "lastModified": 1772884214, + "narHash": "sha256-nl1U1E9Kk9ZmxWdqcwBuFaljxknbrwq8/bY+utQSajk=", "owner": "sodiboo", "repo": "niri-flake", - "rev": "5641625ef950f024e3e0e3f38bb91f876290c0be", + "rev": "3fc5b3670ef77356173ca5f1fa5015e01204bc33", "type": "github" }, "original": { @@ -606,11 +606,11 @@ "niri-unstable": { "flake": false, "locked": { - "lastModified": 1772207631, - "narHash": "sha256-Jkkg+KqshFO3CbTszVVpkKN2AOObYz+wMsM3ONo1z5g=", + "lastModified": 1772873827, + "narHash": "sha256-T1igKylw0ZX8+yws4dWbkrSc+hZ1bmsM+Tjs4lxMYgo=", "owner": "YaLTeR", "repo": "niri", - "rev": "e708f546153f74acf33eb183b3b2992587a701e5", + "rev": "8f75d171b6017ed34043b1255ec4ffc374bf6ab0", "type": "github" }, "original": { @@ -688,11 +688,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1772598333, - "narHash": "sha256-YaHht/C35INEX3DeJQNWjNaTcPjYmBwwjFJ2jdtr+5U=", + "lastModified": 1772822230, + "narHash": "sha256-yf3iYLGbGVlIthlQIk5/4/EQDZNNEmuqKZkQssMljuw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "fabb8c9deee281e50b1065002c9828f2cf7b2239", + "rev": "71caefce12ba78d84fe618cf61644dce01cf3a96", "type": "github" }, "original": { @@ -733,11 +733,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1772624091, - "narHash": "sha256-QKyJ0QGWBn6r0invrMAK8dmJoBYWoOWy7lN+UHzW1jc=", + "lastModified": 1772773019, + "narHash": "sha256-E1bxHxNKfDoQUuvriG71+f+s/NT0qWkImXsYZNFFfCs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "80bdc1e5ce51f56b19791b52b2901187931f5353", + "rev": "aca4d95fce4914b3892661bcb80b8087293536c6", "type": "github" }, "original": { diff --git a/home.nix b/home.nix index ac2696b..f3b1eca 100644 --- a/home.nix +++ b/home.nix @@ -56,6 +56,7 @@ winboat xfce4-taskmanager xdg-desktop-portal-cosmic + file ### file management cosmic-files @@ -86,7 +87,7 @@ ### gaming winetricks - wine + wineWow64Packages.full heroic vintagestory prismlauncher From 886dded72594efa927266995181504a9bc2a54f7 Mon Sep 17 00:00:00 2001 From: TheK0tYaRa Date: Sun, 8 Mar 2026 00:20:18 +0200 Subject: [PATCH 6/6] sorting reorder --- custom/override.nix | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/custom/override.nix b/custom/override.nix index d869133..e906059 100644 --- a/custom/override.nix +++ b/custom/override.nix @@ -93,18 +93,6 @@ final: prev: { }); pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ (pyFinal: pyPrev: { - sseclient-py = pyPrev.sseclient-py.overridePythonAttrs (old: rec { - format = "pyproject"; - nativeBuildInputs = - (old.nativeBuildInputs or [ ]) - ++ (with pyPrev; [ - hatchling - #pypaBuildHook - #pypaInstallHook - ]); - doCheck = false; - }); - haystack-ai = pyPrev.haystack-ai.overridePythonAttrs (old: rec { version = "2.24.1"; @@ -131,6 +119,17 @@ final: prev: { broken = false; }; }); + sseclient-py = pyPrev.sseclient-py.overridePythonAttrs (old: rec { + format = "pyproject"; + nativeBuildInputs = + (old.nativeBuildInputs or [ ]) + ++ (with pyPrev; [ + hatchling + #pypaBuildHook + #pypaInstallHook + ]); + doCheck = false; + }); }) ]; winetricks = prev.winetricks.overrideAttrs (