Skip to content

ghostty: init#703

Merged
trueNAHO merged 3 commits intonix-community:masterfrom
arunoruto:ghostty
Jan 2, 2025
Merged

ghostty: init#703
trueNAHO merged 3 commits intonix-community:masterfrom
arunoruto:ghostty

Conversation

@arunoruto
Copy link
Copy Markdown
Contributor

Ghostty just came out, and I wanted to try it out right away!
If I am gonna do this, I could also do it the right way from the start so I can share my config. Here is my current progress. Feel free to chime in with corrections :D

Colorscheme is derived by comparing cattpuccin macchiato from their official ghostty repo and the tera file for compiling the theme, and the base16 version of the theme. They named everything nicely! The only things missing are:

  • the pink color -> I used flamingo instead (base0F), close enough
  • the subtext colors were not available -> I just used the normal text color (base05), I am open to a better color

This will be kept as a draft, until the ghostty PR is merged into home-manager.

Copy link
Copy Markdown
Member

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

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

Since the GitHub UI does not let me annotate specific lines, here is a normal review:

From 6d3d807f46b94f4de7dd5bec510f8a88420c0c6e Mon Sep 17 00:00:00 2001
From: Mirza Arnaut <mirza.arnaut45@gmail.com>
Date: Fri, 27 Dec 2024 02:26:00 +0100
Subject: [PATCH] Add ghostty module

Rename the commit to ghostty: init.

---
 modules/ghostty/hm.nix | 49 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 modules/ghostty/hm.nix

diff --git a/modules/ghostty/hm.nix b/modules/ghostty/hm.nix
new file mode 100644
index 00000000..f1cdd09a
--- /dev/null
+++ b/modules/ghostty/hm.nix
@@ -0,0 +1,49 @@
+# Documentation is available at:
+# - https://ghostty.org/docs/config/reference
+# - `man 5 ghostty`
+{ config, lib, ... }:
+{
+  options.stylix.targets.ghostty.enable = config.lib.stylix.mkEnableTarget "Ghostty" true;
+
+  config =
+    lib.mkIf
+      (
+        config.stylix.enable && config.stylix.targets.ghostty.enable && config.stylix.targets.ghostty.enable
+      )

You are repeating the config.stylix.targets.ghostty.enable condition twice:

-      (
-        config.stylix.enable && config.stylix.targets.ghostty.enable && config.stylix.targets.ghostty.enable
-      )
+      (config.stylix.enable && config.stylix.targets.ghostty.enable)
+      {
+        programs.ghostty.settings = with config.stylix; {
+          theme = "stylix";
+          font-family = fonts.monospace.name;
+          font-style = "Reg";

Is this font-style generally compatible or only with your specific one?

+          font-size = fonts.sizes.terminal;
+          background-opacity = opacity.terminal;
+        };
+
+        home.file.".config/ghostty/themes/stylix".text =
+          (with config.lib.stylix.colors.withHashtag; ''
+            palette = 0=${base03}
+            palette = 1=${base08}
+            palette = 2=${base0B}
+            palette = 3=${base0A}
+            palette = 4=${base0D}
+            palette = 5=${base0F}
+            palette = 6=${base0C}
+            palette = 7=${base05}
+            palette = 8=${base04}
+            palette = 9=${base08}
+            palette = 10=${base0B}
+            palette = 11=${base0A}
+            palette = 12=${base0D}
+            palette = 13=${base0F}
+            palette = 14=${base0C}
+            palette = 15=${base05}
+          '')
+          + (with config.lib.stylix.colors; ''
+            background = ${base00}
+            foreground = ${base05}
+            cursor-color = ${base06}
+            selection-background = ${base02}
+            selection-foreground = ${base05}
+          '');
+      };
+}

Avoid the with pattern:

{
  home.file.".config/ghostty/themes/stylix".text = let
    inherit (colors) withHashtag;
    inherit (config.lib.stylix) colors;
  in ''
    palette = 0=${withHashtag.base03}
    background = ${colors.base00}
  '';
}

Also, does the Home Manager module support generating theme files as follows:

{
  programs.ghostty.theme.stylix = let
    inherit (config.lib.stylix) colors;
  in {
    background = colors.base00;
    cursor-color = colors.base06;
    foreground = colors.base05;

    palette = let
      inherit (config.lib.stylix.colors) withHashtag;
    in [
      withHashtag.base03
      withHashtag.base08
      withHashtag.base0B
      withHashtag.base0A
      withHashtag.base0D
      withHashtag.base0F
      withHashtag.base0C
      withHashtag.base05
      withHashtag.base04
      withHashtag.base08
      withHashtag.base0B
      withHashtag.base0A
      withHashtag.base0D
      withHashtag.base0F
      withHashtag.base0C
      withHashtag.base05
    ];

    selection-background = colors.base02;
    selection-foreground = colors.base05;
  };
}

Maybe you can add or request this functionality to the future Home Manager module.

@arunoruto
Copy link
Copy Markdown
Contributor Author

arunoruto commented Dec 27, 2024

Thanks for the review!

Rename the commit to ghostty: init.

You are repeating the config.stylix.targets.ghostty.enable condition twice:

✅ no idea how that slipped through...

Is this font-style generally compatible or only with your specific one?

❎ I somehow thought that this was universal, but different fonts implement a different regular keyword... I will take it out!

Avoid the with pattern:

✅ I used some other modules on stylix as inspiration. Even tho I don't like with personally, I thought it was used heavily in stylix. I replaced it with let in.

Also, does the Home Manager module support generating theme files as follows:
Maybe you can add or request this functionality to the future Home Manager module.

It does not.. for now. I asked in the PR and it seems like it will be implemented soonish!

On a sidenote: I added the emoji font too.

@arunoruto
Copy link
Copy Markdown
Contributor Author

The ghostty HM PR just pushed a commit with the needed themes option!
I changed the code to reflect that and tested it out on my setup! So far it works nicely!

Copy link
Copy Markdown
Member

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

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

Avoid the with pattern:

✅ I used some other modules on stylix as inspiration. Even tho I don't like with personally, I thought it was used heavily in stylix.

Once #519 merges, I plan on cleaning up the codebase and removing legacies, like with.

Copy link
Copy Markdown
Member

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

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

LGTM. Great job!

Remember to mark this PR as ready for review and update the nixpkgs and home-manager inputs once the Ghostty patches are available.

@arunoruto
Copy link
Copy Markdown
Contributor Author

LGTM. Great job!

Remember to mark this PR as ready for review and update the nixpkgs and home-manager inputs once the Ghostty patches are available.

Will do so! I am subscribed to both the nixpkgs and hm PRs, so I should get notified when they are done.

@trueNAHO
Copy link
Copy Markdown
Member

Remember to mark this PR as ready for review and update the nixpkgs and home-manager inputs once the Ghostty patches are available.

Will do so! I am subscribed to both the nixpkgs and hm PRs, so I should get notified when they are done.

Same. Keep in mind that the Nixpkgs PR has to land into nixpkgs-unstable (https://nixpk.gs/pr-tracker.html?pr=368404) because that is what we are tracking:

https://github.com/danth/stylix/blob/963e77a3a4fc2be670d5a9a6cbeb249b8a43808a/flake.nix#L45

@arunoruto
Copy link
Copy Markdown
Contributor Author

arunoruto commented Dec 30, 2024

Same. Keep in mind that the Nixpkgs PR has to land into nixpkgs-unstable (https://nixpk.gs/pr-tracker.html?pr=368404) because that is what we are tracking:

https://github.com/danth/stylix/blob/963e77a3a4fc2be670d5a9a6cbeb249b8a43808a/flake.nix#L45

The package PR has landed onto nixpkgs-unstable, but we gotta wait for the HM merge. I guess they wait for nixos-unstable:

https://github.com/nix-community/home-manager/blob/10e99c43cdf4a0713b4e81d90691d22c6a58bdf2/flake.nix#L4

Is there a reason why nixos-unstable isn't tracked in stylix?

@trueNAHO
Copy link
Copy Markdown
Member

https://github.com/danth/stylix/blob/963e77a3a4fc2be670d5a9a6cbeb249b8a43808a/flake.nix#L45

[...]

Is there a reason why nixos-unstable isn't tracked in stylix?

I was thinking the same when I saw this. I opened #712.

@arunoruto arunoruto marked this pull request as ready for review January 2, 2025 00:38
@arunoruto arunoruto requested a review from trueNAHO January 2, 2025 00:38
@arunoruto
Copy link
Copy Markdown
Contributor Author

The ghostty module got merged into master an hour ago!
Since I am rocking nixos stable, I am testing it by including a copy of the module in my config and haven't noticed any problems so far!

Copy link
Copy Markdown
Member

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

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

The ghostty module got merged into master an hour ago!

Please update the nixpkgs and home-manager inputs appropriately for the CI to pass.

@arunoruto
Copy link
Copy Markdown
Contributor Author

The ghostty module got merged into master an hour ago!

Please update the nixpkgs and home-manager inputs appropriately for the CI to pass.

Done! While I was at it, I looked at how the tests are implemented and added a testbed.nix to ghostty 😄

@arunoruto arunoruto requested a review from trueNAHO January 2, 2025 18:52
Copy link
Copy Markdown
Member

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

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

Please update the nixpkgs and home-manager inputs appropriately for the CI to pass.

Done! While I was at it, I looked at how the tests are implemented and added a testbed.nix to ghostty 😄

Great job!

@trueNAHO trueNAHO merged commit 6eb0597 into nix-community:master Jan 2, 2025
@arunoruto
Copy link
Copy Markdown
Contributor Author

I just saw that #712 got merged. I hope me syncing flake.nix to nixpkgs-unstable does not pose a problem here? Maybe a new update of the lockfile is needed.

@trueNAHO
Copy link
Copy Markdown
Member

trueNAHO commented Jan 2, 2025

I just saw that #712 got merged. I hope me syncing flake.nix to nixpkgs-unstable does not pose a problem here? Maybe a new update of the lockfile is needed.

The flake.lock causes Nix to access the same revision regardless of the reference. I think nixpkgs-unstable simply has less caches uploaded compared to nixos-unstable. Either way, this should probably not cause any functional problems.

@arunoruto arunoruto deleted the ghostty branch January 2, 2025 20:49
trueNAHO pushed a commit to trueNAHO/stylix that referenced this pull request Jan 23, 2025
Link: nix-community#703

Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
(cherry picked from commit 6eb0597)
trueNAHO pushed a commit to trueNAHO/stylix that referenced this pull request Jan 23, 2025
Link: nix-community#703

Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
(cherry picked from commit 6eb0597)
@cluther cluther mentioned this pull request Mar 14, 2025
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