Skip to content

feat(nix): add comprehensive nix flake#426

Merged
idursun merged 15 commits intoidursun:mainfrom
doprz:feature/comprehensive-nix-flake
Dec 16, 2025
Merged

feat(nix): add comprehensive nix flake#426
idursun merged 15 commits intoidursun:mainfrom
doprz:feature/comprehensive-nix-flake

Conversation

@doprz
Copy link
Copy Markdown
Contributor

@doprz doprz commented Dec 14, 2025

Features:

  • Nix Flake Configuration: Complete flake setup supporting multiple architectures
    • flake-parts
    • flake-parts partitions
    • official flake-compat (rev/hash pinned)
    • lib.fileset.unions for pkgs.buildGoModule
    • pkgs.writeShellApplication for vendorHash as an app
    • Split flake.nix into modules
    • Create dedicated jjui package with override support
    • nixpkgs.lib.systems.flakeExposed
    • Add JJUI_CONF_DIR env var notice/warning
    • treefmt-nix
      • nixfmt-rfc-style
      • gofmt
  • Development Shell: Pre-configured dev environment
  • Multiple Entry Points: Support for nix develop, nix run, and nix build
  • Updated .gitignore
  • Added .envrc for nix flake users
  • Update README.md
  • Add CODEOWNERS file

TODO:

  • flake-compat

I'm +1 on having support for stable-nix default.nix and shell.nix, however I don't like the fact that the PR adds flake-compat dependency for all flake users. flake-compat is NOT needed when using unstable-nix flakes. It is an anti-pattern of usage, because you will be introducing and forcing all fakes depending on this one to fetch flake-compat which is absolutely bloat for most.

You can still use flake-compat in default.nix and shell.nix like this: https://github.com/vic/den/blob/d114d8b8d0f4c809a7057a7cef35e6d8648dcdaf/nix/template-packages.nix#L5 Just use a fixed rev and sha.

@doprz doprz changed the title feat: add comprehensive nix flake feat(nix): add comprehensive nix flake Dec 14, 2025
@idursun
Copy link
Copy Markdown
Owner

idursun commented Dec 14, 2025

Hey, thanks!

The only thing I can review in this PR is the .gitignore file and it looks good. Everything else is too much nix for me.

Maybe @Adda0 can have a look as he is maintaining the nix builds.

@Adda0
Copy link
Copy Markdown
Collaborator

Adda0 commented Dec 14, 2025

Heya. Sure. While I am by no means an expert on the Nix ecosystem, I will have a look. Looks reasonable on a first glance.

@doprz
Copy link
Copy Markdown
Contributor Author

doprz commented Dec 14, 2025

Thank you for the reviews and for the development of jjui, it's a great TUI that I've been daily driving!

@idursun
Copy link
Copy Markdown
Owner

idursun commented Dec 15, 2025

I am glad this is getting rid of the vendor-hash, which was a minor pain for me after updating dependencies.

@vic
Copy link
Copy Markdown
Collaborator

vic commented Dec 15, 2025

I'm +1 on having support for stable-nix default.nix and shell.nix, however I don't like the fact that the PR adds flake-compat dependency for all flake users. flake-compat is NOT needed when using unstable-nix flakes. It is an anti-pattern of usage, because you will be introducing and forcing all fakes depending on this one to fetch flake-compat which is absolutely bloat for most.

You can still use flake-compat in default.nix and shell.nix like this: https://github.com/vic/den/blob/d114d8b8d0f4c809a7057a7cef35e6d8648dcdaf/nix/template-packages.nix#L5 Just use a fixed rev and sha.

@vic
Copy link
Copy Markdown
Collaborator

vic commented Dec 15, 2025

I am glad this is getting rid of the vendor-hash, which was a minor pain for me after updating dependencies.

It is still there, not just in a file which was used to keep track of version changes on a single file. you'd still have to make vendorHash value empty and build to get the new vendored hash when adding dependencies.

@vic
Copy link
Copy Markdown
Collaborator

vic commented Dec 15, 2025

Now that we are talking about dependencies, you could also remove systems input, and use nixpkgs.lib.systems.flakeExposed so jjui works on more systems and not only at these

