Update (2020-09-03): /u/zimbatm on lobste.rs suggested the nixos-generators project. Added link and brief discussion.
Update (2020-11-29): Added notes on the impact of instance limits on Packer builds.
The NixOS project publishes Amazon Machine Images (AMIs) that are a great base for reproducible servers. This post describes how NixOS and EC2 work together, first showing how to build upon the NixOS project’s public AMIs; and then digging all the way into the scripts maintainers use to build, import and distribute new AMIs on AWS.
There are few good ways to get AMI IDs for NixOS project images:
The NixOS project publishes its images with
owner-id=080433136561
; you can use this with an
aws ec2 describe-images
call. jq
is a good way
to select the interesting parts of the response, and is the easiest way
to find an AArch64 (which AWS calls arm64
) AMI:
# Return the most recent AArch64 NixOS image in the region
$ aws ec2 describe-images \
--region ap-southeast-2 \
--filters Name=owner-id,Values=080433136561 \
| jq '.Images | map(select(.Architecture == "arm64")) | sort_by(.CreationDate) | reverse | map({ ImageId, Description }) | .[0]'
{
"ImageId": "ami-05446a2f818cd3263",
"Description": "NixOS 20.03.2351.f8248ab6d9e aarch64-linux"
}
The NixOS download
page lists AMI IDs for the most recent stable release, which I think
are all x86_64
images. Scroll down to the “Getting NixOS”
section and click the “Amazon EC2” tab to find a list of AMIs, one for
each region. The launch buttons take you straight to the launch wizard
in the EC2 Management Console.
There is a list of AMIs going back to NixOS 14.04 in <nixpkgs/nixos/modules/virtualisation/ec2-amis.nix>.
You can retrieve a specific AMI ID with a nix
command
like:
$ nix eval --raw '(import <nixpkgs/nixos/modules/virtualisation/ec2-amis.nix>)."20.03".ap-southeast-2.hvm-ebs'
ami-04c0f3a75f63daddd
Roughly six months ago, the COVID-19 pandemic reached Australia, and began upending things down under (mid-March was when major events like the F1 Grand Prix were first cancelled). Do you consider yourself well-informed? How well do you remember everything that’s happened? Do you remember the rise and fall of hydroxychloroquine as a potential “miracle cure”? If pressed, could you back up the things you think you remember, even where the media has retreated from things they once said, quietly edited or retracted their stories, and deleted all their embarrassing tweets?
Most people reading this are already rightfully suspicious of the Murdoch press, but unfortunately the “respectable” sources are also terrible. Even from them, you must expect bad behaviour at all times: institutional bias, misleading wording, and cherry-picking. Don’t even expect real cherries, but you might find some if you’re lucky. Constant vigilance is necessary if you hope to engage with the media and come away with any truth at all.
I will use the tale of hydroxychloroquine as an example, because it’s recent and I have the links, but there’s no reason to expect anything different with any other issue, Hopefully you’ll understand the level of attention required to accurately track even one issue. When each new issue comes along, will need to decide whether it’s worth your time to follow it properly, or to let it pass. Anything less means you will be acting on bad information, which is worse than useless.
Read more...Justin Le recently put out a two-part series on “Enhancing Functor
Structures Step-By-Step” (Part
1, Part
2). In the footnotes of Part 2, he mentions there’s no combined Applicative
/Divisible
class:
class DivisibleApplicative f where
conquerpure :: a -> f a
divideAp :: (a -> (b, c)) -> (b -> c -> a) -> f b -> f c -> f a
Let’s see if we can build one.
Read more...