5 ms·
I've occasionally encountered projects using Nix, and I've casually browsed the Nix and NixOS websites, but I still don't have a clear idea of what Nix is. Is
by p-e-w 3y ago
I've occasionally encountered projects using Nix, and I've casually browsed the Nix and NixOS websites, but I still don't have a clear idea of what Nix is.
Is it a package manager? A build system? An operating system? A container platform? A sandbox? An automation tool?
Which widely used, existing software tools is it analogous to?
- seqizz 3y agoAfaiu it's trying to become all. Nix is on core, you can get packages from nixpkgs / write your own definitions, use it on OS configurations via NixOS, use its built-in helpers to run your containers with it, make a whole CI and cache it with the help of Hydra etc.
- politelemon 3y agoThat's confusing because NixOS also seems to be an operating system, looking at the blog post?
- chpatrick 3y agoNixOS is just a super barebones distro where everything is configured with Nix. You can also use Nix on Ubuntu or some other distro.
- SuperSandro2000 3y agoBare bones as in by default you don't get much unless you turn it on
- chpatrick 3y agoRight, it's just bash, Nix and systemd by default.
- hamandcheese 3y agoMost of the above. - Nix is a tool for building and installing software. - Nix is a language for expressing how to build a package. Nix-the-tool reads expressions defined in Nix-the-language to know what to do. At the end of the day, this translates into normal commands that run in a sandboxed build environment. - Nixpkgs is a monolithic repository of 80000+ packages, defined literally as one giant expression in the Nix language (this works fine because Nix is an extremely lazy language). This also includes lots of helpers and abstractions for building packages that can be handy in your own projects. It is possible to use Nix-the-tool without Nixpkgs, but nobody does. - NixOS is a Linux distribution built on these foundations. Everything under /etc is built from nix expressions. You can not directly edit these. Mostly NixOS is about building systemd unit files from Nix expressions - viewed through that lens it's not really all that exotic of an OS. NixOS has modules that make it very easy to configure and run lots of software.
- deleted 3y ago[deleted]
- prox 3y agoSo does this allow for different boot setups for NixOS? Say “webserver” or “office management” , “media streamer” profiles?
- SAI_Peregrinus 3y agoYes. E.g. some guy's config with 6 different machines[1]: multiple desktops, laptops, servers, a Raspberry Pi, and a VPS. That's a rather advanced use of Nix for configuration, but definitely shows what it's capable of. [1] https://github.com/Misterio77/nix-config https://github.com/Misterio77/nix-config
- prox 3y agoWow! Really impressive.
- mindslight 3y agoI wouldn't even say that's so advanced. I've got a similar scope config (not published, sorry). All built from source, with the resulting binaries pushed to less-trusted hosts. My cloud servers, router, wifi APs, Kodi boxes, etc, all running self-hosted self-built software with config kept in git. Previously I ran Debian across my setup (with a homemade configuration templating/distribution tool) but it feels like Nix really bundles up the accidental complexity of installing/deploying most software in a contained way, much more than a traditional distro. I'll be much happier when Nix gains full reproducibility and functionality like Guix's `challenge`. But even now it feels like one of the closest implementations to the Free Software dream.
- mindwok 3y agoIt's got elements of all of those things. It's basically a toolchain for building an 'environment', which is roughly analogous to a Linux distribution. It starts with a language that lets you declare the desired state of your environment, including which packages are present and the configuration of those packages. The packages are installed and managed through the Nix package manager. The end result is an 'environment' that reflects the desired state you expressed. That environment can be a Docker image, an ISO, or it could be a running system you're booted into (in the case of NixOS). Or it can even be an ephemeral environment that exists on the filesystem of whatever distribution you're using (in the case of nix-shell). Each of these options offers different levels of isolation and reproducibility, depending on the requirements of your project or system. There's lots of clever components that make something like this possible, and they're all wrapped up in the Nix umbrella.
- imagineerschool 3y ago"Yes, it is." AFAIK It's each of those things, each unfortunately named the same.
- rollcat 3y agoWe already have names like NixOS and nixpkgs at the top, and individual commands such as nix-env or nix-shell at a lower layer. Perhaps it would be beneficial to adopt official names for other components currently named "nix", such as nixlang (when referring to just the language).
- SuperSandro2000 3y agoOnly the package manager and the language share a name, everything else is named more unique
- bandrami 3y agoIt's maybe best described as a software ecosystem, which has the unfortunate problem that the programming language it uses and the package/deploy tools written in that programming language share the name "Nix". Nix the language (basically a customized version of Standard ML) is used to write package and OS definitions that Nix the tool uses to actually build and deploy software, containers, and operating systems. The "ecosystem" bit comes from the fact that the language is used to write the package/deploy definitions, and a large community of users have assembled a rather good and up-to-date set of package definitions, and these have been bundled together as an operating system, and these all share the rubric "Nix".
- microtonal 3y agoIt confuses a lot of people, because Nix breaks down the boundaries of what we traditionally see as separate tools. If you have a sufficiently powerful language to describe how to build things, you can build packages, container images, operating systems, etc. with it. Probably the closest equivalent outside Nix/Guix is Bazel or Buck (not the same, but they have many overlapping goals).
- nickcox 3y ago> Is it a package manager? A build system? An operating system? A container platform? A sandbox? An automation tool? Yes
- sjamaan 3y ago> Is it a package manager? A build system? Nixpkg is a package manager, which uses the Nix programming language to describe dependencies and build steps. Like all package managers, it has components that could be called a "build system", but that's not its main focus. > An operating system? There's NixOS which is a Linux distro built on nixpkg. But you can also use Nix under other distros. > A container platform? A sandbox? Because nix is based on an underlying immutable store of installed packages (and doesn't rely on global system state), it is trivial to spin up a shell environment in which specific combinations of package versions are available without affecting any other shell. This property allows it to be used as a lightweight alternative to containers, what people usually use Docker for: setting up an environment with well-known package versions that are the dependencies of your project. As a very simple example, I've written a simple setup for running a chosen PostgreSQL version inside a directory: https://code.more-magic.net/ppq/about/ https://code.more-magic.net/ppq/about/. You could easily build this out by adding additional software, for example if you add Python and Django from Nixpkgs to this, you'd have a complete self-contained (or "sandboxed") dev environment. When you're done developing on the project, you simple remove the repo and the entire environment is dropped too. At work we use something like the above, with Java and Clojure and a whole bunch of other software, all completely self-contained. I never had to install any of it globally and didn't have to mess around with $JAVA_HOME etc.
- SuperSandro2000 3y ago> Nixpkg is a package manager *Nix
- Cloudef 3y agoTechnically nixpkgs as just nix would be pretty useless. Nixpkgs is much more than just package derivations, it contains a whole standard library for the language.
- rgoulter 3y ago> Which widely used, existing software tools is it analogous to? It's kinda like Docker, but without the images/containers. Docker solves two problems: distributing the same program everywhere, and running those programs using containers. Nix solves the former problem. But, since it doesn't use containers, you can run the Nix packages without needing to worry about mounting into VMs or containers.
- SuperSandro2000 3y ago> Is it a package manager? Yes > A build system? No > An operating system? Thats NixOS > A container platform? nixpkgs has functions to build them > A sandbox? No > An automation tool? Yes and no > Which widely used, existing software tools is it analogous to? Arch Linux plus Haskell plus Ansible plus better
- superkuh 3y agoNix is a distro that admits defeat against dependency management and entirely gives up on the idea of having system libraries. Instead every application you want to run has to have all of it's dependencies explicitly stated and provided custom in nix style configs for each program. Usually this means someone else has done all this packaging work for you. They hate it when people call it containerization but it's effectively taking containerization to the extreme for every single bit of software on your system with no ability to not use containers. But if, say, you want to compile a random C program you found on the web then it is up to your to now set up the build environment and provide all the libraries and deps to be able to compile and then run the program. Just running make or ./configure or cmake . isn't going to do it because those configuration setups won't have a system lib environment to check against. It seems like a really weird distro to chose as your desktop but makes fine sense in commercial enterprises we're you're going to re-build the world for all your software anyway.
- lolinder 3y agoI think you're thinking of NixOS, which is a distro based on Nix. Nix itself is not a distro. Ironically, this further emphasizes how confusing the project is (projects are?).
- _7tgr 3y agoWell, sure, but setting up the build environment is pretty easy! You just specify the libraries as you normally would, and it works. The only difference is that those libraries are only available to that package, and not globally. The function `stdenv.mkDerivation` will actually build a standard ./configure && make style C project for you if you provide it some package source, you just have to copy out the build artifacts (with something like (cp project bin/project) and specify a list of libraries needed at build/runtime. Agree that the documentation for all of this could be a lot better and more discoverable. It's good once you get over the initial hump though.
- juped 3y agoThis is the opposite of "pretty easy". (Apologies if I'm just failing to detect sarcasm.)