@doprz
Copy link
Copy Markdown
Contributor Author

doprz commented Dec 15, 2025

I am glad this is getting rid of the vendor-hash, which was a minor pain for me after updating dependencies.

It is still there, not just in a file which was used to keep track of version changes on a single file. you'd still have to make vendorHash value empty and build to get the new vendored hash when adding dependencies.

I was thinking of using mod2nix but it seems a good part of the community has moved to just using buildGoModule. I believe some people said that it was using an old version of go but this could be resolved via an overlay. Open to suggestions.

@vic
Copy link
Copy Markdown
Collaborator

vic commented Dec 15, 2025

Using buildGoModule is fine for this repo, it is not a complicated Go compilation setup. Let's keep with standard buildGoModule and avoid adding more dependencies.

Our flake could, however, have a tiny package (a pkgs.writeShellApplication app) to help maintainers keep ./nix/vendor-hash updated.

This is what I do

echo > nix/vendor-hash
nix build # this will fail since hash is empty and we need to take that hash to update vendor-hash
echo -n "the-hash" > nix/vendor-hash

we could have this script inside the development environment, and it could be run either manually (we could have a simple .bash script doing this) or we could have a GH action that runs on tags when go.sum changes and updates nix/vendor-hash.

@doprz
Copy link
Copy Markdown
Contributor Author

doprz commented Dec 15, 2025

Using buildGoModule is fine for this repo, it is not a complicated Go compilation setup. Let's keep with standard buildGoModule and avoid adding more dependencies.

Our flake could, however, have a tiny package (a pkgs.writeShellApplication app) to help maintainers keep ./nix/vendor-hash updated.

This is what I do

echo > nix/vendor-hash
nix build # this will fail since hash is empty and we need to take that hash to update vendor-hash
echo -n "the-hash" > nix/vendor-hash

we could have this script inside the development environment, and it could be run either manually (we could have a simple .bash script doing this) or we could have a GH action that runs on tags when go.sum changes and updates nix/vendor-hash.

Wouldn't having the vendorHash declared in the nix file instead of a text file be preferable?

@vic
Copy link
Copy Markdown
Collaborator

vic commented Dec 15, 2025

Wouldn't having the vendorHash declared in the nix file instead of a text file be preferable?

scripting to write into the plain-text file might be easier, or use sed to replace on the nix file. I've been using the plain-text file in other go repos of mine and for me it is better since the history of go.sum is reflected at ./nix/vendor-hash without touching any nix specific logic. I'm good either way, I just have a preference for the plain text file and keep the history of go.sum and vendor-hash related one to another.

@doprz
Copy link
Copy Markdown
Contributor Author

doprz commented Dec 15, 2025

Wouldn't having the vendorHash declared in the nix file instead of a text file be preferable?

scripting to write into the plain-text file might be easier, or use sed to replace on the nix file. I've been using the plain-text file in other go repos of mine and for me it is better since the history of go.sum is reflected at ./nix/vendor-hash without touching any nix specific logic. I'm good either way, I just have a preference for the plain text file and keep the history of go.sum and vendor-hash related one to another.

Got it; that's a good point and it's nice to have vendorHash tracked with go.sum. Pushing changes now.

@doprz doprz requested a review from vic December 15, 2025 19:10
@doprz
Copy link
Copy Markdown
Contributor Author

doprz commented Dec 15, 2025

Thank you for the detailed review @vic, I learned a lot from this! Addressed all PR comments + tested all features locally + edge cases, and now this PR is ready for a final review.

Copy link
Copy Markdown
Collaborator

@vic vic left a comment

Choose a reason for hiding this comment

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

LGTM now, lets see if pipeline works and we see logs testing jjui on nix build.

@idursun could you please approve CI on this PR?

@vic
Copy link
Copy Markdown
Collaborator

vic commented Dec 15, 2025

a GH action that runs only when go.sum is modified and creates a PR with the updated ./nix/vendor-hash

@idursun would that be of value to you ? if so we maybe @doprz is interested in providing another PR after this one?

I guess this flow will still work.

