Repository: NixOS/nixpkgs
Pull request #402539: mcat: init at 0.2.8
Author: login: louis-thevenet
Labels: name: 8.has: package (new)
description: This PR adds a new package
name: 10.rebuild-linux: 1-10
description: This PR causes between 1 and 10 packages to rebuild on Linux.
name: 10.rebuild-darwin: 1-10
description: This PR causes between 1 and 10 packages to rebuild on Darwin.
name: 12.approvals: 2
description: This PR was reviewed and approved by two persons.
Created: 2025-04-28T13:14:30Z | Merged: 2025-05-26T14:47:42Z

[mcat](https://github.com/Skardyy/mcat) is an extension of `cat` that allows you to open documents, images, and more.

<!--
^ Please summarise the changes you have done and explain why they are necessary here ^

For package updates please link to a changelog or describe changes, this helps your fellow maintainers discover breaking updates.
For new packages please briefly describe the package or provide a link to its homepage.
-->

- Adds `mcat-unwrapped`
- Adds `mcat` with `useChromium` and `useFfmpeg` options to include those dependencies or not.

## Things done

<!-- Please check what applies. Note that these are not hard requirements but merely serve as information for reviewers. -->

- Built on platform(s)
  - [x] x86_64-linux
  - [ ] aarch64-linux
  - [ ] x86_64-darwin
  - [ ] aarch64-darwin
- For non-Linux: Is sandboxing enabled in `nix.conf`? (See [Nix manual](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
  - [ ] `sandbox = relaxed`
  - [ ] `sandbox = true`
- [x] Tested, as applicable:
  - [NixOS test(s)](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
  - and/or [package tests](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-tests)
  - or, for functions and "core" functionality, tests in [lib/tests](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or [pkgs/test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test)
  - made sure NixOS tests are [linked](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#linking-nixos-module-tests-to-a-package) to the relevant packages
- [ ] Tested compilation of all packages that depend on this change using `nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"`. Note: all changes have to be committed, also see [nixpkgs-review usage](https://github.com/Mic92/nixpkgs-review#usage)
- [x] Tested basic functionality of all binary files (usually in `./result/bin/`)
- [25.05 Release Notes](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2505.section.md) (or backporting [24.11](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2411.section.md) and [25.05](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2505.section.md) Release notes)
  - [ ] (Package updates) Added a release notes entry if the change is major or breaking
  - [ ] (Module updates) Added a release notes entry if the change is significant
  - [ ] (Module addition) Added a release notes entry if adding a new NixOS module
- [x] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).

<!--
To help with the large amounts of pull requests, we would appreciate your
reviews of other pull requests, especially simple package updates. Just leave a
comment describing what you have tested in the relevant package/service.
Reviewing helps to reduce the average time-to-merge for everyone.
Thanks a lot if you do!

List of open PRs: https://github.com/NixOS/nixpkgs/pulls
Reviewing guidelines: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#reviewing-contributions
-->

---

Add a :+1: [reaction] to [pull requests you find important].

[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc



Diff:
diff --git a/pkgs/by-name/mc/mcat-unwrapped/package.nix b/pkgs/by-name/mc/mcat-unwrapped/package.nix
new file mode 100644
index 0000000000000..9732a5dfd3ab1
--- /dev/null
+++ b/pkgs/by-name/mc/mcat-unwrapped/package.nix
@@ -0,0 +1,34 @@
+{
+  lib,
+  rustPlatform,
+  fetchFromGitHub,
+  nix-update-script,
+}:
+rustPlatform.buildRustPackage (finalAttrs: {
+  pname = "mcat-unwrapped";
+  version = "0.2.8";
+
+  src = fetchFromGitHub {
+    owner = "Skardyy";
+    repo = "mcat";
+    tag = "v${finalAttrs.version}";
+    hash = "sha256-XvZBikp+Q/pe80eOTQj2rKZ14kXEUBjIroWsh8xmr8A=";
+  };
+
+  cargoHash = "sha256-DIvKCPyqD82IgOqs7+fsAz3sj5IkXacxfZOttSEQ1aA=";
+
+  passthru = {
+    updateScript = nix-update-script { };
+  };
+
+  meta = {
+    description = "cat command for documents / images / videos and more!";
+    homepage = "https://github.com/Skardyy/mcat";
+    changelog = "https://github.com/Skardyy/mcat/blob/v${finalAttrs.version}/CHANGELOG.md";
+    license = lib.licenses.mit;
+    mainProgram = "mcat";
+    maintainers = with lib.maintainers; [
+      louis-thevenet
+    ];
+  };
+})
diff --git a/pkgs/by-name/mc/mcat/package.nix b/pkgs/by-name/mc/mcat/package.nix
new file mode 100644
index 0000000000000..9af71573fb08c
--- /dev/null
+++ b/pkgs/by-name/mc/mcat/package.nix
@@ -0,0 +1,24 @@
+{
+  runCommand,
+  mcat-unwrapped,
+  makeWrapper,
+  lib,
+  chromium,
+  ffmpeg-headless,
+  useChromium ? false,
+  useFfmpeg ? false,
+}:
+
+runCommand "mcat"
+  {
+    pname = "mcat";
+    inherit (mcat-unwrapped) version meta;
+
+    nativeBuildInputs = [ makeWrapper ];
+  }
+  ''
+    mkdir -p $out/bin
+    makeWrapper ${lib.getExe mcat-unwrapped} $out/bin/mcat --prefix PATH : ${
+      lib.makeBinPath ((lib.optional useChromium chromium) ++ (lib.optional useFfmpeg ffmpeg-headless))
+    }
+  ''


Reviews:
user: login: linsui
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T14:45:23Z
user: login: 0xda157
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-29T00:26:55Z
user: login: 0xda157
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-29T00:27:57Z
user: login: louis-thevenet
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-29T07:49:41Z
user: login: 0xda157
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-09T15:44:45Z
user: login: xiaoxiangmoe
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-10T06:17:49Z
user: login: linsui
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-13T07:08:09Z
user: login: xiaoxiangmoe
state: APPROVED
author_association: MEMBER
submitted_at: 2025-05-14T18:51:50Z
user: login: Aleksanaa
state: APPROVED
author_association: MEMBER
submitted_at: 2025-05-26T14:47:32Z

Review comments:
diff_hunk: @@ -0,0 +1,35 @@
+{
+  lib,
+  rustPlatform,
+  fetchFromGitHub,
+  nix-update-script,
+}:
+rustPlatform.buildRustPackage (finalAttrs: {
+  pname = "mcat";
+  version = "0.1.5";
+
+  src = fetchFromGitHub {
+    owner = "Skardyy";
+    repo = "mcat";
+    tag = "v${finalAttrs.version}";
+    hash = "sha256-+wpcLf94FJhkufytKgVnRonivH9CVY/X0+bXx3Z8HKI=";
+  };
+
+  useFetchCargoVendor = true;
path: pkgs/by-name/mc/mcat/package.nix
user: login: linsui
body: This is default.
created_at: 2025-04-28T14:45:23Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,42 @@
+{
+  lib,
+  rustPlatform,
+  fetchFromGitHub,
+  makeWrapper,
+  chromium,
+  nix-update-script,
+}:
+rustPlatform.buildRustPackage (finalAttrs: {
+  pname = "mcat";
+  version = "0.1.5";
+
+  src = fetchFromGitHub {
+    owner = "Skardyy";
+    repo = "mcat";
+    tag = "v${finalAttrs.version}";
+    hash = "sha256-+wpcLf94FJhkufytKgVnRonivH9CVY/X0+bXx3Z8HKI=";
+  };
+
+  cargoHash = "sha256-pi/nts8YqXms5ps6bt+KQRh8twvk5qfkh5FF+/0tMOE=";
+
+  buildInputs = [ makeWrapper ];
+
+  postFixup = ''
+    wrapProgram $out/bin/mcat --prefix PATH : ${lib.makeBinPath [ chromium ]}
path: pkgs/by-name/mc/mcat/package.nix
user: login: 0xda157
body: seems to also need ffmpeg https://github.com/Skardyy/mcat#-dependencies
created_at: 2025-04-29T00:26:55Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,35 @@
+{
+  lib,
+  rustPlatform,
+  fetchFromGitHub,
+  nix-update-script,
+}:
+rustPlatform.buildRustPackage (finalAttrs: {
+  pname = "mcat";
+  version = "0.1.5";
+
+  src = fetchFromGitHub {
+    owner = "Skardyy";
+    repo = "mcat";
+    tag = "v${finalAttrs.version}";
+    hash = "sha256-+wpcLf94FJhkufytKgVnRonivH9CVY/X0+bXx3Z8HKI=";
+  };
+
+  useFetchCargoVendor = true;
path: pkgs/by-name/mc/mcat/package.nix
user: login: 0xda157
body: fyi we shouldn't be nitpicking on this until 24.11 support is dropped, see https://github.com/NixOS/nixpkgs/pull/402152#issuecomment-2832684377
created_at: 2025-04-29T00:27:57Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,42 @@
+{
+  lib,
+  rustPlatform,
+  fetchFromGitHub,
+  makeWrapper,
+  chromium,
+  nix-update-script,
+}:
+rustPlatform.buildRustPackage (finalAttrs: {
+  pname = "mcat";
+  version = "0.1.5";
+
+  src = fetchFromGitHub {
+    owner = "Skardyy";
+    repo = "mcat";
+    tag = "v${finalAttrs.version}";
+    hash = "sha256-+wpcLf94FJhkufytKgVnRonivH9CVY/X0+bXx3Z8HKI=";
+  };
+
+  cargoHash = "sha256-pi/nts8YqXms5ps6bt+KQRh8twvk5qfkh5FF+/0tMOE=";
+
+  buildInputs = [ makeWrapper ];
+
+  postFixup = ''
+    wrapProgram $out/bin/mcat --prefix PATH : ${lib.makeBinPath [ chromium ]}
path: pkgs/by-name/mc/mcat/package.nix
user: login: louis-thevenet
body: Yep, thank you
created_at: 2025-04-29T07:49:41Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,23 @@
+{
+  runCommand,
+  lib,
+  makeWrapper,
+  chromium,
+  ffmpeg,
+  mcat-unwrapped,
+  useChromium ? false,
+  useFfmpeg ? false,
+}:
+
+runCommand mcat-unwrapped.name
+  {
+    inherit (mcat-unwrapped) pname version meta;
+
+    nativeBuildInputs = [ makeWrapper ];
+  }
+  ''
+    mkdir -p $out/bin
+    makeWrapper ${lib.getExe mcat-unwrapped} $out/bin/mcat --prefix PATH : ${
+      lib.makeBinPath ((lib.optional useChromium chromium) ++ (lib.optional useFfmpeg ffmpeg))
path: pkgs/by-name/mc/mcat/package.nix
user: login: 0xda157
body: ```suggestion
      lib.makeBinPath ((lib.optional useChromium chromium) ++ (lib.optional useFfmpeg ffmpeg-headless))
```
created_at: 2025-05-09T15:44:42Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,23 @@
+{
+  runCommand,
+  lib,
+  makeWrapper,
+  chromium,
+  ffmpeg-headless,
+  mcat-unwrapped,
+  useChromium ? false,
+  useFfmpeg ? false,
+}:
+
+runCommand mcat-unwrapped.name
+  {
+    inherit (mcat-unwrapped) pname version meta;
path: pkgs/by-name/mc/mcat/package.nix
user: login: xiaoxiangmoe
body: name and pname should not extends from `mcat-unwrapped`, it should be defined as `mcat`
created_at: 2025-05-10T06:17:49Z
author_association: MEMBER

PR comments:
user: login: linsui
created_at: 2025-04-28T14:51:34Z
body: https://github.com/Skardyy/mcat?tab=readme-ov-file#chromium-for-rendering-html-to-image It installs a chromium which likely won't work. I thought this function should be removed and it should throws an error directly..
author_association: CONTRIBUTOR
user: login: louis-thevenet
created_at: 2025-04-28T16:53:43Z
body: > [Skardyy/mcat#chromium-for-rendering-html-to-image](https://github.com/Skardyy/mcat?tab=readme-ov-file&rgh-link-date=2025-04-28T14%3A51%3A34Z#chromium-for-rendering-html-to-image) It installs a chromium which likely won't work. I thought this function should be removed and it should throws an error directly..

Actually, wrapping chromium works. Thanks for noticing it. =)
author_association: MEMBER
user: login: linsui
created_at: 2025-04-28T17:03:27Z
body: I don't think this is a good idea. Chromium is an optional dep. It's so heavy and shouldn't be bundled.
author_association: CONTRIBUTOR
user: login: louis-thevenet
created_at: 2025-04-28T17:25:00Z
body: > I don't think this is a good idea. Chromium is an optional dep. It's so heavy and shouldn't be bundled.

I see, it is heavy yes.
But it's a design decision from mcat, so users should be aware before installing I think ?

Whats the other option ?
>  I thought this function should be removed and it should throws an error directly..

Do you mean like applying a git patch ?
author_association: MEMBER
user: login: linsui
created_at: 2025-04-28T17:49:38Z
body: > Whats the other option ?

An approach is making the dep optional and configurable. Another approach is patching the code to remove the download function and just throwing and error. Not sure how we can make it a good UX. Downloading Chromium itself sounds bad to me.

> But it's a design decision from mcat, so users should be aware before installing I think ?

If mcat.nvim is packaged and mcat is a dep. Then Chromium is also a dep. This would be a big surprise... Someone who just wants to show images in nvim gets Chromium....

> Do you mean like applying a git patch ?

Yep, this is what I mean.
author_association: CONTRIBUTOR
user: login: louis-thevenet
created_at: 2025-04-29T07:49:31Z
body: > An approach is making the dep optional and configurable. 

I've taken this approach.
After discussions with upstream, the download of chromium and ffmpeg will have its own CLI command in a future release.
author_association: MEMBER
user: login: linsui
created_at: 2025-05-07T05:51:14Z
body: Can you add a unwrapped package and add the args in a wrapper to avoid rebuild?
author_association: CONTRIBUTOR
user: login: xiaoxiangmoe
created_at: 2025-05-13T05:57:14Z
body: mcat 0.2.5 released
author_association: MEMBER