Monday, 15 April 2024

My poetry shell.nix

https://gist.github.com/tom-010/ddb82ddcbbad2892ab60837af9dc3e18
{ pkgs ? import  {} }:

pkgs.mkShell {
  buildInputs = [
    pkgs.gcc
    pkgs.zsh
    pkgs.tmux
  ];

  shellHook = ''

    # Set the shell =================================================
    export SHELL=${pkgs.zsh}/bin/zsh
    source $(poetry env info --path)/bin/activate # instead of poetry shell

    # Setup the environment =========================================

    export LD_LIBRARY_PATH=${pkgs.gcc}/lib64:${pkgs.stdenv.cc.cc.lib}/lib:$LD_LIBRARY_PATH

    # Initialize tmux ===============================================

    # Prepare the tmux project layout ==============================

    # Get the name of the current directory to use as the tmux session name
    SESSION_NAME=$(basename "$(pwd)")

    if [ -z "$TMUX" ]; then
      # Primary: Start nvim
      tmux new-session -d -s "$SESSION_NAME" -n nvim
      tmux send-keys -t "$SESSION_NAME:nvim" 'nvim .' C-m
      # Secondary: Start server
      tmux new-window -t "$SESSION_NAME" -n 'server'
      tmux send-keys -t "$SESSION_NAME:server" 'make serve' C-m
      # Attach to nvim
      tmux select-window -t "$SESSION_NAME:nvim"
      tmux attach-session -t "$SESSION_NAME"
    fi

    exec ${pkgs.zsh}/bin/zsh
  '';
}

No comments:

Post a Comment

Parse Wikipedia dump

""" This module processes Wikipedia dump files by extracting individual articles and parsing them into a structured format, ...