Skip to content

Add CUDA support to btop via Nix flake override#3

Open
wardnath wants to merge 2 commits intomainfrom
claude/btop-cuda-support-xZvHI
Open

Add CUDA support to btop via Nix flake override#3
wardnath wants to merge 2 commits intomainfrom
claude/btop-cuda-support-xZvHI

Conversation

@wardnath
Copy link
Owner

Summary

This PR adds a Nix flake configuration to enable CUDA support for btop and updates the Devbox configuration to use this custom build instead of the standard package.

Key Changes

  • Added flake.nix: New Nix flake that defines a custom btop-gpu package with CUDA support enabled via the cudaSupport override
  • Updated devbox.json: Changed btop dependency from the standard btop@latest to the custom path:./#btop-gpu package defined in the flake

Implementation Details

The flake configuration:

  • Uses nixos-unstable as the nixpkgs input for up-to-date packages
  • Enables unfree packages to allow CUDA support
  • Targets x86_64-linux system
  • Provides the btop-gpu package as a flake output that can be referenced locally

This allows developers in the Devbox environment to use btop with GPU monitoring capabilities via CUDA.

https://claude.ai/code/session_01Cd4UZeN7xCZq4VdxFUYLai

Replace the vanilla btop package with a custom flake-based build that
enables cudaSupport. This adds a flake.nix that overrides btop with
cudaSupport=true and updates devbox.json to reference the local flake
output instead of the default nixpkgs package.

https://claude.ai/code/session_01Cd4UZeN7xCZq4VdxFUYLai
- Replace destructive `chezmoi purge --force` with idempotent
  `chezmoi init || true` in install-chezmoi script
- Add ~/.zshrc.local and ~/.bashrc.local sourcing hooks so
  machine-specific customizations survive chezmoi apply

https://claude.ai/code/session_01Cd4UZeN7xCZq4VdxFUYLai
Copilot AI review requested due to automatic review settings February 11, 2026 00:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Nix flake override to build btop with CUDA support and wires Devbox to use that custom package, along with a couple of shell/chezmoi tweaks.

Changes:

  • Added flake.nix defining btop-gpu (btop with cudaSupport = true) and enabling unfree packages.
  • Updated devbox.json to install btop from the local flake output (path:./#btop-gpu) and adjusted the install-chezmoi script.
  • Updated shell rc files to source optional machine-local overrides (~/.zshrc.local, ~/.bashrc.local).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
flake.nix Introduces a flake-based btop-gpu package override with CUDA enabled.
devbox.json Switches Devbox to consume the flake-provided btop-gpu and modifies the chezmoi install script.
chezmoi/dot_zshrc Sources an optional local zsh rc file for machine-specific overrides.
bash/.bashrc Sources an optional local bash rc file for machine-specific overrides.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +8 to +12
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

system is hard-coded to x86_64-linux, but this repo/config appears to be used on non-Linux hosts as well (e.g., Homebrew setup in shell rc files). With the current flake outputs, path:./#btop-gpu will fail to evaluate on aarch64-darwin/other systems. Consider generating outputs for multiple systems (e.g., via nixpkgs.lib.genAttrs) and/or using builtins.currentSystem, and make btop-gpu fall back to non-CUDA btop on unsupported systems.

Copilot uses AI. Check for mistakes.
description = "Custom overrides for Devbox";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flake introduces an unlocked nixpkgs input, but the PR does not add a flake.lock. Without a lock file, btop-gpu will change over time and may break Devbox installs unpredictably. Add and commit flake.lock so the CUDA-enabled build is reproducible.

Suggested change
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# Pin nixpkgs to a specific revision for reproducible Devbox installs.
nixpkgs.url = "github:nixos/nixpkgs/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";

Copilot uses AI. Check for mistakes.
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.allowUnfree = true enables all unfree packages for this flake. If the intent is only to allow CUDA-related derivations, consider narrowing this (e.g., allowUnfreePredicate) or making it conditional so the flake doesn't silently broaden licensing scope for unrelated packages.

Suggested change
config.allowUnfree = true;
config.allowUnfreePredicate = pkg: true;

Copilot uses AI. Check for mistakes.
"atuin@latest",
"bat@latest",
"btop@latest",
"path:./#btop-gpu",
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

devbox.lock in this repo still pins btop@latest, but devbox.json now depends on path:./#btop-gpu. To keep installs reproducible and avoid confusing diffs for other contributors, regenerate/update the lockfile so it reflects the new dependency graph (or remove the stale btop@latest entry if it’s no longer used).

Suggested change
"path:./#btop-gpu",
"btop@latest",

Copilot uses AI. Check for mistakes.
Comment on lines +98 to 100
"chezmoi init || true",
"cp -r $(devbox global path)/chezmoi/* $(chezmoi source-path)",
"chezmoi apply --no-pager --progress true"
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chezmoi init || true will ignore any initialization failure (not just the “already initialized” case), which can mask real problems and lead to cp/apply operating on an unexpected source directory. Prefer an idempotent check (e.g., detect an existing chezmoi source dir / repo) and only ignore the specific non-fatal condition, or fail fast with a clearer error.

Copilot uses AI. Check for mistakes.
Comment on lines +50 to +51
# Machine-local overrides (not managed by chezmoi, survives devbox global pull)
[ -f ~/.zshrc.local ] && source ~/.zshrc.local
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds sourcing of ~/.zshrc.local, which is unrelated to the stated PR goal (CUDA-enabled btop via Nix/Devbox). Either update the PR description to cover this additional behavior change, or move it into a separate PR to keep scope focused.

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +7
# Machine-local overrides (survives devbox global pull)
[ -f ~/.bashrc.local ] && source ~/.bashrc.local
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds sourcing of ~/.bashrc.local, which is unrelated to the stated PR goal (CUDA-enabled btop via Nix/Devbox). Either update the PR description to cover this additional behavior change, or move it into a separate PR to keep scope focused.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants