8 ms·
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 wit
by julianeon 6y ago
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.
- ris 6y agoYou're describing something a little like NixOps, which is something like a cross between nix and terraform.
- chpatrick 6y agoYep, that's nixops, although it's a command-line application.
- whateveracct 6y agoNixOps + 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.
- takeda 6y agoAgree, 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.
- takeda 6y agoPeople 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/maintainers/scripts/ec2/amazon-image.nix https://github.com/NixOS/nixpkgs/blob/master/nixos/maintaine... [2] https://github.com/nix-community/nixos-generators 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.
- elbear 6y agoI 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.
- 1000101 6y agoHave you tried https://github.com/elitak/nixos-infect 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.
- elbear 6y agoI 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.
- 1000101 6y agoIt'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.
- elbear 6y agoDidn't know about Morph. Thanks!
- takeda 6y agoHmm 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.