Feb 04, 2026 • 3 min read
Nix Zellij
A quick blog post on using nix with Zellij.
Where I can’t get my favourite Tmux configuration going, I often turn to Zellij. Zellij is a great alternative to Tmux and offers some cool elements, which I may revisit in a future blog post. For now, I just want to outline how to perform a similar layout configuration to the Tmux one I recently wrote.
You can amend the configuration used to setup the screen however you wish.
Just amend the dev.kdl script to realign your screen layout however you want.
Nix Scripts
To get started we need to define an external script to represent the environment requirement. Zellij uses kdl files to represent screen layouts, so the configuration slightly different to Tmux.
-
Lets create a zellij layout script
dev.kdl:layout { tab name="Go Dev" focus=true { pane split_direction="vertical" { pane { name "Terminal#1" } pane split_direction="horizontal" { pane { name "Termina#2" } pane { name "Terminal#3" } } } } }In the above
dev.kdlscript we create a new layout. -
We now need to tell Nix to add the
dev.kdlexternal script as a dependency.let # External Script: This reads './dev.kdl' and puts it into a binary named 'dev-kdl' # The layout is then set as a dependency for the `zellijLayout` which will be used in the script. scriptZellijLayout = pkgs.writeText "dev.kdl" (builtins.readFile ./dev.kdl); zellijLayout = pkgs.writeShellScriptBin "dev-zellij" '' ${pkgs.zellij}/bin/zellij --layout ${scriptZellijLayout} ''; in -
Now we can create a
shell.nixscript:with import <nixpkgs> {}; let scriptZellijLayout = pkgs.writeText "dev.kdl" (builtins.readFile ./dev.kdl); zellijLayout = pkgs.writeShellScriptBin "dev-zellij" '' ${pkgs.zellij}/bin/zellij --layout ${scriptZellijLayout} ''; in pkgs.mkShell { name = "go-dev"; nativeBuildInputs = with pkgs; [ go zellij zellijLayout # Custom Zellij script with layout ]; LANGUAGE = "Go"; VERSION = "go version"; shellHook = '' # Optional: Script environment start up echo "Welcome to $LANGUAGE Development Environment" $VERSION # Perform Zellij Dev Layout exec dev-zellij ''; }The above script will initiate a
zellijenvironment. When the nix script executes it will automatically call the dev-zellij to handle the screen layout. Use theexec zellijcommand to ensure an orphan session is not resident on exiting the nix session. -
Run the script:
nix-shell --pureRemember a pure environment tries to ignore the existing host configuration 😂 Nix will automatically look for the file
shell.nixso you dont need to added this parameter 🥰Expected Output:
Welcome to Go Development Environment go version go1.25.5 darwin/arm64Awesome, Zellij is configured and ready to go!
-
Exit the Nix Shell
To exit, you will need to exit each screen individually.
exit
Nice we now have a super easy way to run Zellij on a Nix machine.