Skip to content

Commit 3792cc3

Browse files
committed
feat(build): add logging flag
1 parent 48fa924 commit 3792cc3

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

build.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,21 @@ while [[ $# -gt 0 ]]; do
4343
--builder)
4444
nixBuildArgs+=("--build-host")
4545
nixBuildArgs+=("$2")
46-
shift
47-
shift
46+
shift 2
4847
;;
4948
--build-args)
5049
shift
5150
globalBuildArgs=("$@")
5251
break
5352
;;
5453
--first-install)
55-
shift
5654
isFirstInstall=1
55+
shift
56+
;;
57+
--logs)
58+
export ICEDOS_LOGGING=1
59+
trace="--show-trace"
60+
shift
5761
;;
5862
-*|--*)
5963
echo "Unknown arg: $1" >&2
@@ -86,11 +90,11 @@ export ICEDOS_FLAKE_INPUTS=$(mktemp)
8690

8791
[ "$update_repos" == "1" ] && refresh="--refresh"
8892

89-
ICEDOS_UPDATE="$update_repos" ICEDOS_STAGE="genflake" nix eval $refresh --show-trace --file "./lib/genflake.nix" flakeInputs | nixfmt | sed "1,1d" | sed "\$d" >$ICEDOS_FLAKE_INPUTS
93+
ICEDOS_UPDATE="$update_repos" ICEDOS_STAGE="genflake" nix eval $refresh $trace --file "./lib/genflake.nix" flakeInputs | nixfmt | sed "1,1d" | sed "\$d" >$ICEDOS_FLAKE_INPUTS
9094
(printf "{ inputs = {" ; cat $ICEDOS_FLAKE_INPUTS ; printf "}; outputs = { ... }: {}; }") >$FLAKE
9195
nix flake prefetch-inputs
9296

93-
ICEDOS_STAGE="genflake" nix eval --show-trace --file "./lib/genflake.nix" --raw flakeFinal >$FLAKE
97+
ICEDOS_STAGE="genflake" nix eval $trace --file "./lib/genflake.nix" --raw flakeFinal >$FLAKE
9498
nixfmt "$FLAKE"
9599

96100
rm $ICEDOS_FLAKE_INPUTS
@@ -119,8 +123,8 @@ echo "Building from path $TMP_BUILD_FOLDER"
119123

120124
# Build the system configuration
121125
if (( ${#nixBuildArgs[@]} != 0 )) || [[ "$isFirstInstall" == 1 ]]; then
122-
sudo nixos-rebuild $action --flake .#"$(cat /etc/hostname)" ${nixBuildArgs[*]} ${globalBuildArgs[*]}
126+
sudo nixos-rebuild $action --flake .#"$(cat /etc/hostname)" $trace ${nixBuildArgs[*]} ${globalBuildArgs[*]}
123127
exit 0
124128
fi
125129

126-
nh os $action "$TMP_BUILD_FOLDER" ${nhBuildArgs[*]} -- ${globalBuildArgs[*]}
130+
nh os $action "$TMP_BUILD_FOLDER" ${nhBuildArgs[*]} -- $trace ${globalBuildArgs[*]}

lib/constants.nix

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
_: {
1+
_:
2+
let
3+
inherit (builtins) getEnv;
4+
in
5+
{
26
INPUTS_PREFIX = "icedos";
3-
ENABLE_LOGGING = false;
7+
ENABLE_LOGGING = if ((getEnv "ICEDOS_LOGGING") == "1") then true else false;
48

59
ICEDOS_STAGE =
610
let
7-
stage = builtins.getEnv "ICEDOS_STAGE";
11+
stage = getEnv "ICEDOS_STAGE";
812
in
913
if stage != "" then stage else "nixos_build";
1014
}

0 commit comments

Comments
 (0)