feat(features): gate Claude Code on the host CPU microarchitecture level
Claude Code runs on Node, whose V8 build requires SSE4.2 and POPCNT (x86-64-v2). On an older x86_64 CPU it does not run, so it must not be installed there in the first place. Nix cannot detect the CPU (pure evaluation, hosts often built elsewhere), so add features.cpu.microarchLevel: the psABI level a host declares about itself, defaulting to 2. features.claudeCode.enable derives from it, and home/claude.nix reads that through home-manager's osConfig and installs nothing -- CLI, CLAUDE.md, output style or memory symlink -- when it is off. Hosts without the option (Darwin, the standalone homeConfigurations) keep the tool enabled. An assertion fails evaluation if a host force-enables the flag below the required level, so the mistake surfaces in nix flake check rather than as an illegal-instruction crash on the machine.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
# NVIDIA Quadro P400 (Pascal, GP108) on the Mac Pro 3,1: proprietary driver for
|
||||
# the Sway desktop, plus Docker with GPU/CUDA access for containers.
|
||||
#
|
||||
# Driver branch: 580 (nvidiaPackages.legacy_580), NOT the nixpkgs default
|
||||
# (`production`, currently 595.x). 580 is the last branch that supports
|
||||
# Maxwell/Pascal/Volta -- NVIDIA keeps it as an LTS branch to Aug 2028 -- and a
|
||||
# newer branch simply will not drive this card.
|
||||
#
|
||||
# The driver is unfree, so it is not in the binary cache: the kernel module is
|
||||
# compiled locally. On this machine's 2008 Xeons expect the first rebuild after
|
||||
# a kernel bump to take a long while.
|
||||
{ config, ... }:
|
||||
|
||||
{
|
||||
# Selects the proprietary driver; the module blacklists nouveau/nvidiafb and
|
||||
# loads nvidia-uvm (needed by CUDA) via modprobe softdep. Naming is historical
|
||||
# -- this option drives the kernel/driver choice on Wayland hosts too, which
|
||||
# is why it is set on a machine that runs no X server.
|
||||
services.xserver.videoDrivers = [ "nvidia" ];
|
||||
|
||||
hardware.nvidia = {
|
||||
package = config.boot.kernelPackages.nvidiaPackages.legacy_580;
|
||||
# Required for Wayland: sets nvidia-drm.modeset=1 (and fbdev=1), without
|
||||
# which wlroots gets no GBM device and Sway/cage fail to start.
|
||||
modesetting.enable = true;
|
||||
# The open kernel modules need Turing or later; Pascal must use the closed
|
||||
# ones. Explicit because the option has no default on driver >= 560.
|
||||
open = false;
|
||||
};
|
||||
|
||||
# wlroots refuses the proprietary NVIDIA driver unless told to proceed. The
|
||||
# greeter's compositor (cage) has no such check; only Sway needs the flag,
|
||||
# which the module bakes into the wrapper the session's .desktop file runs.
|
||||
programs.sway.extraOptions = [ "--unsupported-gpu" ];
|
||||
|
||||
virtualisation.docker.enable = true;
|
||||
|
||||
# CDI-based GPU access for containers: generates /var/run/cdi specs from the
|
||||
# host driver at boot and turns on Docker's CDI feature. Run GPU workloads
|
||||
# with `docker run --device=nvidia.com/gpu=all ...`. The deprecated
|
||||
# virtualisation.docker.enableNvidia runtime wrapper is deliberately not used.
|
||||
hardware.nvidia-container-toolkit.enable = true;
|
||||
}
|
||||
Reference in New Issue
Block a user