Enable shellcheck, address errors
I saw the TODO in `formatter/flake-module.nix` and thought I'd deal with it.
Jeremy Fleischman committed
Oct 30, 2024 at 02:32 UTC
715df4190117d5f923ec988705cb31ca4eafb865
7 files changed
+39
-29
build/scripts/nix-mac-installer.sh
+7
-7
@@ -20,13 +20,13 @@ echo "created nixbld group with gid $gid"
20
for i in $(seq 1 10); do
21
user=/Users/nixbld$i
22
uid="$((30000 + i))"
23
- dscl . -create $user
24
- dscl . -create $user RealName "Nix build user $i"
25
- dscl . -create $user PrimaryGroupID "$gid"
26
- dscl . -create $user UserShell /usr/bin/false
27
- dscl . -create $user NFSHomeDirectory /var/empty
28
- dscl . -create $user UniqueID "$uid"
29
- dseditgroup -o edit -a nixbld$i -t user nixbld
23
+ dscl . -create "$user"
24
+ dscl . -create "$user" RealName "Nix build user $i"
25
+ dscl . -create "$user" PrimaryGroupID "$gid"
26
+ dscl . -create "$user" UserShell /usr/bin/false
27
+ dscl . -create "$user" NFSHomeDirectory /var/empty
28
+ dscl . -create "$user" UniqueID "$uid"
29
+ dseditgroup -o edit -a "nixbld$i" -t user nixbld
30
echo "created nixbld$i user with uid $uid"
31
done
32
build/scripts/nix-mac-nuke.sh
+3
-3
@@ -8,12 +8,12 @@ launchctl unload $service_plist
8
dscl . -delete /Groups/nixbld
9
10
for i in $(seq 1 20); do
11
- dscl . -delete /Users/nixbld$i
11
+ dscl . -delete "/Users/nixbld$i"
12
done
13
14
sudo rm -f $service_plist
15
16
sudo rm -rf /nix /etc/nix/nix.conf
17
18
-rm -f $HOME/.nix-channels $HOME/.nix-profile
19
-rm -rf $HOME/.nix-defexpr
18
+rm -f "$HOME/.nix-channels" "$HOME/.nix-profile"
19
+rm -rf "$HOME/.nix-defexpr"
formatter/flake-module.nix
+1
-2
@@ -15,8 +15,7 @@
15
programs.nixfmt.package = pkgs.nixfmt-rfc-style;
16
programs.ruff-format.enable = true;
17
18
- # TODO: fix shellcheck errors in a follow up pr
19
- #programs.shellcheck.enable = true;
18
+ programs.shellcheck.enable = true;
19
20
programs.shfmt.enable = true;
21
programs.rustfmt.enable = true;
metrics/fastly/cron.sh
+4
-2
@@ -1,4 +1,6 @@
1
-#! /bin/sh -e
1
+#!/usr/bin/env bash
2
+
3
+set -e
4
5
export AWS_PROFILE=nixos-org
6
@@ -19,7 +21,7 @@ if [[ -e $marker ]]; then
21
fi
22
23
mkdir -p "$(dirname "$marker")"
22
-touch $marker
24
+touch "$marker"
25
26
./ingest-raw-logs.sh "$from_date_incl" "$to_date_incl"
27
metrics/fastly/ingest-raw-logs.sh
+7
-5
@@ -1,4 +1,6 @@
1
-#! /bin/sh -e
1
+#!/usr/bin/env bash
2
+
3
+set -e
4
5
region=eu-west-1
6
@@ -14,7 +16,7 @@ run_query() {
16
17
res=$(aws athena start-query-execution \
18
--region $region \
17
- --result-configuration OutputLocation=s3://nixos-athena/ingestion/$name/ \
19
+ --result-configuration "OutputLocation=s3://nixos-athena/ingestion/$name/" \
20
--query-string "$query")
21
22
execution_id="$(printf "%s" "$res" | jq -r -e .QueryExecutionId)"
@@ -24,14 +26,14 @@ run_query() {
26
27
printf "Waiting..."
28
while true; do
27
- res="$(aws athena get-query-execution --region $region --query-execution-id $execution_id)"
29
+ res="$(aws athena get-query-execution --region $region --query-execution-id "$execution_id")"
30
status="$(printf %s "$res" | jq -r -e .QueryExecution.Status.State)"
29
- if [[ $status = RUNNING || $status = QUEUED ]]; then
31
+ if [[ $status == RUNNING || $status == QUEUED ]]; then
32
printf "."
33
sleep 1
34
continue
35
fi
34
- if [[ $status = SUCCEEDED ]]; then
36
+ if [[ $status == SUCCEEDED ]]; then
37
printf " done.\n"
38
break
39
fi
metrics/fastly/run-queries.sh
+6
-4
@@ -1,4 +1,6 @@
1
-#! /bin/sh -e
1
+#!/usr/bin/env bash
2
+
3
+set -e
4
5
region=eu-west-1
6
@@ -10,7 +12,7 @@ run_query() {
12
13
res=$(aws athena start-query-execution \
14
--region $region \
13
- --result-configuration OutputLocation=s3://nixos-metrics/$report_date/$name/ \
15
+ --result-configuration "OutputLocation=s3://nixos-metrics/$report_date/$name/" \
16
--query-string "$query")
17
18
execution_id="$(printf "%s" "$res" | jq -r -e .QueryExecutionId)"
@@ -21,8 +23,8 @@ run_query() {
23
redirect=latest/$name.csv
24
aws s3api put-object \
25
--bucket nixos-metrics \
24
- --key $redirect \
25
- --website-redirect-location /$report_date/$name/$execution_id.csv >/dev/null
26
+ --key "$redirect" \
27
+ --website-redirect-location "/$report_date/$name/$execution_id.csv" >/dev/null
28
29
echo "Created redirect http://nixos-metrics.s3-website-eu-west-1.amazonaws.com/$redirect."
30
}
modules/prometheus/system-version-exporter.sh
+11
-6
@@ -1,11 +1,16 @@
1
-#!/bin/sh
1
+#!/usr/bin/env bash
2
3
set -euo pipefail
4
5
-readonly VERSION="$(cat /run/current-system/nixos-version)"
6
-readonly CURRENT_SYSTEM_DRV="$(readlink /run/current-system)"
7
-readonly CURRENT_SYSTEM_PROFILE="$(find /nix/var/nix/profiles -ilname "${CURRENT_SYSTEM_DRV}")"
8
-readonly DEPLOY_TIMESTAMP="$(stat -c '%y' "${CURRENT_SYSTEM_PROFILE}" | cut -c '-16')"
9
-readonly DEPLOY_SECONDS="$(stat -c '%Y' "${CURRENT_SYSTEM_PROFILE}")"
5
+readonly VERSION
6
+VERSION="$(cat /run/current-system/nixos-version)"
7
+readonly CURRENT_SYSTEM_DRV
8
+CURRENT_SYSTEM_DRV="$(readlink /run/current-system)"
9
+readonly CURRENT_SYSTEM_PROFILE
10
+CURRENT_SYSTEM_PROFILE="$(find /nix/var/nix/profiles -ilname "${CURRENT_SYSTEM_DRV}")"
11
+readonly DEPLOY_TIMESTAMP
12
+DEPLOY_TIMESTAMP="$(stat -c '%y' "${CURRENT_SYSTEM_PROFILE}" | cut -c '-16')"
13
+readonly DEPLOY_SECONDS
14
+DEPLOY_SECONDS="$(stat -c '%Y' "${CURRENT_SYSTEM_PROFILE}")"
15
16
echo "node_deployed{version=\"${VERSION}\",date=\"${DEPLOY_TIMESTAMP}\"} ${DEPLOY_SECONDS}"