# Package Overrides This note covers `20-package-overrides/`, which customizes an existing package with `overrideAttrs`. --- ## 1. Why Override Instead of Rewriting Sometimes you want to change one part of an existing package, not replace the whole derivation. That is what package overrides are for. This example starts from `pkgs.hello` and changes its installed program with `overrideAttrs`. --- ## 2. What `overrideAttrs` Changes `overrideAttrs` receives the old derivation attributes and returns an updated attrset. In this example, the override: - appends `makeWrapper` to `nativeBuildInputs`, and - wraps `bin/hello` so the program always receives a custom `--greeting` flag. The package still comes from `pkgs.hello`; only one part of its install result changes. --- ## 3. Why the Check Runs the Program The check does not inspect the derivation text. It runs the overridden program and asserts that the greeting changed. That keeps the example focused on visible package behavior. --- ## 4. Commands to Try ```bash cd 20-package-overrides nix build ./result/bin/hello nix run nix flake check ```