virtualization/amazon-init: fix logging, nix path
The missing `\n` in the printf format string prevented multiple channels from being logged. The missing `nixpkgs=` in the `NIX_PATH` prevented `nixos-rebuild` from working if the system configuration has any reference to `nixpkgs`. Additionally: * Use process substitution instead of piping printf to avoid creating a subshell. * Set an empty `IFS` to avoid word splitting. * Add the `-r` flag to `read` to avoid mangling backslashes.
This commit is contained in:
parent
24a323b767
commit
76ad649dd8
1 changed files with 3 additions and 3 deletions
|
@ -8,7 +8,7 @@ let
|
|||
|
||||
export HOME=/root
|
||||
export PATH=${pkgs.lib.makeBinPath [ config.nix.package pkgs.systemd pkgs.gnugrep pkgs.gnused config.system.build.nixos-rebuild]}:$PATH
|
||||
export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
|
||||
export NIX_PATH=nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
|
||||
|
||||
userData=/etc/ec2-metadata/user-data
|
||||
|
||||
|
@ -18,9 +18,9 @@ let
|
|||
# that as the channel.
|
||||
if sed '/^\(#\|SSH_HOST_.*\)/d' < "$userData" | grep -q '\S'; then
|
||||
channels="$(grep '^###' "$userData" | sed 's|###\s*||')"
|
||||
printf "%s" "$channels" | while read channel; do
|
||||
while IFS= read -r channel; do
|
||||
echo "writing channel: $channel"
|
||||
done
|
||||
done < <(printf "%s\n" "$channels")
|
||||
|
||||
if [[ -n "$channels" ]]; then
|
||||
printf "%s" "$channels" > /root/.nix-channels
|
||||
|
|
Loading…
Reference in a new issue