This repository has been archived by the owner on Nov 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Activation scripts! #22
Comments
Here's a translation of the default bash activation (with bash versions copied in to help out copilot) use std
let env_cols = ($env | columns)
# if [ -n "$HOME" ] && [ -n "$USER" ]; then
if ("HOME" in $env_cols) and ("USER" in $env_cols) {
# # Set up the per-user profile.
# NIX_LINK="$HOME/.nix-profile"
let NIX_LINK = $"($env.HOME)/.nix-profile"
let NIX_LINK_NEW = ""
# if [ -n "${XDG_STATE_HOME-}" ]; then
if "XDG_STATE_HOME" in $env_cols {
# else
} else {
# NIX_LINK_NEW="$HOME/.local/state/nix/profile"
let NIX_LINK_NEW = $"($env.HOME)/.local/state/nix/profile"
# fi
}
# if [ -e "$NIX_LINK_NEW" ]; then
if $NIX_LINK_NEW != "" {
# NIX_LINK="$NIX_LINK_NEW"
let NIX_LINK = $NIX_LINK_NEW
# else
} else {
# fi
}
# # Set up environment.
# # This part should be kept in sync with nixpkgs:nixos/modules/programs/environment.nix
# export NIX_PROFILES="/nix/var/nix/profiles/default $NIX_LINK"
$env.NIX_PROFILES = $"/nix/var/nix/profiles/default ($NIX_LINK)"
# # Populate bash completions, .desktop files, etc
# if [ -z "${XDG_DATA_DIRS-}" ]; then
if "XDG_DATA_DIRS" in $env_cols {
# # According to XDG spec the default is /usr/local/share:/usr/share, don't set something that prevents that default
# export XDG_DATA_DIRS="/usr/local/share:/usr/share:$NIX_LINK/share:/nix/var/nix/profiles/default/share"
$env.XDG_DATA_DIRS = $"/usr/local/share:/usr/share:($NIX_LINK)/share:/nix/var/nix/profiles/default/share"
# else
} else {
# export XDG_DATA_DIRS="$XDG_DATA_DIRS:$NIX_LINK/share:/nix/var/nix/profiles/default/share"
$env.XDG_DATA_DIRS = $"($NIX_LINK)/share:/nix/var/nix/profiles/default/share"
# fi
}
# # Set $NIX_SSL_CERT_FILE so that Nixpkgs applications like curl work.
# if [ -e /etc/ssl/certs/ca-certificates.crt ]; then # NixOS, Ubuntu, Debian, Gentoo, Arch
if ("/etc/ssl/certs/ca-certificates.crt" | path exists) {
# export NIX_SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
$env.NIX_SSL_CERT_FILE = "/etc/ssl/certs/ca-certificates.crt"
# elif [ -e /etc/ssl/ca-bundle.pem ]; then # openSUSE Tumbleweed
} else if ("/etc/ssl/ca-bundle.pem" | path exists) {
# export NIX_SSL_CERT_FILE=/etc/ssl/ca-bundle.pem
$env.NIX_SSL_CERT_FILE = "/etc/ssl/ca-bundle.pem"
# elif [ -e /etc/ssl/certs/ca-bundle.crt ]; then # Old NixOS
} else if ("/etc/ssl/certs/ca-bundle.crt" | path exists) {
# export NIX_SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt
$env.NIX_SSL_CERT_FILE = "/etc/ssl/certs/ca-bundle.crt"
# elif [ -e /etc/pki/tls/certs/ca-bundle.crt ]; then # Fedora, CentOS
} else if ("/etc/pki/tls/certs/ca-bundle.crt" | path exists) {
# export NIX_SSL_CERT_FILE=/etc/pki/tls/certs/ca-bundle.crt
$env.NIX_SSL_CERT_FILE = "/etc/pki/tls/certs/ca-bundle.crt"
# elif [ -e "$NIX_LINK/etc/ssl/certs/ca-bundle.crt" ]; then # fall back to cacert in Nix profile
} else if ($"($NIX_LINK)/etc/ssl/certs/ca-bundle.crt" | path exists) {
# export NIX_SSL_CERT_FILE="$NIX_LINK/etc/ssl/certs/ca-bundle.crt"
$env.NIX_SSL_CERT_FILE = $"($NIX_LINK)/etc/ssl/certs/ca-bundle.crt"
# elif [ -e "$NIX_LINK/etc/ca-bundle.crt" ]; then # old cacert in Nix profile
} else if ($"($NIX_LINK)/etc/ca-bundle.crt" | path exists) {
# export NIX_SSL_CERT_FILE="$NIX_LINK/etc/ca-bundle.crt"
$env.NIX_SSL_CERT_FILE = $"($NIX_LINK)/etc/ca-bundle.crt"
# fi
}
# # Only use MANPATH if it is already set. In general `man` will just simply
# # pick up `.nix-profile/share/man` because is it close to `.nix-profile/bin`
# # which is in the $PATH. For more info, run `manpath -d`.
# if [ -n "${MANPATH-}" ]; then
if "MANPATH" in $env_cols {
# export MANPATH="$NIX_LINK/share/man:$MANPATH"
$env.MANPATH = $"($NIX_LINK)/share/man:($env.MANPATH)"
# fi
}
# export PATH="$NIX_LINK/bin:$PATH"
std path add $"($NIX_LINK)/bin"
# unset NIX_LINK NIX_LINK_NEW
# fi
} Add to |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
It would be great to add Nushell tools for system activation scripts! :)
The text was updated successfully, but these errors were encountered: