Skip to content

fix/tmux resurrect nixos - #1529

Merged
shunkakinoki merged 2 commits into
mainfrom
fix/tmux-resurrect-nixos
Apr 20, 2026
Merged

fix/tmux resurrect nixos#1529
shunkakinoki merged 2 commits into
mainfrom
fix/tmux-resurrect-nixos

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Apr 20, 2026

Copy link
Copy Markdown
Owner
  • fix: tmux resurrect/continuum restore on NixOS
  • fix: load resurrect before continuum in plugin order

Summary by cubic

Fixes reliable tmux session restore on NixOS by loading resurrect before continuum and resolving the restore script after the server starts. Moves plugin options into per-plugin extraConfig so hooks run with the correct settings and lets continuum manage status-right.

  • Bug Fixes

    • Start a tmux server in _two_function.fish so plugins load, then read @resurrect-restore-script-path (fallback to key scan) and run restore.
    • Load resurrect before continuum to enable auto-restore.
    • Use grep -P in the post-save hook to correctly match tab-separated fields.
  • Refactors

    • Move plugin options from tmux.conf to per-plugin extraConfig in default.nix (resurrect, continuum, extrakto, tmux-thumbs, tmux-sessionx).
    • Set status-right and its length in continuum extraConfig so it can prepend its save trigger; remove duplicates from tmux.conf.

Written for commit fcec1ba. Summary will update on new commits.

- Move plugin options to per-plugin extraConfig in default.nix so they
  are set before each plugin's run-shell
