Skip to content

Instantly share code, notes, and snippets.

@luochen1990
Last active July 11, 2024 07:53
Show Gist options
  • Save luochen1990/bdfb49a630d865afa5a41af7adcc3980 to your computer and use it in GitHub Desktop.
Save luochen1990/bdfb49a630d865afa5a41af7adcc3980 to your computer and use it in GitHub Desktop.
Demo for Nix as Shebang
#!/usr/bin/env nix-shell
#! nix-shell -p 'python3.withPackages (ps: with ps; [ msgspec ])' -i python3
import msgspec
print('hello')
#!/usr/bin/env nix
#! nix shell nixpkgs#bash --command bash -e
#Doc: https://nix.dev/manual/nix/2.22/command-ref/new-cli/nix3-shell#use-as-a--interpreter
echo Hello, $NAME
echo $@
# Usage:
# $ NAME=Nix ./hello.sh today is a good day!
# Hello, Nix
# today is a good day!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment