Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer known and 64 bit cpus #160

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion nixops_aws/nix/ec2.nix
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,23 @@ in
checked =
throwIf (config.deployment.ec2.physicalProperties.platforms or [] == [])
"Please set a supported deployment.ec2.instanceType, or set nixpkgs.hostPlatform.";
plat = lib.head config.deployment.ec2.physicalProperties.platforms;

# inverse value of cpu; lower number is better
# number is not exposed
unrankedRank = 1000;
ranking = {
"x86_64" = 0;
"i686" = 1;
"aarch64" = 0; # prefer over older arm (which is currently not listed)
};

# sorts better cpu first. If cpus are equal the first will be picked (sort is stable).
plat = lib.head (lib.sort byRanking config.deployment.ec2.physicalProperties.platforms);

byRanking = a: b:
ranking.${a.cpu} or unrankedRank
< ranking.${b.cpu} or unrankedRank;

systemString =
lib.throwIf (plat.os or "linux" != "linux")
"Instance does not seem to be intended for running Linux. Please set nixpkgs.hostPlatform manually."
Expand Down