- Move status-right to continuum extraConfig so continuum can prepend
  its auto-save trigger (#(.../continuum_save.sh))
- Fix _two_function to create tmux server before resolving resurrect
  restore script path (was always empty after reboot)
- Switch grep -E to grep -P for tab matching in post-save hook
@mesa-dot-dev

mesa-dot-dev Bot commented Apr 20, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@coderabbitai

coderabbitai Bot commented Apr 20, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 284f2e36-89a9-453d-97c9-8569c0b87fd1

📥 Commits

Reviewing files that changed from the base of the PR and between c93a1b7 and fcec1ba.

📒 Files selected for processing (3)
  • home-manager/programs/fish/functions/_two_function.fish
  • home-manager/programs/tmux/default.nix
  • home-manager/programs/tmux/tmux.conf

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Enhanced tmux plugin configuration with customized keybindings: Extrakto (Tab), Thumbs (Space), and Sessionx (o).
    • Improved session restoration with selective process resurrection and automatic state persistence.
  • Bug Fixes

    • Optimized session resurrection detection and fallback resolution logic.
  • Configuration

    • Adjusted tmux status bar sizing and layout for better display consistency.

Walkthrough

Configuration refactoring moves tmux plugin options from static .conf file to Nix module extraConfig declarations, while reordering fish function logic to detect the resurrect restore script after bootstrapping a temporary tmux server instead of before.

Changes

Cohort / File(s) Summary
Fish function logic
home-manager/programs/fish/functions/_two_function.fish
Reordered restore-script resolution to occur after _bootstrap tmux server startup. Changed detection strategy to query tmux show-options first, then fall back to tmux list-keys lookup if empty. Removed delay comment.
Tmux plugin configuration migration
home-manager/programs/tmux/default.nix, home-manager/programs/tmux/tmux.conf
Moved tmux plugin options from static .conf to Nix extraConfig declarations. Added per-plugin configuration for extrakto, resurrect (with pane content capture, process allowlist, post-save hook), continuum (restore enabled, 3-second save interval), tmux-sessionx, and tmux-thumbs. Removed explicit status bar sizing and status-right format from .conf.

Sequence Diagram

sequenceDiagram
    participant Fish as Fish Function
    participant Bootstrap as _bootstrap<br/>tmux server
    participant ShowOpts as tmux show-options
    participant ListKeys as tmux list-keys
    participant Resurrect as Resurrect<br/>Restore Script

    rect rgba(200, 150, 255, 0.5)
    Note over Fish,Resurrect: Old Flow (eager detection)
    Fish->>ListKeys: Query `@resurrect-restore-script-path`
    activate ListKeys
    ListKeys-->>Fish: path or fallback
    deactivate ListKeys
    Fish->>Resurrect: Execute restore
    end

    rect rgba(150, 200, 255, 0.5)
    Note over Fish,Resurrect: New Flow (deferred detection)
    Fish->>Bootstrap: Start _bootstrap tmux server<br/>(if no sessions exist)
    activate Bootstrap
    Bootstrap-->>Fish: Server ready
    deactivate Bootstrap
    Fish->>ShowOpts: Query `@resurrect-restore-script-path`
    activate ShowOpts
    ShowOpts-->>Fish: path or empty
    deactivate ShowOpts
    alt Option set
        Fish->>Resurrect: Execute restore
    else Option empty
        Fish->>ListKeys: Fall back to list-keys lookup
        activate ListKeys
        ListKeys-->>Fish: path
        deactivate ListKeys
        Fish->>Resurrect: Execute restore
    end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Hop-hop, configurations now align,
Fish and tmux dance in perfect time,
Bootstrap first, then restore with care,
Options migrate through the Nix-y air!

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tmux-resurrect-nixos

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@shunkakinoki
shunkakinoki merged commit 1bc1acc into main Apr 20, 2026
29 of 30 checks passed
@mesa-dot-dev

mesa-dot-dev Bot commented Apr 20, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Fixes tmux resurrect/continuum restore on NixOS.

What changed?

  • fix: tmux resurrect/continuum restore on NixOS
  • fix: load resurrect before continuum in plugin order

Description generated by Mesa. Update settings

@shunkakinoki
shunkakinoki deleted the fix/tmux-resurrect-nixos branch April 20, 2026 20:42

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the tmux configuration by migrating plugin-specific settings from tmux.conf to default.nix using Home Manager's plugin attribute sets. It also updates the _two_function.fish script to more reliably locate the tmux-resurrect restore script by checking tmux options before falling back to key bindings. Feedback was provided to harden the resurrect-hook-post-save-all hook by using absolute Nix store paths for system utilities like grep and readlink, ensuring the hook remains robust across different environments.

extraConfig = ''
set -g @resurrect-capture-pane-contents 'on'
set -g @resurrect-processes 'btop fish git'
set -g @resurrect-hook-post-save-all 'd=~/.tmux/resurrect && f="$d/$(readlink "$d/last")" && grep -P "^(pane|window)\twork\t" "$f" > "$f.tmp" && printf "state\twork\n" >> "$f.tmp" && mv "$f.tmp" "$f"'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The resurrect-hook-post-save-all hook is somewhat fragile as it relies on the user's PATH for commands like grep, readlink, and mv. In a Nix environment, it's more robust to use absolute paths from pkgs. Additionally, using $HOME instead of ~ and adding a check for the existence of the last symlink improves reliability.

          set -g @resurrect-hook-post-save-all 'd=$HOME/.tmux/resurrect; [ -L "$d/last" ] && f="$d/$(${pkgs.coreutils}/bin/readlink "$d/last")" && ${pkgs.gnugrep}/bin/grep -P "^(pane|window)\twork\t" "$f" > "$f.tmp" && ${pkgs.coreutils}/bin/printf "state\twork\n" >> "$f.tmp" && ${pkgs.coreutils}/bin/mv "$f.tmp" "$f"'

shunkakinoki added a commit that referenced this pull request Apr 21, 2026
* fix: tmux resurrect/continuum restore on NixOS

- Move plugin options to per-plugin extraConfig in default.nix so they
  are set before each plugin's run-shell
- Move status-right to continuum extraConfig so continuum can prepend
  its auto-save trigger (#(.../continuum_save.sh))
- Fix _two_function to create tmux server before resolving resurrect
  restore script path (was always empty after reboot)
- Switch grep -E to grep -P for tab matching in post-save hook

* fix: load resurrect before continuum in plugin order
shunkakinoki added a commit that referenced this pull request Apr 21, 2026
* chore(deps): lock file maintenance

Signed-off-by:

* chore(deps): update dependency mempalace to >=3.2.0 (#1525)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): lock file maintenance (#1526)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix/tmux resurrect nixos (#1529)

* fix: tmux resurrect/continuum restore on NixOS

- Move plugin options to per-plugin extraConfig in default.nix so they
  are set before each plugin's run-shell
- Move status-right to continuum extraConfig so continuum can prepend
  its auto-save trigger (#(.../continuum_save.sh))
- Fix _two_function to create tmux server before resolving resurrect
  restore script path (was always empty after reboot)
- Switch grep -E to grep -P for tab matching in post-save hook

* fix: load resurrect before continuum in plugin order

* chore(deps): update dotagents digest to dc0fdc0 (#1527)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): lock file maintenance (#1528)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): lock file maintenance (#1530)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency mistral-vibe to >=2.7.5 (#1531)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update rust crate worktrunk to 0.37.0 (#1532)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): lock file maintenance (#1533)

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix: remap framework copy for editors (#1534)

* fix: remap framework copy for editors

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* fix(keyd): centralize app mapper config

Move the Slack app mapper config into the shared keyd module so the host does not inline repo config paths.

Keep the keyd application mapper service in the shared module and preserve the sg keyd launch path that fixes Slack Framework+C in stale user sessions.

Co-authored-by: Codex <noreply@openai.com>

* ref(home-manager): move keyd app mapper service

Move the keyd application mapper user unit into the Home Manager services tree so service wiring follows the repo's shared service layout.

Keep config/keyd focused on keyd config and enable the mapper through an explicit Home Manager service option so the service can consume app.conf without recursive evaluation.

Co-authored-by: Codex <noreply@openai.com>

* ref(keyd): simplify app mapper wiring

Write app.conf from the shared keyd module again and keep the Home Manager service focused on the user unit.

Have the service read the standard xdg config path instead of carrying a configFile option, while keeping the restart hash tied to the resolved app.conf source.

Co-authored-by: Codex <noreply@openai.com>

---------

Co-authored-by: Codex <noreply@openai.com>

* fix: use extraLuaConfig instead of home.file for nvim init.lua

* fix: replace removed nodePackages with top-level packages

* fix: remove vllm from nix packages (managed via pyproject.toml)

---------

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <renovate@whitesourcesoftware.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Codex <noreply@openai.com>
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.

1 participant