News for hackers. Stuff that matters.
Re:A Nix terminology primer by a newcomer by julianeon on Tuesday June 02, 2020 @04:37PM (#23396008)
I guess the ideal, for me, would be to have a service where I could upload a Nix file, and then have it generate a server from that. Darklang may be working with the general idea, but I'd like to see it for Nix too.
Re:A Nix terminology primer by a newcomer by takeda on Tuesday June 02, 2020 @09:55PM (#23398853)
People mentioned NixOps (I personally think it is weaker part of Nix, but it is still good for specific use cases)

There's also another option, nixpkgs actually has a functionality to generate ec2 image, basd on your configuration.nix[1]

You can also generate other images[2]

[1] https://github.com/NixOS/nixpkgs/blob/master/nixos/maintaine...

[2] https://github.com/nix-community/nixos-generators

edit: I believe you can use [2] even for AWS images, the raw and qcow2 should work on EC2 as well, the [1] is including some additional settings that make NixOS work better there, although there's nothing stopping you from adding these to your own configuration.nix

Also, this is not really a fault of Nix, but in EC2 if you import image it has to go through their conversion mechansim, which takes about 10 minutes :( A kind of workaround around it is to have another instance with attached extra EBS drive, use dd to write raw image on that disk. Then disconnect the EBS, create a snapshot of it and convert the snapshot to an AMI.

Re:A Nix terminology primer by a newcomer by 1000101 on Wednesday June 03, 2020 @04:58AM (#23401427)
Morph is another great alternative to NixOps (well, it's not a replacement per se, but it's easier to use and lightweight in comparison to NixOps). It's basically just a really nice wrapper that allows you to easily deploy smaller herds of servers (~100 and less). I wholeheartedly recommend trying it out https://github.com/DBCDK/morph
Re:A Nix terminology primer by a newcomer by elbear on Wednesday June 03, 2020 @04:44AM (#23401352)
I tried to use nixos-generators recently and the experience wa frustrating. For example, I tried to generate an image in the `do` format (DigitalOcean) and a few other formats. Every time, the script (`nixos-generate`) finished running and didn't produce any output.
Re:A Nix terminology primer by a newcomer by takeda on Wednesday June 03, 2020 @02:36PM (#23407017)
Hmm frankly I did not use nixos-generator before writing this post, and only generated EC2 images.

But I just tried, and it did work for me. The generated image was provided as the last line of the output.

It looked like this:

    Making image hybrid...
    /nix/store/ra02s6nmhfklmsrmhkd960xdqpwghgak-nixos.iso/iso/nixos.iso
What OS you run it on? I run this on NixOS 20.03 on VirtualBox, I needed to have "Enable Nested VT-x/AMD-V" since the process spins a qemu to finalize the image.
Re:A Nix terminology primer by a newcomer by elbear on Thursday June 04, 2020 @09:39AM (#23416390)
When I didn't get any output, I ran it in Ubuntu 18 on a Linode VPS. But I tried to generate different formats: do, qcow, vmware.
Re:A Nix terminology primer by a newcomer by takeda on Thursday June 04, 2020 @07:04PM (#23423021)
Strange that there was no output or even errors.

BTW: I believe NixOS image generation can be run only on NixOS machine, because it needs to run a VM and that requires some kernel modules to be loaded. At least I never was able to made it work on OS X.

The nixos-infect code though will turn your Ubuntu installation into NixOS, so you might try to boot to your Ubuntu machine, convert it to NixOS and I'm hoping then nixos-generate might start working.

Note though that "do" didn't work either for me, and I didn't look to investigate why, I figured out that maybe it was because I was running it on machine on VirtualBox and not DO.

Re:A Nix terminology primer by a newcomer by 1000101 on Wednesday June 03, 2020 @05:38AM (#23401620)
Have you tried https://github.com/elitak/nixos-infect ? Works like a charm (with DO). It's a oneliner, you don't need to fiddle with anything. If it won't work from the user config option, just paste it in the live VPS and it will rebuild itself.
Re:A Nix terminology primer by a newcomer by elbear on Wednesday June 03, 2020 @05:44AM (#23401651)
I haven't. I was trying to use nixos-generators, because at some point I want to generate a custom, stripped down image of NixOS. But until then, I might use nixos-infect, if it gets me a running instance of DO quicker.
Re:A Nix terminology primer by a newcomer by 1000101 on Wednesday June 03, 2020 @05:57AM (#23401713)
It's super easy and works every time. You might want to change NIX_CHANNEL=nixos-19.09 to NIX_CHANNEL=nixos-20.03 since 19.09 is the previous stable version. I use nixos-infect along with Morph so I don't care about the custom images that much - a fresh/bare NixOS is all I need to build, push and deploy the actual configuration through Morph.
Re:A Nix terminology primer by a newcomer by elbear on Wednesday June 03, 2020 @07:34AM (#23402234)
Didn't know about Morph. Thanks!
Re:A Nix terminology primer by a newcomer by ris on Tuesday June 02, 2020 @04:40PM (#23396037)
You're describing something a little like NixOps, which is something like a cross between nix and terraform.
Re:A Nix terminology primer by a newcomer by chpatrick on Tuesday June 02, 2020 @04:52PM (#23396166)
Yep, that's nixops, although it's a command-line application.
Re:A Nix terminology primer by a newcomer by whateveracct on Tuesday June 02, 2020 @06:48PM (#23397415)
NixOps + the kind of money mainstream projects get would be really nice. Sadly NixOps is a lil rough around the edges. I like using it for my projects already though. I manually provision on DO instead of letting the tool do that.
Re:A Nix terminology primer by a newcomer by takeda on Tuesday June 02, 2020 @09:57PM (#23398877)
Agree, they approached this by creating a common interface to provision VMs. The good part is that you can deploy the image to different cloud providers with minimum changes. The bad think is that it is utilizing the common components among all providers, that means you essentially can just deploy VM and that's it. No autoscaling etc.