BACK TO THE HOMEPAGE

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.

  1. Lets create a zellij layout script dev.kdl:

    NODE_TYPE // bash
    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.kdl script we create a new layout.

  2. We now need to tell Nix to add the dev.kdl external script as a dependency.

    NODE_TYPE // nix
    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
  3. Now we can create a shell.nix script:

    NODE_TYPE // nix
    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 zellij environment. When the nix script executes it will automatically call the dev-zellij to handle the screen layout. Use the exec zellij command to ensure an orphan session is not resident on exiting the nix session.

  4. Run the script:

    NODE_TYPE // bash
    nix-shell --pure

    Remember a pure environment tries to ignore the existing host configuration 😂 Nix will automatically look for the file shell.nix so you dont need to added this parameter 🥰

    Expected Output:

    NODE_TYPE // bash
    Welcome to Go Development Environment
    go version go1.25.5 darwin/arm64

    Awesome, Zellij is configured and ready to go!

  5. Exit the Nix Shell

    To exit, you will need to exit each screen individually.

    NODE_TYPE // bash
    exit

Nice we now have a super easy way to run Zellij on a Nix machine.