[Bug] Inaccurate Nix/NixOS Code Generation and Hallucination
Resolved 💬 2 comments Opened Sep 21, 2025 by behrangsa Closed Nov 1, 2025
Bug Description
Claude Code's knowledge and understanding of Nix and NixOS is abysmal and useless, most often wrong and hallucinated, indistinguishable from lies. Here Opus generated a flake.nix for me. OpenAI Codex found various issues in it and fixed it. I feedback Codex's review to Opus and eventually it accepted that Codex was correct and it was wrong.
Here's where Opus admits it was wrong:
● You're absolutely right. After reconsidering each point: 1. cargo-tarpaulin: I was mistaken - it's indeed packaged in nixpkgs-unstable, so pkgs.cargo-tarpaulin works fine. 2. buildRustPackage: This is the standard Rust builder in nixpkgs. While naersk/crane offer some benefits, they're not necessary here and wouldn't solve incremental builds for source changes anyway. 3. Cargo.lock: Requiring it for reproducible builds is correct behavior, not a gap. 4. OpenSSL duplication: The duplication is functional and intentional - shell needs exported vars, package needs build-time vars. Current approach is correct. 5. Version hardcoding: Standard practice, not an issue. 6. pre-commit-hooks.nix: Nice-to-have for a hooks manager, but not a correctness issue. 7. Cachix: Belongs in CI/ops configuration, not the flake. 8. Shell hook: I misread - it doesn't mention platform-specific commands, just general cargo commands. The flake.nix is actually well-written and follows Nix best practices. My initial review was overly critical and contained factual errors. The only potential minor enhancement would be inheriting shellVars in the package definition to reduce duplication, but even that's aesthetic rather than functional.
Environment Info
- Platform: linux
- Terminal: ghostty
- Version: 1.0.120
- Feedback ID: 860fb0d2-7de5-4fc9-94b9-bb72994704d8
Errors
[{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n at iV (file:///home/amadeus/.local/share/npm/lib/node_modules/@anthropic-ai/claude-code/cli.js:1794:1184)\n at file:///home/amadeus/.local/share/npm/lib/node_modules/@anthropic-ai/claude-code/cli.js:1794:912\n at Array.map (<anonymous>)\n at TX (file:///home/amadeus/.local/share/npm/lib/node_modules/@anthropic-ai/claude-code/cli.js:1794:903)\n at IUB (file:///home/amadeus/.local/share/npm/lib/node_modules/@anthropic-ai/claude-code/cli.js:3032:14086)\n at QC (file:///home/amadeus/.local/share/npm/lib/node_modules/@anthropic-ai/claude-code/cli.js:84:19415)\n at Jp (file:///home/amadeus/.local/share/npm/lib/node_modules/@anthropic-ai/claude-code/cli.js:86:42814)\n at W9 (file:///home/amadeus/.local/share/npm/lib/node_modules/@anthropic-ai/claude-code/cli.js:86:38355)\n at Hh (file:///home/amadeus/.local/share/npm/lib/node_modules/@anthropic-ai/claude-code/cli.js:86:38283)\n at zC (file:///home/amadeus/.local/share/npm/lib/node_modules/@anthropic-ai/claude-code/cli.js:86:38137)","timestamp":"2025-09-21T02:59:31.313Z"}]
Here's the flake.nix under question FYI:
{
description = "Samoyed - A modern, minimal, cross-platform Git hooks manager";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, rust-overlay, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
lib = pkgs.lib;
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [
"rust-src"
"rustfmt"
"clippy"
"llvm-tools-preview"
];
};
rustPlatform = pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
};
commonNativeBuildInputs = with pkgs; [
rustToolchain
pkg-config
git
];
devNativeBuildInputs = commonNativeBuildInputs ++ [ pkgs.cargo-tarpaulin ];
# Build inputs including OpenSSL development libraries
buildInputs = with pkgs; [
openssl
openssl.dev
] ++ lib.optionals pkgs.stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];
# Environment variables for OpenSSL
shellVars = {
OPENSSL_DIR = "${pkgs.openssl.dev}";
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include";
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
};
in
{
devShells.default = pkgs.mkShell (shellVars // {
buildInputs = buildInputs;
nativeBuildInputs = devNativeBuildInputs;
shellHook = ''
echo "🐕 Samoyed development environment"
echo "Rust toolchain: ${rustToolchain.name} (with rustfmt, clippy)"
echo "OpenSSL: ${pkgs.openssl.version}"
echo "cargo-tarpaulin: ${pkgs.cargo-tarpaulin.version}"
echo ""
echo "Available commands:"
echo " cargo build - Build the project"
echo " cargo test - Run tests"
echo " cargo clippy - Run linter"
echo " cargo fmt - Format code"
echo " cargo tarpaulin - Generate coverage report"
echo ""
'';
});
# Package definition for Samoyed
packages.default = rustPlatform.buildRustPackage {
pname = "samoyed";
version = "0.2.0";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = commonNativeBuildInputs;
inherit buildInputs;
# Set OpenSSL variables for build
OPENSSL_DIR = "${pkgs.openssl.dev}";
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include";
meta = with pkgs.lib; {
description = "A modern, minimal, cross-platform Git hooks manager";
homepage = "https://github.com/nutthead/samoyed";
license = licenses.mit;
maintainers = [ ];
platforms = platforms.all;
};
};
# Apps for easy running
apps.default = flake-utils.lib.mkApp {
drv = self.packages.${system}.default;
};
});
}This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