Skip to content

feat(wrapperModules.bat): init#494

Open
appleptree wants to merge 10 commits intoBirdeeHub:mainfrom
appleptree:bat-wrapper
Open

feat(wrapperModules.bat): init#494
appleptree wants to merge 10 commits intoBirdeeHub:mainfrom
appleptree:bat-wrapper

Conversation

@appleptree
Copy link
Copy Markdown
Contributor

Wrapper Module for the bat CLI.

Comment thread wrapperModules/b/bat/module.nix
Comment thread wrapperModules/b/bat/module.nix Outdated
Comment thread wrapperModules/b/bat/module.nix Outdated
Comment thread wrapperModules/b/bat/module.nix Outdated
@BirdeeHub
Copy link
Copy Markdown
Owner

https://github.com/sharkdp/bat#adding-new-syntaxes--language-definitions

^ this is in our dir too? What to do about this?

Comment thread wrapperModules/b/bat/module.nix Outdated
}) config.themes;
syntaxes-constructFiles = lib.concatMapAttrs (name: value: {
"syntaxes-${name}" = {
content = builtins.readFile value.path;
Copy link
Copy Markdown
Owner

@BirdeeHub BirdeeHub May 2, 2026

Choose a reason for hiding this comment

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

Can these be directories too or just files?


If they are only files, this is technically ok but I am still not super sure how I feel about readFile here to be honest. It means you can't use an impure path, as you would be able to if you just did ln -s for example, and runs the risk of IFD.

Could you use constructFiles.<name>.builder instead to build the value of content if nonempty or copy it if it is empty? Or something to that effect?


If they can be directories too, I am not super sure exactly how you want to do that, maybe just accept just wlib.types.stringable for them and let them make or get the file themselves if they want it and pass the path there, and then you just ln -s them via config.buildCommand?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They can be directories, too. So let's just accept paths.

Comment thread wrapperModules/b/bat/module.nix Outdated
syntaxes-constructFiles = lib.concatMapAttrs (name: value: {
"syntaxes-${name}" = {
content = builtins.readFile value.path;
content = builtins.readFile value;
Copy link
Copy Markdown
Owner

@BirdeeHub BirdeeHub May 3, 2026

Choose a reason for hiding this comment

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

Can we either use .builder here to do ln -s, or config.buildCommand to do ln -s?

Then they can be impure paths also

Thats why the readFile was bothering me too.

Copy link
Copy Markdown
Contributor Author

@appleptree appleptree May 3, 2026

Choose a reason for hiding this comment

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

If .builder does ln -s, what should we set .content to? And how does .builder know about the file it should symlink then?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Since we are only accepting paths, because they can be directories, lets not use constructFiles for that

      buildCommand.makeBatSyntaxes =
        "mkdir -p ${placeholder "out"}/syntaxes\n"
        + lib.concatMapAttrsStringSep "\n" (
          n: v: "ln -s ${v} ${placeholder "out"}/syntaxes/${n}"
        ) config.syntaxes;

Something like that is probably better?

Regardless, if we are going to be using readFile, there isn't a point to accepting a path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right, that's a good solution. Should we do the same for themes?

Comment thread wrapperModules/b/bat/module.nix Outdated
};
syntaxes = lib.mkOption {
type = lib.types.attrsOf (wlib.types.file pkgs);
type = lib.types.attrsOf lib.types.string;
Copy link
Copy Markdown
Owner

@BirdeeHub BirdeeHub May 3, 2026

Choose a reason for hiding this comment

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

wlib.types.stringable is the type for anything that can be "${interpolated}"

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.

2 participants