Skip to content

Commit 4ce51b3

Browse files
committed
feat: take into effect system-features
1 parent af70cbe commit 4ce51b3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/nixos-anywhere.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,26 @@ echo "extra-trusted-public-keys = ${trustedPublicKeys}" >> ~/.config/nix/nix.con
944944
SSH
945945
fi
946946
947+
# Get system-features with a specific cpu architecture from the machine and add them to the installer
948+
if [[ -n ${flake} ]]; then
949+
system_features=$(nix --extra-experimental-features 'nix-command flakes' eval --apply toString "${flake}"#"${flakeAttr}".nix.settings.system-features)
950+
if [[ -z ${system_features} ]]; then
951+
system_features=$(nix config show system-features)
952+
fi
953+
platform_arch=$(nix --extra-experimental-features 'nix-command flakes' eval --apply toString "${flake}"#"${flakeAttr}".nixpkgs.hostPlatform.gcc.arch)
954+
if [[ -n ${platform_arch} ]]; then
955+
system_features="${system_features} gccarch-${platform_arch}"
956+
fi
957+
958+
# deduplicate the features
959+
system_features=$(echo "${system_features}" | tr ' ' '\n' | sort -u | tr '\n' ' ' | sed 's/ $//')
960+
961+
runSsh sh <<SSH || true
962+
mkdir -p ~/.config/nix
963+
echo "system-features = ${system_features}" >> ~/.config/nix/nix.conf
964+
SSH
965+
fi
966+
947967
if [[ ${phases[disko]} == 1 ]]; then
948968
runDisko "$diskoScript"
949969
fi

0 commit comments

Comments
 (0)