yes, same workflow would work with your dockered nix.

@doprz
Copy link
Copy Markdown
Contributor Author

doprz commented Dec 15, 2025

Last thing. I used mdformat but I can also use biome or prettier to format markdown files. Any preference?

@vic
Copy link
Copy Markdown
Collaborator

vic commented Dec 15, 2025

Last thing. I used mdformat but I can also use biome or prettier to format markdown files. Any preference?

Hm, looks like the markdown formatter messed up the issues templates. Can we either skip those files via treefmt config or remove md formatting ?

@vic
Copy link
Copy Markdown
Collaborator

vic commented Dec 15, 2025

Don't know how to revert my approval at GH, haha.

@doprz
Copy link
Copy Markdown
Contributor Author

doprz commented Dec 15, 2025

Don't know how to revert my approval at GH, haha.

Make another review and select "request changes".

Copy link
Copy Markdown
Collaborator

@vic vic left a comment

Choose a reason for hiding this comment

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

make sure md files frontmatter are not modified

@doprz doprz force-pushed the feature/comprehensive-nix-flake branch 2 times, most recently from c530d1d to f2c548e Compare December 15, 2025 21:59
@doprz
Copy link
Copy Markdown
Contributor Author

doprz commented Dec 15, 2025

make sure md files frontmatter are not modified

Done. I went with prettier and only for markdown files and it works as expected.

It also formatted internal/config/default/config.toml but it's still valid toml.

@doprz doprz requested a review from vic December 15, 2025 22:00
@vic
Copy link
Copy Markdown
Collaborator

vic commented Dec 15, 2025

I'm not really sure about all the formatting changes, they are not related to the title of this PR. Maybe we could work that on another PR if any. I'd prefer the toml files to be keep as they are, since having spaces aids people visually (and these toml files will also be read by users as reference so we need them to be as understandable and easy to read as possible).

Can we keep this PR focused on the nix stuff ?

EDIT: we'd also have to assume that Nix is just a convenience here, the main maintainer probably does not know how to run the nix formatters, if he agrees to keep formatters checks in place it'd be better to have a normal treefmt.yaml file and instructions on how to run treefmt outside the nix env. So we can have formatting not only on the nix environment.

@doprz
Copy link
Copy Markdown
Contributor Author

doprz commented Dec 15, 2025

Ok. Dropping the formatting commit and commenting out the formatters. Other than that, I think we're done with this PR.

@doprz doprz force-pushed the feature/comprehensive-nix-flake branch from bf1badd to f2c548e Compare December 15, 2025 22:33
Copy link
Copy Markdown
Collaborator

@Adda0 Adda0 left a comment

Choose a reason for hiding this comment

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

While I am no expert, @vic most definitely is. ❤️ Amazing work. Not much more to say here. Mostly nits.

However, I feel like this PR should only touch the Nix stuff. Everything else (editorconfig, even nixfmt, formatting) should come with different PRs so @idursun can decide themselves whether they want the changes or not. If all the changes are desired, than I see no problem with the PR.

Highly educational Nix structure, too 👍

@doprz doprz force-pushed the feature/comprehensive-nix-flake branch from f2c548e to baf85ea Compare December 16, 2025 16:39
@doprz doprz requested a review from idursun December 16, 2025 16:40
Copy link
Copy Markdown
Collaborator

@vic vic left a comment

Choose a reason for hiding this comment

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

LGTM again.

@idursun
Copy link
Copy Markdown
Owner

idursun commented Dec 16, 2025

Thanks @doprz @vic @Adda0 for all the work and the review!

@idursun idursun merged commit eea4cc8 into idursun:main Dec 16, 2025
6 checks passed
@doprz
Copy link
Copy Markdown
Contributor Author

doprz commented Dec 16, 2025

Thank you @vic @idursun @Adda0 for the reviews and help with this PR!

