Apr 16, 2025
Simple Nix Template
Name the script shell.nix
and put it under the directory. Use nix-shell
to boot up the environment.
Python
{
pkgs ? import <nixpkgs> { },
}:
pkgs.mkShell {
buildInputs = [
(pkgs.python311.withPackages (
ps: with ps; [
numpy
pandas
# ...
]
))
];
}
Rust
If you want to specify the gcc version:
{
pkgs ? import <nixpkgs> { },
}:
with pkgs;
stdenvNoCC.mkDerivation {
name = "rust-llvm";
buildInputs = [
gcc10
clang
llvmPackages.libclang
pkgs.cargo
pkgs.rustc
bashInteractive
];
shellHook = ''
export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib";
'';
}