We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 74b8e31 + 90a2c43 commit d002ce9Copy full SHA for d002ce9
nixos-generate
@@ -58,6 +58,19 @@ abort() {
58
exit 1
59
}
60
61
+# TODO: Is there a better name for this?
62
+fixDiskSizeFormat() {
63
+ # If the arg is an int, pass it back unchanged:
64
+ if [[ "$1" =~ ^[0-9][0-9]*$ ]]; then
65
+ echo "$1"
66
+ return
67
+ fi
68
+
69
+ # If the arg is _not_ an int, we'll assume it's a string.
70
+ # Therefore, we'll make sure it's wrapped in quotes, so its eval'd as a string by Nix:
71
+ echo "\"$1\""
72
+}
73
74
## Main ##
75
76
while [[ $# -gt 0 ]]; do
@@ -81,7 +94,8 @@ while [[ $# -gt 0 ]]; do
81
94
shift
82
95
;;
83
96
--disk-size)
84
- nix_build_args+=("--argstr" "diskSize" "$2")
97
+ # Note: make sure integers are not incorrectly interpreted as strings by Nix:
98
+ nix_build_args+=("--arg" "diskSize" "$(fixDiskSizeFormat "$2")")
85
99
86
100
87
101
--special-arg)
0 commit comments