Last active
September 27, 2024 09:51
-
-
Save mwmdev/04ce97f10cd09e3e14e57fc2328fca68 to your computer and use it in GitHub Desktop.
Setup script for python environment on nixos.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Step 1: Check if shell.nix exists; if not, create it | |
| if [ ! -f shell.nix ]; then | |
| cat <<'EOF' > shell.nix | |
| { pkgs ? import <nixpkgs> {} }: | |
| pkgs.mkShell { | |
| buildInputs = [ | |
| pkgs.python3 | |
| pkgs.python3.pkgs.virtualenv | |
| pkgs.gcc | |
| pkgs.glibc | |
| pkgs.git | |
| pkgs.stdenv.cc.cc.lib | |
| ]; | |
| # Set environment variables | |
| env = { | |
| LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.glibc}/lib"; | |
| }; | |
| shellHook = '' | |
| if [ ! -d ".venv" ]; then | |
| virtualenv .venv | |
| source .venv/bin/activate | |
| else | |
| source .venv/bin/activate | |
| fi | |
| ''; | |
| } | |
| EOF | |
| fi | |
| # Step 2: Run nix-shell to enter the Nix shell environment | |
| nix-shell |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can be executed remotely with an alias like :