$ curl -L https://nixos.org/nix/install | sh -s -- --daemon
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
100 4267 100 4267 0 0 1622 0 0:00:02 0:00:02 --:--:-- 7147
downloading Nix 2.32.4 binary tarball for x86_64-linux from 'https://releases.nixos.org/nix/nix-2.32.4/nix-2.32.4-x86_64-linux.tar.xz' to '/tmp/nix-binary-tarball-unpack.t6xBSMNsyb'...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 24.8M 100 24.8M 0 0 797k 0 0:00:31 0:00:31 --:--:-- 786k
Note: a multi-user installation is possible. See https://nix.dev/manual/nix/stable/installation/installing-binary.html#multi-user-installation
Switching to the Multi-user Installer
Welcome to the Multi-User Nix Installation
This installation tool will set up your computer with the Nix package
manager. This will happen in a few stages:
1. Make sure your computer doesn't already have Nix. If it does, I
will show you instructions on how to clean up your old install.
2. Show you what I am going to install and where. Then I will ask
if you are ready to continue.
3. Create the system users (uids [30001..30032]) and groups (gid 30000)
that the Nix daemon uses to run builds. To create system users
in a different range, exit and run this tool again with
NIX_FIRST_BUILD_UID set.
4. Perform the basic installation of the Nix files daemon.
5. Configure your shell to import special Nix Profile files, so you
can use Nix.
6. Start the Nix daemon.
Would you like to see a more detailed list of what I will do?
No TTY, assuming you would say yes :)
I will:
- make sure your computer doesn't already have Nix files
(if it does, I will tell you how to clean them up.)
- create local users (see the list above for the users I'll make)
- create a local group (nixbld)
- install Nix in /nix
- create a configuration file in /etc/nix
- set up the "default profile" by creating some Nix-related files in
/root
- back up /etc/bashrc to /etc/bashrc.backup-before-nix
- update /etc/bashrc to include some Nix configuration
- back up /etc/zshrc to /etc/zshrc.backup-before-nix
- update /etc/zshrc to include some Nix configuration
- load and start a service (at /etc/systemd/system/nix-daemon.service
and /etc/systemd/system/nix-daemon.socket) for nix-daemon
Ready to continue?
No TTY, assuming you would say yes :)
---- let's talk about sudo -----------------------------------------------------
This script is going to call sudo a lot. Normally, it would show you
exactly what commands it is running and why. However, the script is
run in a headless fashion, like this:
$ curl -L https://nixos.org/nix/install | sh
or maybe in a CI pipeline. Because of that, I'm going to skip the
verbose output in the interest of brevity.
If you would like to
see the output, try like this:
$ curl -L -o install-nix https://nixos.org/nix/install
$ sh ./install-nix
~~> Checking for artifacts of previous installs
Before I try to install, I'll check for signs Nix already is or has
been installed on this system.
---- Nix config report ---------------------------------------------------------
Temp Dir: /tmp/tmp.eibIFRLfWt
Nix Root: /nix
Build Users: 32
Build Group ID: 30000
Build Group Name: nixbld
build users:
Username: UID
nixbld1: 30001
nixbld2: 30002
nixbld3: 30003
nixbld4: 30004
nixbld5: 30005
nixbld6: 30006
nixbld7: 30007
nixbld8: 30008
nixbld9: 30009
nixbld10: 30010
nixbld11: 30011
nixbld12: 30012
nixbld13: 30013
nixbld14: 30014
nixbld15: 30015
nixbld16: 30016
nixbld17: 30017
nixbld18: 30018
nixbld19: 30019
nixbld20: 30020
nixbld21: 30021
nixbld22: 30022
nixbld23: 30023
nixbld24: 30024
nixbld25: 30025
nixbld26: 30026
nixbld27: 30027
nixbld28: 30028
nixbld29: 30029
nixbld30: 30030
nixbld31: 30031
nixbld32: 30032
Ready to continue?
No TTY, assuming you would say yes :)
~~> Setting up the build group nixbld
[sudo] tomoyan のパスワード:
Created: Yes
~~> Setting up the build user nixbld1
useradd warning: nixbld1's uid 30001 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 1
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld2
useradd warning: nixbld2's uid 30002 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 2
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld3
useradd warning: nixbld3's uid 30003 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 3
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld4
useradd warning: nixbld4's uid 30004 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 4
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld5
useradd warning: nixbld5's uid 30005 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 5
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld6
useradd warning: nixbld6's uid 30006 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 6
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld7
useradd warning: nixbld7's uid 30007 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 7
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld8
useradd warning: nixbld8's uid 30008 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 8
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld9
useradd warning: nixbld9's uid 30009 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 9
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld10
useradd warning: nixbld10's uid 30010 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 10
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld11
useradd warning: nixbld11's uid 30011 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 11
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld12
useradd warning: nixbld12's uid 30012 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 12
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld13
useradd warning: nixbld13's uid 30013 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 13
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld14
useradd warning: nixbld14's uid 30014 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 14
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld15
useradd warning: nixbld15's uid 30015 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 15
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld16
useradd warning: nixbld16's uid 30016 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 16
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld17
useradd warning: nixbld17's uid 30017 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 17
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld18
useradd warning: nixbld18's uid 30018 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 18
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld19
useradd warning: nixbld19's uid 30019 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 19
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld20
useradd warning: nixbld20's uid 30020 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 20
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld21
useradd warning: nixbld21's uid 30021 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 21
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld22
useradd warning: nixbld22's uid 30022 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 22
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld23
useradd warning: nixbld23's uid 30023 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 23
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld24
useradd warning: nixbld24's uid 30024 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 24
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld25
useradd warning: nixbld25's uid 30025 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 25
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld26
useradd warning: nixbld26's uid 30026 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 26
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld27
useradd warning: nixbld27's uid 30027 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 27
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld28
useradd warning: nixbld28's uid 30028 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 28
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld29
useradd warning: nixbld29's uid 30029 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 29
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld30
useradd warning: nixbld30's uid 30030 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 30
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld31
useradd warning: nixbld31's uid 30031 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 31
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the build user nixbld32
useradd warning: nixbld32's uid 30032 is greater than SYS_UID_MAX 999
Created: Yes
Hidden: Yes
Home Directory: /var/empty
Note: Nix build user 32
Logins Disabled: Yes
Member of nixbld: Yes
PrimaryGroupID: 30000
~~> Setting up the basic directory structure
install: ディレクトリ '/nix' を作成しています
install: ディレクトリ '/nix/var' を作成しています
install: ディレクトリ '/nix/var/log' を作成しています
install: ディレクトリ '/nix/var/log/nix' を作成しています
install: ディレクトリ '/nix/var/log/nix/drvs' を作成しています
install: ディレクトリ '/nix/var/nix' を作成しています
install: ディレクトリ '/nix/var/nix/db' を作成しています
install: ディレクトリ '/nix/var/nix/gcroots' を作成しています
install: ディレクトリ '/nix/var/nix/profiles' を作成しています
install: ディレクトリ '/nix/var/nix/temproots' を作成しています
install: ディレクトリ '/nix/var/nix/userpool' を作成しています
install: ディレクトリ '/nix/var/nix/daemon-socket' を作成しています
install: ディレクトリ '/nix/var/nix/gcroots/per-user' を作成しています
install: ディレクトリ '/nix/var/nix/profiles/per-user' を作成しています
install: ディレクトリ '/nix/store' を作成しています
install: ディレクトリ '/etc/nix' を作成しています
~~> Installing Nix
Alright! We have our first nix at /nix/store/69hp828rcfmc32bnbxnkkavl7idpp5ns-nix-2.32.4
Just finished getting the nix database ready.
~~> Setting up shell profiles: /etc/bashrc /etc/profile.d/nix.sh /etc/zshrc /etc/bash.bashrc /etc/zsh/zshrc
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /etc/profile
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
# Prevent doublesourcing
if [ -z "$BASHRCSOURCED" ]; then
BASHRCSOURCED="Y"
# are we an interactive shell?
if [ "$PS1" ]; then
if [ -z "$PROMPT_COMMAND" ]; then
declare -a PROMPT_COMMAND
case $TERM in
xterm*)
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
else
PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
fi
;;
screen*)
if [ -e /etc/sysconfig/bash-prompt-screen ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
else
PROMPT_COMMAND='printf "\033k%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
fi
;;
*)
[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
;;
esac
fi
# Turn on parallel history
shopt -s histappend
# Turn on checkwinsize
shopt -s checkwinsize
# Change the default prompt string
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
# You might want to have e.g. tty in prompt (e.g. more virtual machines)
# and console windows
# If you want to do so, just add e.g.
# if [ "$PS1" ]; then
# PS1="[\u@\h:\l \W]\\$ "
# fi
# to your custom modification shell script in /etc/profile.d/ directory
fi
if ! shopt -q login_shell ; then # We're not a login shell
# Need to redefine pathmunge, it gets undefined at the end of /etc/profile
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
# Set default umask for non-login shell only if it is set to 0
[ `umask` -eq 0 ] && umask 022
SHELL=/bin/bash
# Only display echos from profile.d scripts if we are no login shell
# and interactive - otherwise just process them to set envvars
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
if [ "$PS1" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
unset i
unset -f pathmunge
fi
fi
# vim:ts=4:sw=4
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
#
# /etc/zshrc is sourced in interactive shells. It
# should contain commands to set up aliases, functions,
# options, key bindings, etc.
#
## shell functions
#setenv() { export $1=$2 } # csh compatibility
# Set prompts
[[ "$PROMPT" = "%m%# " ]] && PROMPT='[%n@%m]%~%# ' # default prompt
#RPROMPT=' %~' # prompt for right side of screen
# bindkey -v # vi key bindings
# bindkey -e # emacs key bindings
bindkey ' ' magic-space # also do history expansion on space
# Provide pathmunge for /etc/profile.d scripts
pathmunge()
{
if ! echo $PATH | /bin/grep -qE "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
_src_etc_profile_d()
{
# Make the *.sh things happier, and have possible ~/.zshenv options like
# NOMATCH ignored.
emulate -L ksh
# from bashrc, with zsh fixes
if [[ ! -o login ]]; then # We're not a login shell
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
. $i
fi
done
unset i
fi
}
_src_etc_profile_d
unset -f pathmunge _src_etc_profile_d
# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix
~~> Setting up shell profiles for Fish with conf.d/nix.fish inside /etc/fish /usr/local/etc/fish /opt/homebrew/etc/fish /opt/local/etc/fish
~~> Setting up the default profile
installing 'nix-2.32.4'
building '/nix/store/rb229iwnnwdg1frkn8v0jdl9sc1f55gq-user-environment.drv'...
installing 'nss-cacert-3.115'
building '/nix/store/jry58j2n07hnbjz6s0bzxzdkb8kf5ayf-user-environment.drv'...
unpacking 1 channels...
~~> Setting up the nix-daemon systemd service
Created symlink '/etc/systemd/system/nix-daemon.service' → '/nix/var/nix/profiles/default/lib/systemd/system/nix-daemon.service'.
Created symlink '/etc/systemd/system/nix-daemon.socket' → '/nix/var/nix/profiles/default/lib/systemd/system/nix-daemon.socket'.
Created symlink '/etc/systemd/system/sockets.target.wants/nix-daemon.socket' → '/nix/var/nix/profiles/default/lib/systemd/system/nix-daemon.socket'.
Alright! We're done!
Try it! Open a new terminal, and type:
$ nix-shell -p nix-info --run "nix-info -m"
Thank you for using this installer. If you have any feedback or need
help, don't hesitate:
You can open an issue at
https://github.com/NixOS/nix/issues/new?labels=installer&template=installer.md
Or get in touch with the community: https://nixos.org/community
---- Reminders -----------------------------------------------------------------
[ 1 ]
Nix won't work in active shell sessions until you restart them.
マルチユーザー
$ which nix
/nix/var/nix/profiles/default/bin/nix
$ ps aux | grep nix-daemon
root 740755 0.0 0.1 498432 30668 ? Ssl 02:07 0:00 nix-daemon --daemon