Skip to content

delta: refactor into standalone module #7134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

LucasWagler
Copy link
Contributor

@LucasWagler LucasWagler commented May 26, 2025

Description

WIP

Refactor delta into its own standalone module, with a new enableGitIntegration option.

Many submodules under the Git module deserve to be broken out into their own spaces. Delta is a great example, as it can be used without Git.

Checklist

  • Change is backwards compatible.

  • Code formatted with nix fmt or
    nix-shell -p treefmt nixfmt-rfc-style keep-sorted --run treefmt.

  • Code tested through nix-shell --pure tests -A run.all
    or nix build --reference-lock-file flake.lock ./tests#test-all using Flakes.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.

Maintainer CC

@khaneliman
@rycee

@github-actions github-actions bot added the git label May 26, 2025
@LucasWagler
Copy link
Contributor Author

LucasWagler commented May 26, 2025

Running TODO list:

  • Move & polish tests
  • Ensure new test files are wired up & asserted
  • Remove any commented pieces & TODOs
  • Decide where to direct the old enable option to (enable vs. enableGitIntegration)
  • What should the new enable and enableGitIntegration default to? Tie them together?
  • Should we move/remove the assertion for ensuring only a single diff tool is used?
  • Ensure config file is created regardless of Git being enabled? (It uses .gitconfig as its config file)

@LucasWagler LucasWagler force-pushed the refactor/delta-standalone branch from 3f34b32 to 00088b5 Compare May 26, 2025 04:13
@LucasWagler LucasWagler force-pushed the refactor/delta-standalone branch from 00088b5 to a9665ff Compare May 26, 2025 04:50
@LucasWagler LucasWagler force-pushed the refactor/delta-standalone branch from a9665ff to 1fdb7a9 Compare May 27, 2025 03:23
Copy link
Contributor

@ambroisie ambroisie left a comment

Choose a reason for hiding this comment

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

I agree that delta (and other pagers) should have its (their) own module. Good first step

I do have a nit to review for the module options.

Comment on lines +37 to +49
enable = mkEnableOption "" // {
default = cfg.enableGitIntegration;
description = ''
Whether to enable the {command}`delta` syntax highlighter.
See <https://github.com/dandavison/delta>.
'';
};

enableGitIntegration = mkEnableOption "" // {
description = ''
Whether to enable Git integration for the {command}`delta` syntax highlighter.
See <https://github.com/dandavison/delta>.
'';
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO this should default to false for enable and true for enableGitIntegration.

Suggested change
enable = mkEnableOption "" // {
default = cfg.enableGitIntegration;
description = ''
Whether to enable the {command}`delta` syntax highlighter.
See <https://github.com/dandavison/delta>.
'';
};
enableGitIntegration = mkEnableOption "" // {
description = ''
Whether to enable Git integration for the {command}`delta` syntax highlighter.
See <https://github.com/dandavison/delta>.
'';
enable = mkEnableOption "" // {
description = ''
Whether to enable the {command}`delta` syntax highlighter.
See <https://github.com/dandavison/delta>.
'';
};
enableGitIntegration = mkEnableOption "" // {
default = true;
description = ''
Whether to enable Git integration for the {command}`delta` syntax highlighter.
See <https://github.com/dandavison/delta>.
'';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your suggestion seems reasonable to me, at the expense of new users needing to explicitly disable Git integration when adding delta to their config. That should be fine, as I'd expect a majority of users to want Git integration enabled, anyway. I'll look at implementing it!

Ideally, programs.git.delta.enable would be split-renamed into both programs.delta.enable and programs.delta.enableGitIntegration. We could then keep the default as false for both new options.

Comment on lines +28 to +31
(mkRenamedOptionModule
[ "programs" "git" "delta" "enable" ]
[ "programs" "delta" "enableGitIntegration" ]
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Related to my previous comment, this would need to use a custom message with mkRemovedOptionModule or mkChangedOptionModule to point at both programs.delta.{enable,enableGitIntegration}.

Comment on lines +81 to +91
finalPackage =
if cfg.settings == { } then
cfg.package
else
(pkgs.writeShellApplication {
name = "delta";
runtimeInputs = [ cfg.package ];
text = ''
exec ${getExe cfg.package} --config=${deltaConfig} "$@"
'';
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Makes me wish that dandavison/delta#1959 had been better received.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants