Add Nix flake and Home Manager module#29
Conversation
📝 WalkthroughWalkthroughThis PR introduces Nix flake support for why-cli, enabling multi-system builds, declarative packaging through Home Manager, and Nix overlay integration. A new Nim dependency lock file pins the cligen dependency, a Nix package definition wires the build, and a comprehensive flake exposes packages, apps, overlays, and a Home Manager module. Installation documentation covers both direct and module-based usage. ChangesNix Flake and Home Manager Integration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
flake.nix (1)
4-6: 💤 Low valueConsider using flake-utils for cleaner system iteration.
The manual
forAllSystemsimplementation works correctly, but the flake-utils library provides a standardeachDefaultSystemhelper that reduces boilerplate and is widely adopted in the Nix community.♻️ Optional refactor using flake-utils
Add flake-utils to inputs:
inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; };Then simplify the outputs:
outputs = - { self, nixpkgs }: + { self, nixpkgs, flake-utils }: - let - systems = [ - "aarch64-darwin" - "aarch64-linux" - "x86_64-darwin" - "x86_64-linux" - ]; - - forAllSystems = nixpkgs.lib.genAttrs systems; - - pkgsFor = - system: - import nixpkgs { - inherit system; - }; - in + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in { - packages = forAllSystems ( - system: - let - pkgs = pkgsFor system; - in - { + packages = { default = pkgs.callPackage ./nix/package.nix { }; why-cli = self.packages.${system}.default; - } - ); + }; # ... rest of outputs - }; + }) // { + overlays.default = final: _prev: { + why-cli = final.callPackage ./nix/package.nix { }; + }; + homeManagerModules.default = ...; + };🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@flake.nix` around lines 4 - 6, Add flake-utils to the inputs and replace your custom system iteration with its helper: add an input named flake-utils (e.g., flake-utils.url) and in outputs swap the manual forAllSystems logic for flake-utils.eachDefaultSystem, calling eachDefaultSystem(fn: system: { ... }) instead of your forAllSystems implementation; update any references to the iterated `system` value inside outputs to match the eachDefaultSystem callback signature and remove the old forAllSystems helper.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@flake.nix`:
- Around line 4-6: Add flake-utils to the inputs and replace your custom system
iteration with its helper: add an input named flake-utils (e.g.,
flake-utils.url) and in outputs swap the manual forAllSystems logic for
flake-utils.eachDefaultSystem, calling eachDefaultSystem(fn: system: { ... })
instead of your forAllSystems implementation; update any references to the
iterated `system` value inside outputs to match the eachDefaultSystem callback
signature and remove the old forAllSystems helper.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3c3cdb85-1f89-459a-838f-162cd610f360
⛔ Files ignored due to path filters (1)
flake.lockis excluded by!**/*.lock
📒 Files selected for processing (4)
README.mdflake.nixnix/nim-lock.jsonnix/package.nix
5b59aa7 to
c38d9bd
Compare
Summary
why-clias a package, app, and overlayprograms.why.enableflake-utils.lib.eachDefaultSystemfor standard system iterationhome.packagesand the module import pathTesting
nix build .#why-cli --no-linknix run . -- --helpnix flake check --all-systemsprograms.why.enable = true