hercules-ci / flake-parts

❄️ Simplify Nix Flakes with the module system
https://flake.parts
MIT License
776 stars 42 forks source link

What is the best way to custom attributes for debugging purpose inside `perSystem`? #256

Open bglgwyng opened 3 weeks ago

bglgwyng commented 3 weeks ago

I'm debugging my flake-parts code with nix repl. To do this, I put custom values into flake attribute. However, sometimes I need values provided for perSystem lambda like lib, pkgs to debug more conveniently. AFAIK, I can't add custom attributes inside perSystem without adding custom options. It would be great if I could add attributes for debugging purpose into perSystem. Do we have any?

bglgwyng commented 3 weeks ago
{
  imports = [
        ({ lib, flake-parts-lib, ... }:
          let
            inherit (lib) mkOption types;
            inherit (flake-parts-lib) mkTransposedPerSystemModule;
          in mkTransposedPerSystemModule {
            name = "debug2";
            option = mkOption {
              type = types.lazyAttrsOf types.bool;
              default = { };
            };
            file = ./.;
          })
      ];

The best solution I found so far is to put debug2 attribute manually in imports. debug is different from what I expected. Do we have such thing in default?

roberth commented 3 weeks ago

Did you find the debug option? I think it covers your needs. It adds to the flake outputs:

bglgwyng commented 3 weeks ago

Using debug, I should define values for debugging purposes in REPL. Is it correct? https://github.com/hercules-ci/flake-parts/issues/256#issuecomment-2449156316 This approach allows arbitrary properties inside perSystem.debug.

What about adding this feature into the existing debug option?