mirror of
https://github.com/NixOS/nix
synced 2024-10-18 00:16:11 -04:00
Compare commits
11 commits
ed8b0964ac
...
4cf6045ecf
Author | SHA1 | Date | |
---|---|---|---|
4cf6045ecf | |||
ab0f9f9089 | |||
de0a34a362 | |||
3c59df412a | |||
bd1961b7cc | |||
30655dd146 | |||
1f0bb21f7c | |||
6372bfd255 | |||
2712972cfd | |||
034ba1aa69 | |||
6c0b232173 |
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -40,6 +40,8 @@ perl/Makefile.config
|
|||
/scripts/nix-profile-daemon.sh
|
||||
/scripts/nix-profile.fish
|
||||
/scripts/nix-profile-daemon.fish
|
||||
/scripts/nix-profile.nu
|
||||
/scripts/nix-profile-daemon.nu
|
||||
|
||||
# /src/libexpr/
|
||||
/src/libexpr/lexer-tab.cc
|
||||
|
|
|
@ -50,6 +50,17 @@ readonly PROFILE_FISH_PREFIXES=(
|
|||
)
|
||||
readonly PROFILE_NIX_FILE_FISH="$NIX_ROOT/var/nix/profiles/default/etc/profile.d/nix-daemon.fish"
|
||||
|
||||
# Nu has different syntax than zsh/bash, treat it separate
|
||||
readonly PROFILE_NU_SUFFIX="nushell/vendor/autoload/nix.nu"
|
||||
readonly PROFILE_NU_PREFIXES=(
|
||||
# each of these are common values of $nu.vendor-autoload-dirs,
|
||||
# under which Fish will look for a file named
|
||||
# $PROFILE_NU_SUFFIX.
|
||||
# "/usr/share" # not good for Macos
|
||||
"/usr/local/share"
|
||||
)
|
||||
readonly PROFILE_NIX_FILE_NU="$NIX_ROOT/var/nix/profiles/default/etc/profile.d/nix-daemon.nu"
|
||||
|
||||
readonly NIX_INSTALLED_NIX="@nix@"
|
||||
readonly NIX_INSTALLED_CACERT="@cacert@"
|
||||
#readonly NIX_INSTALLED_NIX="/nix/store/j8dbv5w6jl34caywh2ygdy88knx1mdf7-nix-2.3.6"
|
||||
|
@ -876,6 +887,17 @@ end
|
|||
EOF
|
||||
}
|
||||
|
||||
# Nu has differing syntax
|
||||
nu_source_lines() {
|
||||
cat <<EOF
|
||||
|
||||
# Nix
|
||||
if ("$PROFILE_NIX_FILE_NU" | path exists) { use $PROFILE_NIX_FILE_NU }
|
||||
# End Nix
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
configure_shell_profile() {
|
||||
task "Setting up shell profiles: ${PROFILE_TARGETS[*]}"
|
||||
for profile_target in "${PROFILE_TARGETS[@]}"; do
|
||||
|
@ -918,6 +940,25 @@ configure_shell_profile() {
|
|||
tee "$profile_target"
|
||||
done
|
||||
|
||||
task "Setting up shell profiles for Nu with ${PROFILE_NU_SUFFIX} inside ${PROFILE_NU_PREFIXES[*]}"
|
||||
for nu_prefix in "${PROFILE_NU_PREFIXES[@]}"; do
|
||||
if [ ! -d "$nu_prefix" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
profile_target="${nu_prefix}/${PROFILE_NU_SUFFIX}"
|
||||
conf_dir=$(dirname "$profile_target")
|
||||
if [ ! -d "$conf_dir" ]; then
|
||||
_sudo "create $conf_dir for our Nu hook" \
|
||||
mkdir -p "$conf_dir"
|
||||
fi
|
||||
|
||||
nu_source_lines \
|
||||
| _sudo "write nix-daemon settings to $profile_target" \
|
||||
tee "$profile_target"
|
||||
done
|
||||
|
||||
|
||||
# TODO: should we suggest '. $PROFILE_NIX_FILE'? It would get them on
|
||||
# their way less disruptively, but a counter-argument is that they won't
|
||||
# immediately notice if something didn't get set up right?
|
||||
|
|
|
@ -218,6 +218,7 @@ added=
|
|||
p=
|
||||
p_sh=$NIX_LINK/etc/profile.d/nix.sh
|
||||
p_fish=$NIX_LINK/etc/profile.d/nix.fish
|
||||
p_nu=$NIX_LINK/etc/profile.d/nix.nu
|
||||
if [ -z "$NIX_INSTALLER_NO_MODIFY_PROFILE" ]; then
|
||||
# Make the shell source nix.sh during login.
|
||||
for i in .bash_profile .bash_login .profile; do
|
||||
|
@ -257,6 +258,13 @@ if [ -z "$NIX_INSTALLER_NO_MODIFY_PROFILE" ]; then
|
|||
added=1
|
||||
p=${p_fish}
|
||||
fi
|
||||
|
||||
if [ -d "$HOME/.config/nushell" ]; then
|
||||
fn="$HOME/.config/nushell/env.nu"
|
||||
printf '\nif ("%s" | path exists) { use %s } # added by Nix installer\n' "$p_nu" "$p_nu" >> "$fn"
|
||||
added=1
|
||||
p=${p_nu}
|
||||
fi
|
||||
else
|
||||
p=${p_sh}
|
||||
fi
|
||||
|
|
|
@ -7,7 +7,9 @@ profiledir = $(sysconfdir)/profile.d
|
|||
|
||||
$(eval $(call install-file-as, $(d)/nix-profile.sh, $(profiledir)/nix.sh, 0644))
|
||||
$(eval $(call install-file-as, $(d)/nix-profile.fish, $(profiledir)/nix.fish, 0644))
|
||||
$(eval $(call install-file-as, $(d)/nix-profile.nu, $(profiledir)/nix.nu, 0644))
|
||||
$(eval $(call install-file-as, $(d)/nix-profile-daemon.sh, $(profiledir)/nix-daemon.sh, 0644))
|
||||
$(eval $(call install-file-as, $(d)/nix-profile-daemon.fish, $(profiledir)/nix-daemon.fish, 0644))
|
||||
$(eval $(call install-file-as, $(d)/nix-profile-daemon.nu, $(profiledir)/nix-daemon.nu, 0644))
|
||||
|
||||
clean-files += $(nix_noinst_scripts)
|
||||
|
|
61
scripts/nix-profile-daemon.nu.in
Normal file
61
scripts/nix-profile-daemon.nu.in
Normal file
|
@ -0,0 +1,61 @@
|
|||
export-env {
|
||||
|
||||
# Only execute this file once per shell.
|
||||
if ('__ETC_PROFILE_NIX_SOURCED' not-in $env) {
|
||||
|
||||
mut NIX_LINK = [$env.HOME '.nix-profile'] | path join;
|
||||
mut NIX_LINK_NEW = [$env.HOME '.local/state/nix/profile'];
|
||||
if 'XDG_STATE_HOME' in $env {
|
||||
$NIX_LINK_NEW = [$env.XDG_STATE_HOME 'nix/profile'];
|
||||
}
|
||||
$NIX_LINK_NEW = ($NIX_LINK_NEW | path join);
|
||||
if ($NIX_LINK_NEW | path exists) {
|
||||
$NIX_LINK = $NIX_LINK_NEW;
|
||||
}
|
||||
|
||||
let NIX_PROFILES = (['@localstatedir@/nix/profiles/default' $NIX_LINK] | str join ' ');
|
||||
|
||||
# Populate bash completions, .desktop files, etc
|
||||
mut XDG_DATA_DIRS = '';
|
||||
if 'XDG_DATA_DIRS' not-in $env {
|
||||
# According to XDG spec the default is /usr/local/share:/usr/share, don't set something that prevents that default
|
||||
$XDG_DATA_DIRS = (['/usr/local/share' '/usr/share'] | str join (char esep));
|
||||
}
|
||||
$XDG_DATA_DIRS = (
|
||||
$XDG_DATA_DIRS
|
||||
| split row (char esep)
|
||||
| append ([$NIX_LINK 'share'] | path join)
|
||||
| append '/nix/var/nix/profiles/default/share'
|
||||
| str join (char esep)
|
||||
);
|
||||
|
||||
# Set $NIX_SSL_CERT_FILE so that Nixpkgs applications like curl work.
|
||||
mut NIX_SSL_CERT_FILE = '';
|
||||
if ('NIX_SSL_CERT_FILE' in $env) {
|
||||
# Allow users to override the NIX_SSL_CERT_FILE
|
||||
} else if ('/etc/ssl/certs/ca-certificates.crt' | path exists) { # NixOS, Ubuntu, Debian, Gentoo, Arch
|
||||
$NIX_SSL_CERT_FILE = '/etc/ssl/certs/ca-certificates.crt';
|
||||
} else if ('/etc/ssl/ca-bundle.pem' | path exists) { # openSUSE Tumbleweed
|
||||
$NIX_SSL_CERT_FILE = '/etc/ssl/ca-bundle.pem';
|
||||
} else if ('/etc/ssl/certs/ca-bundle.crt' | path exists) { # Old NixOS
|
||||
$NIX_SSL_CERT_FILE = '/etc/ssl/certs/ca-bundle.crt';
|
||||
} else if ('/etc/pki/tls/certs/ca-bundle.crt' | path exists) { # Fedora, CentOS
|
||||
$NIX_SSL_CERT_FILE = '/etc/pki/tls/certs/ca-bundle.crt';
|
||||
} else {
|
||||
# Fall back to what is in the nix profiles, favouring whatever is defined last.
|
||||
let last = $NIX_PROFILES
|
||||
| split row (char space)
|
||||
| where ([$it 'etc/ssl/certs/ca-bundle.crt'] | path join | path exists)
|
||||
| last;
|
||||
|
||||
$NIX_SSL_CERT_FILE = ([$last 'etc/ssl/certs/ca-bundle.crt'] | path join);
|
||||
}
|
||||
|
||||
$env.NIX_PROFILES = $NIX_PROFILES
|
||||
$env.XDG_DATA_DIRS = $XDG_DATA_DIRS
|
||||
$env.NIX_SSL_CERT_FILE = $NIX_SSL_CERT_FILE
|
||||
$env.PATH = ($env.PATH | prepend '@localstatedir@/nix/profiles/default/bin' | prepend ([$NIX_LINK 'bin'] | path join));
|
||||
}
|
||||
|
||||
$env.__ETC_PROFILE_NIX_SOURCED = 1;
|
||||
}
|
63
scripts/nix-profile.nu.in
Normal file
63
scripts/nix-profile.nu.in
Normal file
|
@ -0,0 +1,63 @@
|
|||
export-env {
|
||||
if ([$env.HOME $env.USER] | all {nu-check}) {
|
||||
|
||||
# Set up the per-user profile.
|
||||
mut NIX_LINK = [$env.HOME '.nix-profile'] | path join;
|
||||
mut NIX_LINK_NEW = [$env.HOME '.local/state/nix/profile'];
|
||||
if 'XDG_STATE_HOME' in $env {
|
||||
$NIX_LINK_NEW = [$env.XDG_STATE_HOME 'nix/profile'];
|
||||
}
|
||||
$NIX_LINK_NEW = ($NIX_LINK_NEW | path join);
|
||||
if ($NIX_LINK_NEW | path exists) {
|
||||
$NIX_LINK = $NIX_LINK_NEW;
|
||||
}
|
||||
|
||||
# Set up environment.
|
||||
# This part should be kept in sync with nixpkgs:nixos/modules/programs/environment.nix
|
||||
let NIX_PROFILES = (['@localstatedir@/nix/profiles/default' $NIX_LINK] | str join ' ');
|
||||
|
||||
# Populate bash completions, .desktop files, etc
|
||||
mut XDG_DATA_DIRS = '';
|
||||
if 'XDG_DATA_DIRS' not-in $env {
|
||||
# According to XDG spec the default is /usr/local/share:/usr/share, don't set something that prevents that default
|
||||
$XDG_DATA_DIRS = (['/usr/local/share' '/usr/share'] | str join (char esep));
|
||||
}
|
||||
$XDG_DATA_DIRS = (
|
||||
$XDG_DATA_DIRS
|
||||
| split row (char esep)
|
||||
| append ([$NIX_LINK 'share'] | path join)
|
||||
| append '/nix/var/nix/profiles/default/share'
|
||||
| str join (char esep)
|
||||
);
|
||||
|
||||
# Set $NIX_SSL_CERT_FILE so that Nixpkgs applications like curl work.
|
||||
mut NIX_SSL_CERT_FILE = '';
|
||||
if ('/etc/ssl/certs/ca-certificates.crt' | path exists) { # NixOS, Ubuntu, Debian, Gentoo, Arch
|
||||
$NIX_SSL_CERT_FILE = '/etc/ssl/certs/ca-certificates.crt';
|
||||
} else if ('/etc/ssl/ca-bundle.pem' | path exists) { # openSUSE Tumbleweed
|
||||
$NIX_SSL_CERT_FILE = '/etc/ssl/ca-bundle.pem';
|
||||
} else if ('/etc/ssl/certs/ca-bundle.crt' | path exists) { # Old NixOS
|
||||
$NIX_SSL_CERT_FILE = '/etc/ssl/certs/ca-bundle.crt';
|
||||
} else if ('/etc/pki/tls/certs/ca-bundle.crt' | path exists) { # Fedora, CentOS
|
||||
$NIX_SSL_CERT_FILE = '/etc/pki/tls/certs/ca-bundle.crt';
|
||||
} else if ([$NIX_LINK 'etc/ssl/certs/ca-bundle.crt'] | path join | path exists) { # fall back to cacert in Nix profile
|
||||
$NIX_SSL_CERT_FILE = ([$NIX_LINK 'etc/ssl/certs/ca-bundle.crt'] | path join);
|
||||
} else if ([$NIX_LINK 'etc/ca-bundle.crt'] | path join | path exists) { # old cacert in Nix profile
|
||||
$NIX_SSL_CERT_FILE = ([$NIX_LINK '/etc/ca-bundle.crt'] | path join);
|
||||
}
|
||||
|
||||
# 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 ('MANPATH' in $env) {
|
||||
export-env {
|
||||
$env.MANPATH = ([$NIX_LINK 'share/man'] | path join | append $"(char esep)($env.MANPATH)")
|
||||
}
|
||||
}
|
||||
|
||||
$env.NIX_PROFILES = $NIX_PROFILES
|
||||
$env.XDG_DATA_DIRS = $XDG_DATA_DIRS
|
||||
$env.NIX_SSL_CERT_FILE = $NIX_SSL_CERT_FILE
|
||||
$env.PATH = ($env.PATH | prepend ([$NIX_LINK 'bin'] | path join))
|
||||
}
|
||||
}
|
|
@ -208,7 +208,7 @@ static git_packbuilder_progress PACKBUILDER_PROGRESS_CHECK_INTERRUPT = &packBuil
|
|||
static void initRepoAtomically(std::filesystem::path &path, bool bare) {
|
||||
if (pathExists(path.string())) return;
|
||||
|
||||
Path tmpDir = createTempDir(std::filesystem::path(path).parent_path());
|
||||
Path tmpDir = createTempDir(os_string_to_string(PathViewNG { std::filesystem::path(path).parent_path() }));
|
||||
AutoDelete delTmpDir(tmpDir, true);
|
||||
Repository tmpRepo;
|
||||
|
||||
|
|
|
@ -50,8 +50,9 @@ R""(
|
|||
|
||||
# Description
|
||||
|
||||
This command evaluates the given Nix expression and prints the
|
||||
result on standard output.
|
||||
This command evaluates the given Nix expression, and prints the result on standard output.
|
||||
|
||||
It also evaluates any nested attribute values and list items.
|
||||
|
||||
# Output format
|
||||
|
||||
|
|
|
@ -212,18 +212,23 @@ nix_symlinks = [
|
|||
'nix-store',
|
||||
]
|
||||
|
||||
executable_suffix = ''
|
||||
if host_machine.system() == 'windows'
|
||||
executable_suffix = '.exe'
|
||||
endif
|
||||
|
||||
foreach linkname : nix_symlinks
|
||||
install_symlink(
|
||||
linkname,
|
||||
linkname + executable_suffix,
|
||||
# TODO(Qyriad): should these continue to be relative symlinks?
|
||||
pointing_to : 'nix',
|
||||
pointing_to : fs.name(this_exe),
|
||||
install_dir : get_option('bindir'),
|
||||
# The 'runtime' tag is what executables default to, which we want to emulate here.
|
||||
install_tag : 'runtime'
|
||||
)
|
||||
t = custom_target(
|
||||
command: ['ln', '-sf', fs.name(this_exe), '@OUTPUT@'],
|
||||
output: linkname,
|
||||
output: linkname + executable_suffix,
|
||||
# TODO(Ericson2314): Don't do this once we have the `meson.override_find_program` working)
|
||||
build_by_default: true
|
||||
)
|
||||
|
@ -233,15 +238,15 @@ endforeach
|
|||
|
||||
install_symlink(
|
||||
'build-remote',
|
||||
pointing_to : '..' / '..'/ get_option('bindir') / 'nix',
|
||||
install_dir : get_option('libexecdir') / 'nix',
|
||||
pointing_to : '..' / '..'/ get_option('bindir') / fs.name(this_exe),
|
||||
install_dir : get_option('libexecdir') / fs.name(this_exe),
|
||||
# The 'runtime' tag is what executables default to, which we want to emulate here.
|
||||
install_tag : 'runtime'
|
||||
)
|
||||
|
||||
custom_target(
|
||||
command: ['ln', '-sf', fs.name(this_exe), '@OUTPUT@'],
|
||||
output: 'build-remote',
|
||||
output: 'build-remote' + executable_suffix,
|
||||
# TODO(Ericson2314): Don't do this once we have the `meson.override_find_program` working)
|
||||
build_by_default: true
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue