Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add Nix flake and Home Manager module#29

Merged
akriaueno merged 1 commit into
developfrom
add-nix-flake-home-manager
May 15, 2026
Merged

Add Nix flake and Home Manager module#29
akriaueno merged 1 commit into
developfrom
add-nix-flake-home-manager

Conversation

@akriaueno

@akriaueno akriaueno commented May 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add a Nix flake that exposes why-cli as a package, app, and overlay
  • Add a Home Manager module with programs.why.enable
  • Use flake-utils.lib.eachDefaultSystem for standard system iteration
  • Document Home Manager installation through home.packages and the module import path

Testing

  • nix build .#why-cli --no-link
  • nix run . -- --help
  • nix flake check --all-systems
  • Built a temporary Home Manager activation package with programs.why.enable = true

@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This 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.

Changes

Nix Flake and Home Manager Integration

Layer / File(s) Summary
Nix package build and Nim dependencies
nix/package.nix, nix/nim-lock.json
Define the buildNimPackage derivation for why-cli with pname = "why-cli" and version 0.1.0, sourcing from the cleaned local directory and using a pinned cligen Git dependency from the Nim lock file.
Flake definition and multi-system outputs
flake.nix
Create a multi-system flake that builds the Nim package for each system and exposes packages.${system}.default, apps.${system}.default, overlays.default, and homeManagerModules.default with programs.why.enable and programs.why.package options.
Home Manager installation guide
README.md
Document how to add the flake as an input, install via home.packages, and enable the programs.why Home Manager module.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A flake so bright, with Nix in sight,
Home Manager modules bundled tight,
Nim packages dance through systems fair,
why-cli now lives everywhere! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: adding a Nix flake and Home Manager module as documented in the PR objectives and implemented across flake.nix and supporting files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-nix-flake-home-manager

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
flake.nix (1)

4-6: 💤 Low value

Consider using flake-utils for cleaner system iteration.

The manual forAllSystems implementation works correctly, but the flake-utils library provides a standard eachDefaultSystem helper 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9a87f67 and 5b59aa7.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • README.md
  • flake.nix
  • nix/nim-lock.json
  • nix/package.nix

@akriaueno akriaueno force-pushed the add-nix-flake-home-manager branch from 5b59aa7 to c38d9bd Compare May 15, 2026 14:15
@akriaueno akriaueno merged commit 27ebecb into develop May 15, 2026
6 checks passed
@akriaueno akriaueno deleted the add-nix-flake-home-manager branch May 30, 2026 13:25
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.

1 participant