News for hackers. Stuff that matters.
Re:ContainerSSH: Launch containers on demand by toastal on Saturday September 10, 2022 @06:05AM (#32789255)
I would rather have a Nix devShell.
Re:ContainerSSH: Launch containers on demand by evol262 on Saturday September 10, 2022 @07:37AM (#32789714)
I would, too, but the barrier to entry is much higher.

This has been discussed ad-nauseum, but "getting started" with nix (or home-manager, or devshell) is an experience worse than trying to do anything with Linux in 2005.

Cobbling together a bunch of blogposts and docs which kind of, sort of, might let you piece together a config which works after enough iterations and unreadable backtraces is far more difficult than it needs to be, and that's before you get into cases like "I want Python linters in my environment, so I need Python, but I also need access to some modules from Python on the system, which aren't installable (let's say `python-apt`, which cannot be installed from pypi), and..."

For probably the 500th time someone has said it on HN this week, nix will never be really usable or gain wider adoption until someone puts together solid documentation, or even a solid "getting started -- intermediate" guide which can bridge between "let me set up a trivial env" and "I'm running nixos and it's nix all the way down"

Re:ContainerSSH: Launch containers on demand by viraptor on Saturday September 10, 2022 @06:15AM (#32789292)
Is there a good solution for devshell with associated services? The app itself is fine that way, but what about the database, message queue, seed data, etc.?
Re:ContainerSSH: Launch containers on demand by _hl_ on Saturday September 10, 2022 @06:49AM (#32789455)
I usually write a script that idempotently spins these things up locally, and use the shellHook to call that script. That way whenever I cd into the dir the first time, direnv loads the nix-shell, which starts the db, message broker, etc. I also have a shutdown script that I run when I manually want to shut things down. Works quite well.

For more advanced use cases, such as k8s with tons of services, you're better off using something like tilt.dev.

Re:ContainerSSH: Launch containers on demand by thenonameguy on Saturday September 10, 2022 @08:21AM (#32789986)
I've been using https://github.com/F1bonacc1/process-compose with great success.

It's a userspace process orchestrator/scheduler that works across all relevant platforms, supporting daemon processes and k8s style readiness/health checks.

In combination with nix flakes, it quickly reduced my projects docker-compose usage for easy-to-configure services.

This gave huge performance benefits for the M1 Mac folks on my team especially for CPU intensive processes thanks to native binaries.

For maximal ease of use, the remaining docker-compose containers are started/stopped as a process-compose task. Quite meta :)

Re:ContainerSSH: Launch containers on demand by qbasic_forever on Saturday September 10, 2022 @07:36AM (#32789708)
You can install any services in your nix dev shell environment. Run them however you desire--a bash script that backgrounds their tasks, systemd user services, supervisord, or any other process manager.

edit: A really simple and effective process manager is foreman and its procfile format. I like the golang version of it (simple single binary with zero dependencies): https://github.com/ddollar/forego or https://github.com/mattn/goreman

Re:ContainerSSH: Launch containers on demand by viraptor on Saturday September 10, 2022 @10:11AM (#32790806)
So I'm aware you can script anything you want. I meant a more integrated version. Now I'm tempted to write one myself where you provide the (for example) mysql you want to run and it automatically inserts the right scripts...