@doprz doprz deleted the feature/comprehensive-nix-flake branch December 16, 2025 16:57
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jan 9, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [idursun/jjui](https://github.com/idursun/jjui) | patch | `v0.9.8` → `v0.9.9` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>idursun/jjui (idursun/jjui)</summary>

### [`v0.9.9`](https://github.com/idursun/jjui/releases/tag/v0.9.9)

[Compare Source](idursun/jjui@v0.9.8...v0.9.9)

### Release Notes

Another release with small improvements and bug fixes. Thanks to all contributors!

#### 🎉 New Features

##### Custom Commands & Lua API Enhancements

- **Custom Commands with Sequence Keys** ([#&#8203;420](idursun/jjui#420))
  - Added `key_sequence` property allowing custom commands to be invoked with multiple key presses in sequence
  - Added `desc` property for command descriptions
  - Introduced sequence overlay UI showing available key sequences when first key is pressed
  - Example: `key_sequence = ["w", "b", "l"]`

- **Lua API: Choose Method and UI** ([#&#8203;427](idursun/jjui#427)) ([#&#8203;442](idursun/jjui#442))
  - New `choose()` function for interactive selection prompts in Lua scripts
  - New `input()` function to prompt users for text input with customizable title and prompt
  - New `split_lines()` function for text processing

- **Lua API: Await on Operation Results** ([#&#8203;422](idursun/jjui#422))
  - `start_inline_describe()` now returns boolean indicating if operation was applied or cancelled
  - Enables conditional command execution based on user actions
  - Fixes [#&#8203;310](idursun/jjui#310)

- **Lua API: Interactive Commands** ([commit 8b257263](idursun/jjui@8b257263))
  - Added `jj_interactive` Lua function for interactive jj command execution

##### Navigation & UI Improvements

- **Ace Jump for Operations** ([#&#8203;445](idursun/jjui#445))
  - Pressing 'f' in set\_parents/duplicate/rebase/squash modes now triggers ace jump
  - After jump completes, returns to the original operation mode instead of normal mode
  - Closes [#&#8203;394](idursun/jjui#394)

- **Preview Width Variable** ([#&#8203;452](idursun/jjui#452))
  - Added `$preview_width` placeholder variable for preview commands
  - Exposes actual view width (in columns) to enable tools like delta to use `--side-by-side` correctly
  - Width updates dynamically when preview pane is resized
  - Similar to fzf's `$FZF_PREVIEW_COLUMNS`

- **Configurable Flash Message Display Time** ([#&#8203;456](idursun/jjui#456))
  - New config key: `ui.flash_message_display_seconds` (default: 4)
  - Special value `0` means messages display until manually dismissed
  - Fixes [#&#8203;455](idursun/jjui#455)

- **Page Up/Down Key Configuration** ([#&#8203;437](idursun/jjui#437))
  - ScrollUp/Down keys now registered in config instead of hardcoded
  - Keys exposed to configuration for customization
  - Fixes [#&#8203;360](idursun/jjui#360)

##### SSH & Authentication

- **SSH Askpass Support** ([#&#8203;423](idursun/jjui#423))
  - New `[ssh] hijack_askpass` setting to prompt for SSH passphrases/PINs within jjui
  - Works on Linux and macOS
  - Properly handles prompt overriding and cancellation
  - Fixes [#&#8203;100](idursun/jjui#100)

#### 🐛 Bug Fixes

- **Exec Command History** ([#&#8203;458](idursun/jjui#458))
  - Fixed issue where selected command history wasn't applied in exec mode
  - Input value now properly updated when selecting from fuzzy/regex suggestions
  - Selected commands correctly saved to history

- **Menu Pagination Display** ([#&#8203;446](idursun/jjui#446))
  - Fixed incorrect `%d/%d` pagination display
  - Height now calculated before pagination render
  - Added tab/shift+tab to short help menu
  - Fixes [#&#8203;444](idursun/jjui#444)

- **Flash Message Width** ([#&#8203;432](idursun/jjui#432))
  - Added maxWidth (50% of screen) to flash message rendering
  - Messages now properly line-wrap instead of extending beyond window width

- **Operation Log Refresh** ([#&#8203;431](idursun/jjui#431))
  - Operation log now returns Refresh and SelectionChanged messages upon closing
  - Fixes [#&#8203;430](idursun/jjui#430)

- **Custom Commands List Sorting** ([commit 3fa9783a](idursun/jjui@3fa9783a))
  - Fixed custom commands list to use stable sort
  - Fixes [#&#8203;424](idursun/jjui#424)

- **JJ Error Pass-through** ([#&#8203;421](idursun/jjui#421))
  - jjui now properly passes through stderr from jj commands
  - Error messages are more informative and show actual jj errors

- **Navigation Message Display** ([commit 94a4a874](idursun/jjui@94a4a874))
  - Navigation messages now only shown for paged scrolls

#### What's Changed

- main: pass through jj error by [@&#8203;baggiiiie](https://github.com/baggiiiie) in [#&#8203;421](idursun/jjui#421)
- feat(lua): add ability to await on operation results (cancelled/applied) by [@&#8203;idursun](https://github.com/idursun) in [#&#8203;422](idursun/jjui#422)
- oplog: return Refresh and SelectionChanged upon oplog closing by [@&#8203;baggiiiie](https://github.com/baggiiiie) in [#&#8203;431](idursun/jjui#431)
- feat(nix): add comprehensive nix flake by [@&#8203;doprz](https://github.com/doprz) in [#&#8203;426](idursun/jjui#426)
- Add option to hijack SSH Askpass to prompt for passphrase/pin by [@&#8203;oliverpool](https://github.com/oliverpool) in [#&#8203;423](idursun/jjui#423)
- feat(lua): add choose method and ui by [@&#8203;idursun](https://github.com/idursun) in [#&#8203;427](idursun/jjui#427)
- flash: add maxWidth to flash msg rendering by [@&#8203;baggiiiie](https://github.com/baggiiiie) in [#&#8203;432](idursun/jjui#432)
- keys: add pageup/down to keys config by [@&#8203;baggiiiie](https://github.com/baggiiiie) in [#&#8203;437](idursun/jjui#437)
- chore(github): Add Adda0 as an automatic reviewer for Nix-related changes by [@&#8203;Adda0](https://github.com/Adda0) in [#&#8203;440](idursun/jjui#440)
- feat: add .editorconfig by [@&#8203;doprz](https://github.com/doprz) in [#&#8203;434](idursun/jjui#434)
- Add input and log to custom\_commands API by [@&#8203;ArnaudBger](https://github.com/ArnaudBger) in [#&#8203;442](idursun/jjui#442)
- oplog,list: refactor scrolling with Scrollable/StreamableList interface by [@&#8203;baggiiiie](https://github.com/baggiiiie) in [#&#8203;429](idursun/jjui#429)
- menu: calculate height before pagination render by [@&#8203;baggiiiie](https://github.com/baggiiiie) in [#&#8203;446](idursun/jjui#446)
- operations: enable ace jump for set\_parents/duplicate/rebase/squash by [@&#8203;baggiiiie](https://github.com/baggiiiie) in [#&#8203;445](idursun/jjui#445)
- feat: make flash message display time configurable by [@&#8203;living180](https://github.com/living180) in [#&#8203;456](idursun/jjui#456)
- feat: add $width variable for preview commands by [@&#8203;pablospe](https://github.com/pablospe) in [#&#8203;452](idursun/jjui#452)
- status: fix exec command history not applied by [@&#8203;baggiiiie](https://github.com/baggiiiie) in [#&#8203;458](idursun/jjui#458)

#### New Contributors

- [@&#8203;doprz](https://github.com/doprz) made their first contribution in [#&#8203;426](idursun/jjui#426)
- [@&#8203;oliverpool](https://github.com/oliverpool) made their first contribution in [#&#8203;423](idursun/jjui#423)
- [@&#8203;living180](https://github.com/living180) made their first contribution in [#&#8203;456](idursun/jjui#456)
- [@&#8203;pablospe](https://github.com/pablospe) made their first contribution in [#&#8203;452](idursun/jjui#452)

**Full Changelog**: <idursun/jjui@v0.9.8...v0.9.9>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi43NS4xIiwidXBkYXRlZEluVmVyIjoiNDIuNzUuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6OnBhdGNoIl19-->
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.

4 participants