News for hackers. Stuff that matters.
Re:NixOS and Stateless Deployment by otterley on Sunday January 04, 2015 @12:28PM (#8835076)
One could argue the same for any package-oriented system, from Red Hat to Solaris to Debian/Ubuntu ("only use packages"). The reality is quite different, and it's always been different. I'm unaware of any environment that's used packages for every aspect of system management, and Nix isn't going to change that.

Moreover, there's nothing stopping a Nix package author from writing a post-install script that causes state changes to be made out of bounds. The package manager isn't going to notice, and it's not going to clean it up at deinstallation time.

Re:NixOS and Stateless Deployment by sparkie on Sunday January 04, 2015 @12:38PM (#8835107)
I think you misunderstand the architecture of Nix. Every package in Nix gets put into an immutable /nix/store. Packages are identified by a hash of their contents, so a small mutation of any package definition gives it a new identity, and thus, a separate package derivation.

Every package in the store has exact dependencies - they reference the hashes of other packages only. When a package is built with Nix, only the directories for these packages are exposed to the chrooted environment in which the build occurs - so it is simply not possible for some randomly added junk in the filesystem to make it's way into a nix-defined package.

Contrast this to building software on another machine, where I might depend on "glibc" version "1.0". The combination these two values hardly represents a unique identity, as I could make any random package that fits those requirements. It's much more difficult for me to create a package which results in an hash collision though.

One thing that makes the other systems so unreliable is the presence of multiple repositories. If you were going to deploy packages from a single repository, then you can do careful planning in such a way that packages do not have any collisions. Assuming no user mutates the directories under control of the package manager, such system will also be effectively reproducible. Current mainstream distros work surprisingly well because they basically use this model, where a default repository provides most users needs. These distros quickly break down when you start adding third-party repositories which bundle alternative compilations of the same software that sits in the "official" one.

Basing packages from hashes (identity), rather than names and numbers, and making sure all of the files for each package is held in an isolated directory ensures that collisions won't happen, even if two different repositories provide the same software name and number, they are represented by different hashes, and will be treated as distinct pieces of software.

Re:NixOS and Stateless Deployment by retr0h on Sunday January 04, 2015 @02:22PM (#8835458)
I like the architecture of Nix, and believe there are many benefits to it's packaging model. However, I am not a huge fan of the syntax[1], and rather use a template engine I am quite familiar with (like jinja).

I'll continue to follow and learn more about Nix, but anxiously awaiting my epiphany.

[1] https://github.com/NixOS/nixpkgs/blob/1a504e3fb72fab10799cf0...

Re:NixOS and Stateless Deployment by cwp on Sunday January 04, 2015 @03:06PM (#8835616)
Yeah, problem with nix is that it's different. The nix language is a lazy-functional DSL, which takes a bit of effort to learn.

The thing is, "better" does imply "different." The syntax is weird and difficult, but it's the linchpin of the whole system. It's much, much better than your typical packaging system and worth the effort to learn it.

Re:NixOS and Stateless Deployment by fineIllregister on Sunday January 04, 2015 @06:34PM (#8836362)
If you like Scheme, GNU Guix is based on Nix but uses a DSL in Guile.

http://www.gnu.org/software/guix/

Re:NixOS and Stateless Deployment by gfxmonk on Monday January 05, 2015 @02:31AM (#8837737)
Do you wish nix's syntax were more like jinja? Or do you actually want to use jinja with nix somehow? I don't really know what the latter would mean, since nix is a programming language and jinja is a (string-based) template system.
Re:NixOS and Stateless Deployment by xorcist on Monday January 05, 2015 @03:16AM (#8837841)
So, what do you do when you have to install a new patch level release of said glibc? Rebuild every single component on the system?

I take it configuration of the packages needs to go in nix as well? So what do you do when there is, for example, a change of upstream smtp?

Re:NixOS and Stateless Deployment by vertex-four on Sunday January 04, 2015 @12:55PM (#8835170)
Nix doesn't have post-install scripts. (NixOS sort-of does, as its global "activation script".) In any case, nothing can force you to do anything - only give you tools to work in the right direction.

Nix gives you tools for dealing with the concept of an immutable system - there's very few other working tools that do the same. Perhaps it can't possibly get all of it right - database setup and schemas, for example - but that's alright, you can use other tools to deal with them! (There's certainly a glut of schema management tools that would fit right into a Nix system.)

Re:NixOS and Stateless Deployment by tel on Sunday January 04, 2015 @01:15PM (#8835244)
I'd be interested to hear of any recommendations for schema management software which works on principles similar to Nix.
Re:NixOS and Stateless Deployment by vertex-four on Sunday January 04, 2015 @02:09PM (#8835418)
In general, you could integrate a tool like Alembic into a NixOS system, by having your NixOS configuration copy your migration files to a persistent directory in the activation script, and running the relevant command to get to a certain revision of your schema specified in your NixOS configuration. That way, you always have all the scripts in a persistent directory to roll back without having to keep them in your git repository until some undefined point in time, and it's tied in reasonably well.

However, NixOS doesn't handle multi-system upgrades very well on its own - for example, you need to have some external way of dealing with "we need to upgrade the schema before restarting the application servers one at a time". I think that's a whole project on its own, and something that almost everything seems to do on an ad-hoc basis (Salt excluded).

Re:NixOS and Stateless Deployment by cwp on Sunday January 04, 2015 @03:02PM (#8835605)
This is just what I do. I don't use Alembic, but I've got a really simple tool that handles migrations. The tool, along with its sequence of migrations is deployed along with the app. The systemd service for Postgres runs the tool after the database is up.

Because the service definition has my migration tool as a dependency, it gets rebuilt when the tool is updated. That causes Postgres to get restarted and the tool to get run IFF there are new migrations. The nix configuration is parameterized, so that in dev or staging environments, the database is completely rebuilt and loaded with test data on each deploy, but in production, we just apply migrations.

With Nixops, this works even on a multi-system deployment. The full deployment typically takes several minutes, but most of that time is in installing the updated packages, which doesn't interrupt the running system. Once everything is installed, the cut-over only takes a second or two. Eventually, I'll have enough traffic to warrant more careful orchestration of the cut-over, but for now it's fine.