Skip to content

Instantly share code, notes, and snippets.

@xfthhxk
Last active September 22, 2025 00:41
Show Gist options
  • Select an option

  • Save xfthhxk/0d72b290f8c6ab23b26791fae6252e34 to your computer and use it in GitHub Desktop.

Select an option

Save xfthhxk/0d72b290f8c6ab23b26791fae6252e34 to your computer and use it in GitHub Desktop.
example using nix with clojure and other dev tools
{ use_zsh ? "true" }:
let
# nixos-25.05 stable as of 4 Aug 2025. See: https://status.nixos.org
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/archive/ce01daebf8489ba97bd1609d185ea276efdeb121.tar.gz";
pkgs = import nixpkgs { config = {}; overlays = []; };
in
pkgs.mkShell {
packages = [
pkgs.clojure
pkgs.babashka
pkgs.clj-kondo
pkgs.cljfmt
pkgs.temurin-bin
pkgs.nodejs
pkgs.google-cloud-sdk
pkgs.docker
pkgs.docker-buildx
pkgs.docker-compose
pkgs.pulumi
pkgs.pulumiPackages.pulumi-nodejs
pkgs.postgresql
pkgs.mkcert
pkgs.nss.tools # provides certutil for mkcert
pkgs.openssl
pkgs.libgcc.lib # provides libgomp which is needed for datalevin
pkgs.zsh
];
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.libgcc.lib}/lib:$LD_LIBRARY_PATH" # needed by datalevin
export CLOUD_PYTHON=`which python` # force gcloud to use the installed python
if [[ ${use_zsh} = true ]]
then
exec zsh
fi
'';
}
#------------------------------------------------------------
# Uncomment and put the following in .zshrc
# to show nix shell is activated
#------------------------------------------------------------
# if [[ $IN_NIX_SHELL ]]
# then
# PROJECT=`basename $PWD`
# PROMPT='%(?:%{%}%1{➜%} :%{%}%1{➜%} ) %F{yellow}[nix:$PROJECT]%f %{%}%c%{%} $(git_prompt_info)'
# fi
@xfthhxk
Copy link
Author

xfthhxk commented Aug 6, 2025

Running sudo can get tricky inside of nix-shells because sudo won't be able to find programs that exist only inside of nix.
This seems to work however.

sudo PATH=$PATH `which bb` some_file.clj

You can add other env vars on the cli to sudo for example $HOME to preserve the current user's $HOME env varlue

sudo PATH=$PATH HOME=$HOME USER=$USER `which bb` some_file.clj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment