diff options
author | Christian Höppner <christian.hoppner@serokell.io> | 2019-12-27 19:32:12 +0000 |
---|---|---|
committer | Christian Höppner <christian.hoppner@serokell.io> | 2019-12-28 16:58:46 +0000 |
commit | 76ad649dd823d38c65c489869e763dd1869c090c (patch) | |
tree | bd11cb17744eaf17e9bf1bfa45ecebce8d067d52 /nixos/modules/virtualisation | |
parent | 24a323b767e923507950ae7e856f5235db75f65b (diff) |
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.
Diffstat (limited to 'nixos/modules/virtualisation')
-rw-r--r-- | nixos/modules/virtualisation/amazon-init.nix | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/nixos/modules/virtualisation/amazon-init.nix b/nixos/modules/virtualisation/amazon-init.nix index 8032b2c6d7ca4..826c78a6e7ffc 100644 --- a/nixos/modules/virtualisation/amazon-init.nix +++ b/nixos/modules/virtualisation/amazon-init.nix @@ -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 |