Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ function Connect-GitHub {
}

function Install-Nix {
# Track whether we installed Nix this run so Main can warn the user
# afterwards that `nix` won't be on PATH in new terminals until they
# restart the shell (env mutations from the installer don't propagate
# back to the parent process that curl|pwsh'd this script).
$script:NixJustInstalled = $false
if (-not (Test-Command 'nix')) {
if ($IsNativeWindows) {
Write-Info 'Nix is not natively supported on Windows.'
Expand All @@ -201,6 +206,7 @@ function Install-Nix {

Write-Info 'Installing Nix via Determinate Systems installer...'
bash -c "curl --proto '=https' --tlsv1.2 -sSf -L '$NixInstallUrl' | sh -s -- install"
$script:NixJustInstalled = $true

# Source nix in current shell
if (Test-Path '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh') {
Expand Down Expand Up @@ -501,6 +507,22 @@ function Show-RepoInfo {
Write-Host ' make anchor-build, make anchor-test'
Write-Host ''
}
'dotnet-sdk' {
Write-Host ''
Write-Host ' What''s included:' -ForegroundColor White
Write-Host ''
Write-Host ' .NET 9 SDK, Protobuf toolchain'
Write-Host ' dotnet build -c Release, dotnet test -c Release'
Write-Host ''
}
'landing' {
Write-Host ''
Write-Host ' What''s included:' -ForegroundColor White
Write-Host ''
Write-Host ' Bun, Next.js 15, Tailwind CSS, TypeScript'
Write-Host ' bun dev, bun run build'
Write-Host ''
}
'pypi' {
Write-Host ''
Write-Host ' What''s included:' -ForegroundColor White
Expand Down Expand Up @@ -575,6 +597,16 @@ function Main {

Write-Host ' Ready!' -ForegroundColor Green
Write-Host ''

if ($script:NixJustInstalled) {
Write-Host ' Note:' -ForegroundColor Yellow -NoNewline
Write-Host ' Nix was just installed. For `nix` to be on PATH, either:'
Write-Host ' - open a new terminal, or'
Write-Host ' - run: . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
Write-Host ' (fish users: set -x PATH /nix/var/nix/profiles/default/bin $PATH)'
Write-Host ''
}

Write-Host ' Get started:' -ForegroundColor White
Write-Host ''
Write-Host " cd $($script:TargetDir)"
Expand Down
47 changes: 44 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,21 @@ authenticate_gh() {
}

install_nix() {
# Track whether Determinate installed Nix this session so we can remind the
# user to start a fresh shell (or source the profile) for `nix` to be on
# PATH in their interactive terminal — env mutations inside `curl | sh`
# don't propagate to the parent process.
NIX_JUST_INSTALLED=0
if ! has nix; then
if ! confirm "Install Nix package manager?"; then
warn "Skipping Nix install — some repos require Nix for their dev environment."
return 0
fi
info "Installing Nix via Determinate Systems installer..."
curl --proto '=https' --tlsv1.2 -sSf -L "$NIX_INSTALL_URL" | sh -s -- install
NIX_JUST_INSTALLED=1

# Source nix in current shell
# Source nix in current shell (this script's process only; see note above).
# shellcheck disable=SC1091
if [ -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]; then
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
Expand Down Expand Up @@ -461,13 +467,26 @@ install_resq_completions() {
esac

mkdir -p "$_compl_dir"
if "$_bin_path" completions "$_shell_name" > "$_compl_file" 2>/dev/null; then
# Capture stderr on failure so the user sees the real reason. Older resq
# binaries (before v0.2.7) don't know about `completions`; newer ones do.
# Using mktemp (not /tmp/...$$) so TMPDIR is honoured and we can't collide
# with a stale file owned by another user on a shared host.
_err_tmp="$(mktemp)"
_compl_err="$("$_bin_path" completions "$_shell_name" 2> "$_err_tmp" > "$_compl_file" && echo ok || echo fail)"
if [ "$_compl_err" = "ok" ] && [ -s "$_compl_file" ]; then
rm -f "$_err_tmp"
ok "Installed $_shell_name completions to $_compl_file"
if [ "$_shell_name" = "zsh" ]; then
info " zsh: add to ~/.zshrc if not already: fpath+=(\"$_compl_dir\"); autoload -Uz compinit && compinit"
fi
else
Comment thread
WomB0ComB0 marked this conversation as resolved.
warn "Failed to generate $_shell_name completions — skip"
_err_msg="$(head -n 1 "$_err_tmp" 2>/dev/null)"
rm -f "$_compl_file" "$_err_tmp"
if [ -n "$_err_msg" ]; then
warn "Failed to generate $_shell_name completions: $_err_msg"
else
warn "Failed to generate $_shell_name completions (empty output — the installed resq may predate the 'completions' subcommand; retry once a newer release is out)"
fi
fi
}

Expand All @@ -478,6 +497,16 @@ print_repo_info() {
printf " Solana CLI, Anchor framework, Rust toolchain\n" >&2
printf " make anchor-build, make anchor-test\n\n" >&2
;;
dotnet-sdk)
printf "\n ${BOLD}What's included:${RESET}\n\n" >&2
printf " .NET 9 SDK, Protobuf toolchain\n" >&2
printf " dotnet build -c Release, dotnet test -c Release\n\n" >&2
;;
landing)
printf "\n ${BOLD}What's included:${RESET}\n\n" >&2
printf " Bun, Next.js 15, Tailwind CSS, TypeScript\n" >&2
printf " bun dev, bun run build\n\n" >&2
;;
pypi)
printf "\n ${BOLD}What's included:${RESET}\n\n" >&2
printf " Python 3.11-3.13, uv, ruff, mypy\n" >&2
Expand Down Expand Up @@ -531,6 +560,18 @@ main() {
print_repo_info

printf "${BOLD}${GREEN} Ready!${RESET}\n\n" >&2

# If Determinate installed Nix this run, the user's interactive shell
# (which spawned `curl | sh`) hasn't sourced the profile yet. Flag this
# prominently before the "Get started" list so they don't hit
# `nix: command not found` when they follow the instructions.
if [ "${NIX_JUST_INSTALLED:-0}" = "1" ]; then
printf " ${BOLD}${YELLOW}Note:${RESET} Nix was just installed. For \`nix\` to be on PATH, either:\n" >&2
printf " - open a new terminal, or\n" >&2
printf " - run: . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh\n" >&2
printf " (fish users: set -x PATH /nix/var/nix/profiles/default/bin \$PATH)\n\n" >&2
fi

printf " ${BOLD}Get started:${RESET}\n\n" >&2
printf " cd %s\n" "$TARGET_DIR" >&2
if [ -f "$TARGET_DIR/flake.nix" ]; then
Expand Down
Loading