Skip to content

Commit

Permalink
Fix installer script bugs
Browse files Browse the repository at this point in the history
- --no-channel-add didn't have effect on multi-user installation
- some new flags didn't work at all
- document all installer flags
  • Loading branch information
domenkozar committed May 26, 2020
1 parent 909bdfb commit 1a5ac89
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
24 changes: 14 additions & 10 deletions scripts/install-multi-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ readonly NIX_FIRST_BUILD_UID="30001"
# Please don't change this. We don't support it, because the
# default shell profile that comes with Nix doesn't support it.
readonly NIX_ROOT="/nix"
readonly NIX_EXTRA_CONF=${NIX_EXTRA_CONF:-}

readonly PROFILE_TARGETS=("/etc/bashrc" "/etc/profile.d/nix.sh" "/etc/zshrc")
readonly PROFILE_BACKUP_SUFFIX=".backup-before-nix"
Expand Down Expand Up @@ -452,9 +453,11 @@ create_directories() {
}

place_channel_configuration() {
echo "https://nixos.org/channels/nixpkgs-unstable nixpkgs" > "$SCRATCH/.nix-channels"
_sudo "to set up the default system channel (part 1)" \
install -m 0664 "$SCRATCH/.nix-channels" "$ROOT_HOME/.nix-channels"
if [ -z "$NIX_INSTALLER_NO_CHANNEL_ADD" ]; then
echo "https://nixos.org/channels/nixpkgs-unstable nixpkgs" > "$SCRATCH/.nix-channels"
_sudo "to set up the default system channel (part 1)" \
install -m 0664 "$SCRATCH/.nix-channels" "$ROOT_HOME/.nix-channels"
fi
}

welcome_to_nix() {
Expand Down Expand Up @@ -636,13 +639,14 @@ setup_default_profile() {
export NIX_SSL_CERT_FILE=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
fi

# Have to explicitly pass NIX_SSL_CERT_FILE as part of the sudo call,
# otherwise it will be lost in environments where sudo doesn't pass
# all the environment variables by default.
_sudo "to update the default channel in the default profile" \
HOME="$ROOT_HOME" NIX_SSL_CERT_FILE="$NIX_SSL_CERT_FILE" "$NIX_INSTALLED_NIX/bin/nix-channel" --update nixpkgs \
|| channel_update_failed=1

if [ -z "$NIX_INSTALLER_NO_CHANNEL_ADD" ]; then
# Have to explicitly pass NIX_SSL_CERT_FILE as part of the sudo call,
# otherwise it will be lost in environments where sudo doesn't pass
# all the environment variables by default.
_sudo "to update the default channel in the default profile" \
HOME="$ROOT_HOME" NIX_SSL_CERT_FILE="$NIX_SSL_CERT_FILE" "$NIX_INSTALLED_NIX/bin/nix-channel" --update nixpkgs \
|| channel_update_failed=1
fi
}


Expand Down
13 changes: 8 additions & 5 deletions scripts/install-nix-from-closure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ fi

INSTALL_MODE=no-daemon
CREATE_DARWIN_VOLUME=0
NIX_EXTRA_CONF=
# handle the command line flags
while [ $# -gt 0 ]; do
case $1 in
Expand All @@ -50,20 +49,20 @@ while [ $# -gt 0 ]; do
--no-daemon)
INSTALL_MODE=no-daemon;;
--no-channel-add)
NIX_INSTALLER_NO_CHANNEL_ADD=1;;
export NIX_INSTALLER_NO_CHANNEL_ADD=1;;
--daemon-user-count)
NIX_USER_COUNT=$2
export NIX_USER_COUNT=$2
shift;;
--no-modify-profile)
NIX_INSTALLER_NO_MODIFY_PROFILE=1;;
--darwin-use-unencrypted-nix-store-volume)
CREATE_DARWIN_VOLUME=1;;
--nix-extra-conf-file)
NIX_EXTRA_CONF=$(cat $2)
export NIX_EXTRA_CONF="$(cat $2)"
shift;;
*)
(
echo "Nix Installer [--daemon|--no-daemon] [--no-channel-add] [--no-modify-profile]"
echo "Nix Installer [--daemon|--no-daemon] [--daemon-user-count INT] [--no-channel-add] [--no-modify-profile] [--darwin-use-unencrypted-nix-store-volume] [--nix-extra-conf-file FILE]"

echo "Choose installation method."
echo ""
Expand All @@ -82,6 +81,10 @@ while [ $# -gt 0 ]; do
echo " --no-modify-profile: Skip channel installation. When not provided nixpkgs-unstable"
echo " is installed by default."
echo ""
echo " --daemon-user-count: Number of build users to create. Defaults to 32."
echo ""
echo " --nix-extra-conf-file: Path to nix.conf to prepend when installing /etc/nix.conf"
echo ""
) >&2

# darwin and Catalina+
Expand Down

0 comments on commit 1a5ac89

Please sign in to comment.