Skip to content

Commit 2d80948

Browse files
authored
nixos/containers: Fix shellcheck issues (#346131)
2 parents 58d6ee3 + cc28f2b commit 2d80948

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

nixos/modules/virtualisation/nixos-containers.nix

+13-9
Original file line numberDiff line numberDiff line change
@@ -109,44 +109,46 @@ let
109109
110110
cp --remove-destination /etc/resolv.conf "$root/etc/resolv.conf"
111111
112+
declare -a extraFlags
113+
112114
if [ "$PRIVATE_NETWORK" = 1 ]; then
113-
extraFlags+=" --private-network"
115+
extraFlags+=("--private-network")
114116
fi
115117
116118
if [ -n "$HOST_ADDRESS" ] || [ -n "$LOCAL_ADDRESS" ] ||
117119
[ -n "$HOST_ADDRESS6" ] || [ -n "$LOCAL_ADDRESS6" ]; then
118-
extraFlags+=" --network-veth"
120+
extraFlags+=("--network-veth")
119121
fi
120122
121123
if [ -n "$HOST_PORT" ]; then
122124
OIFS=$IFS
123125
IFS=","
124126
for i in $HOST_PORT
125127
do
126-
extraFlags+=" --port=$i"
128+
extraFlags+=("--port=$i")
127129
done
128130
IFS=$OIFS
129131
fi
130132
131133
if [ -n "$HOST_BRIDGE" ]; then
132-
extraFlags+=" --network-bridge=$HOST_BRIDGE"
134+
extraFlags+=("--network-bridge=$HOST_BRIDGE")
133135
fi
134136
135-
extraFlags+=" ${concatStringsSep " " (mapAttrsToList nspawnExtraVethArgs cfg.extraVeths)}"
137+
extraFlags+=(${lib.escapeShellArgs (mapAttrsToList nspawnExtraVethArgs cfg.extraVeths)})
136138
137139
for iface in $INTERFACES; do
138-
extraFlags+=" --network-interface=$iface"
140+
extraFlags+=("--network-interface=$iface")
139141
done
140142
141143
for iface in $MACVLANS; do
142-
extraFlags+=" --network-macvlan=$iface"
144+
extraFlags+=("--network-macvlan=$iface")
143145
done
144146
145147
# If the host is 64-bit and the container is 32-bit, add a
146148
# --personality flag.
147149
${optionalString (pkgs.stdenv.hostPlatform.system == "x86_64-linux") ''
148150
if [ "$(< "''${SYSTEM_PATH:-/nix/var/nix/profiles/per-container/$INSTANCE/system}/system")" = i686-linux ]; then
149-
extraFlags+=" --personality=x86"
151+
extraFlags+=("--personality=x86")
150152
fi
151153
''}
152154
@@ -157,9 +159,11 @@ let
157159
# Kill signal handling means systemd-nspawn will pass a system-halt signal
158160
# to the container systemd when it receives SIGTERM for container shutdown;
159161
# containerInit and stage2 have to handle this as well.
162+
# TODO: fix shellcheck issue properly
163+
# shellcheck disable=SC2086
160164
exec ${config.systemd.package}/bin/systemd-nspawn \
161165
--keep-unit \
162-
-M "$INSTANCE" -D "$root" $extraFlags \
166+
-M "$INSTANCE" -D "$root" "''${extraFlags[@]}" \
163167
$EXTRA_NSPAWN_FLAGS \
164168
--notify-ready=yes \
165169
--kill-signal=SIGRTMIN+3 \

0 commit comments

Comments
 (0)