Skip to content

Commit

Permalink
use login keychain for single-user install
Browse files Browse the repository at this point in the history
  • Loading branch information
abathur committed Oct 23, 2020
1 parent 82cc15c commit 1668c39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions scripts/create-darwin-volume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,15 @@ main() {
# and be prompted for a pw to add; two step workaround:
# 1. add a blank pw to a keychain
# - system if daemon
sudo /usr/bin/security add-generic-password -a "Nix Volume" -s "Nix Volume" -D "Nix Volume password" "/Library/Keychains/System.keychain"
# - login if single-user
# TODO: pass something in to discriminate this case?
# sudo /usr/bin/security add-generic-password -a "Nix Volume" -s "Nix Volume" -D "Nix Volume password"
if [ "$INSTALL_MODE" = "daemon" ]; then # exported by caller
# system is technically less secure than user... in theory we
# could install the password in each user keychain, but we'd
# need some ergonomic way to add users after install...
sudo /usr/bin/security add-generic-password -a "Nix Volume" -s "Nix Volume" -D "Nix Volume password" "/Library/Keychains/System.keychain"
# - login (default) if single-user
else
sudo /usr/bin/security add-generic-password -a "Nix Volume" -s "Nix Volume" -D "Nix Volume password"
fi
# 2. add a password with the -U (update) flag and -w (prompt if last)
# flags, but specify no keychain; security will use the first it finds
prepare_darwin_volume_password | sudo diskutil apfs addVolume "$disk" APFS 'Nix Volume' -mountpoint /nix -stdinpassphrase
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-nix-from-closure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ elif [ "$(uname -s)" = "Linux" ]; then
echo "Note: a multi-user installation is possible. See https://nixos.org/nix/manual/#sect-multi-user-installation" >&2
fi

INSTALL_MODE=no-daemon
export INSTALL_MODE=no-daemon
CREATE_DARWIN_VOLUME=${CREATE_DARWIN_VOLUME:-1} # now default
# handle the command line flags
while [ $# -gt 0 ]; do
Expand Down

0 comments on commit 1668c39

Please sign in to comment.