Skip to content

Commit 25d3307

Browse files
committed
feat: take into effect system-features
1 parent af70cbe commit 25d3307

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/nixos-anywhere.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,27 @@ 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+
954+
platform_arch=$(nix --extra-experimental-features 'nix-command flakes' eval --apply 'x: toString (x.nixpkgs.hostPlatform.gcc.arch or "")' "${flake}#${flakeAttr}")
955+
if [[ -n ${platform_arch} ]]; then
956+
system_features="${system_features} gccarch-${platform_arch}"
957+
fi
958+
959+
# deduplicate the features
960+
system_features=$(echo "${system_features}" | tr ' ' '\n' | sort -u | tr '\n' ' ' | sed 's/ $//')
961+
962+
runSsh sh <<SSH || true
963+
mkdir -p ~/.config/nix
964+
echo "system-features = ${system_features}" >> ~/.config/nix/nix.conf
965+
SSH
966+
fi
967+
947968
if [[ ${phases[disko]} == 1 ]]; then
948969
runDisko "$diskoScript"
949970
fi

0 commit comments

Comments
 (0)