Skip to content

feat(wrapperModules.ghostty): init#546

Open
TrustworthyAdult wants to merge 1 commit into
BirdeeHub:mainfrom
TrustworthyAdult:main
Open

feat(wrapperModules.ghostty): init#546
TrustworthyAdult wants to merge 1 commit into
BirdeeHub:mainfrom
TrustworthyAdult:main

Conversation

@TrustworthyAdult
Copy link
Copy Markdown
Contributor

@TrustworthyAdult TrustworthyAdult commented May 19, 2026

Settings are written to a generated Nix store config file and loaded via --config-default-files=false --config-file=<path>, so the host config is never loaded -- including on machines that already have their own Ghostty config. The host config path varies by platform: ~/.config/ghostty/config on Linux, and ~/Library/Application Support/com.mitchellh.ghostty/config on macOS.

On macOS, ghostty-bin is used by default, which is the pre-built binary distribution recommended for nix-darwin by the Ghostty installation docs.

Known limitations

  • ghostty +show-config and ghostty +validate-config will show the host config rather than the generated one. Ghostty's action-mode option parsers reject --config-file, so there is no way to point them at the generated config.

  • If you pass an additional --config-file flag at runtime, Ghostty merges it on top of the generated config (later files take precedence for conflicting keys).

@TrustworthyAdult
Copy link
Copy Markdown
Contributor Author

Converted to draft — this is blocked on #548 which fixes the wlib-formatting CI crash on macOS. Once that merges I'll rebase and mark ready.

@TrustworthyAdult TrustworthyAdult force-pushed the main branch 3 times, most recently from d9ea92e to aa70410 Compare May 20, 2026 09:39
@TrustworthyAdult
Copy link
Copy Markdown
Contributor Author

TrustworthyAdult commented May 20, 2026

Please excuse the number of edits and CI runs on this PR. I previously thought that this PR was blocked by a CI-related change so every time I needed to test that change, I'd re-run the CI pipeline on the other PR and then rebase here.

@TrustworthyAdult TrustworthyAdult marked this pull request as ready for review May 20, 2026 09:52
Copy link
Copy Markdown
Owner

@BirdeeHub BirdeeHub left a comment

Choose a reason for hiding this comment

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

#393

^ This PR might have some useful things in it for you (The last PR attempt, which ran into similar bugs in ghostty but was otherwise quite good)

Comment thread wrapperModules/g/ghostty/module.nix
Copy link
Copy Markdown
Owner

@BirdeeHub BirdeeHub left a comment

Choose a reason for hiding this comment

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

Some changes requested to the other PR to allow

  settings.keybind = [
    "ctrl+a>-=new_split:down"
    "ctrl+a>==new_split:right"
  ];

for

keybind=ctrl+a>-=new_split:down
keybind=ctrl+a>==new_split:right

and

  settings.config-file = [
    "${./more}"
    "${./files}"
  ];

Comment thread wrapperModules/g/ghostty/module.nix
Comment thread wrapperModules/g/ghostty/module.nix Outdated
Comment on lines +19 to +26
type = lib.types.attrsOf (
lib.types.oneOf [
lib.types.bool
lib.types.float
lib.types.int
lib.types.str
]
);
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.

Suggested change
type = lib.types.attrsOf (
lib.types.oneOf [
lib.types.bool
lib.types.float
lib.types.int
lib.types.str
]
);
type = let
atom = lib.types.oneOf [
lib.types.bool
lib.types.float
lib.types.int
lib.types.str
];
in lib.types.attrsOf (lib.types.either (lib.types.listOf atom) atom);

Copy link
Copy Markdown
Owner

@BirdeeHub BirdeeHub May 20, 2026

Choose a reason for hiding this comment

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

Alternatively, we could use inherit (pkgs.formats.keyValue { listsAsDuplicateKeys = true; }) type;

Or even add https://github.com/NixOS/nixpkgs/blob/2bc4da5851acf09c933e582394e122fb5402ea4e/pkgs/pkgs-lib/formats.nix#L417-L446 <-- the type to wlib.types (because they have neglected to give us a way to use it without grabbing it from pkgs) or open a PR for them to move it in nixpkgs (If you do that, give this PR a shoutout too! That is our wlib.types.structuredValueWith type)

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.

Applied both suggestions: listsAsDuplicateKeys = true in the generator, and the type updated to attrsOf (either (listOf atom) atom). I also updated the example and tests to demonstrate the duplicate-key behaviour with a keybind list.

I went with the explicit either union rather than inheriting from pkgs.formats.keyValue to keep the type out of pkgs. If your nixpkgs PR (#516798) lands and that type becomes available in lib without needing a pkgs instance, happy to consolidate here at that point.

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.

#516798

This is actually a different type entirely, I was just mentioning it.

@TrustworthyAdult
Copy link
Copy Markdown
Contributor Author

@BirdeeHub ah sorry I'll look in more detail tomorrow and get back to you

@TrustworthyAdult TrustworthyAdult force-pushed the main branch 2 times, most recently from babe1b6 to c3c7270 Compare May 21, 2026 12:17
Writes settings to a Nix store config file and loads it via
--config-default-files=false --config-file=<path>, isolating the wrapper
from the host config in both installed and ephemeral use. The host config
path varies by platform: ~/.config/ghostty/config on Linux, and
~/Library/Application Support/com.mitchellh.ghostty/config on macOS.

Ghostty +actions and --help use minimal option parsers that reject unknown
flags and exit silently, so argv0type bypasses flag injection for these.
+show-config and +validate-config are subject to the same parser limitation
and will show the host config rather than the generated one.

On macOS, ghostty-bin is used by default (the pre-built binary distribution
recommended for nix-darwin by the Ghostty installation docs).
@BirdeeHub
Copy link
Copy Markdown
Owner

BirdeeHub commented May 24, 2026

I think I am OK with the intercepting of those args as a workaround for now. They have at least acknowledged the issue, and people could set argv0type themselves if they don't want it.

One question, what happened to our filesToPatch we had there before? Are they not necessary due to using ghostty-bin on mac? Or is there some reason why they were removed?

I think other than that this is good though, but I am curious about where that went, because you had them in your original version of the PR.

Once we add those back, or you explain why we don't need them anymore, I guess we should probably just go ahead and merge it rather than waiting around for ghostty to fix the bug, its been long enough...

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