News for hackers. Stuff that matters.
Re:How to Learn Nix by indigo747 on Monday November 22, 2021 @04:12AM (#29304402)
I've bounced off Nix a couple of times and figured that the problem is that it was too different. A lot of Linux distros (especially post-systemd) have a fair number of similarities and it's pretty easy to translate knowledge between them. NixOS _probably_ works very similarly, but it's also got this additional declarative configuration layer on top, which is the point of using NixOS, and it's got its own special way of doing things.

You can't translate Linux knowledge to a NixOS config directly, you need NixOS' documentation to understand the "NixOS Way" of doing things, and the NixOS way of doing things does not translate into other distros. And the documentation is difficult to understand and at times seemingly arbitrary.

You have to commit to learning NixOS and understand that you are only learning NixOS, it won't help you use anything else. Other Linux distros help you learn Linux in general and inform your understanding of Linux system construction, but NixOS is its own thing. Plenty of people learn NixOS anyway, and more power to them, but it's definitely pushed me away.

Re:How to Learn Nix by akavel on Monday November 22, 2021 @05:00AM (#29304723)
> "and understand that you are only learning NixOS, it won't help you use anything else"

So — for one thing — in my personal case, it helped me at one time when I was experimenting with kernel build flags. With the caveat that finding how to change them was (surprise surprise) typically non-trivial in Nix in the first place... so it may be a feeble counterpoint... but still, after I found how to do it, NixOS made rebuilding new OS with different kernel flags absolute breeze, with basically 0 worry if I bork something (I mean, except maybe going to deep hardware params hacking such that would risk fraying some electronics) — I'd always automatically be just one GRUB entry away from a previous working configuration. (Though also useful to have `git commit`ed the previous /etc/configuration.nix from before I made some risky change, so that I could easily go tweaking again from there.)

Re:How to Learn Nix by ochoseis on Monday November 22, 2021 @09:05AM (#29306385)
I've had a similar experience with systemd itself. While you could go and read through the systemd docs to understand all of its nooks and crannies, you can actually learn the important bits by reading through the source for NixOS's modules (which are linked directly from https://search.nixos.org/options). You start to see patterns of which options they set in the units, and pretty quickly build up the knowledge you need to write your own. This is also aided by the fact that the repository is one giant git repo hosted on GitHub that you can search, clone, tweak, atomically deploy from a local branch. It buys you so much flexibility when experimenting.
Re:How to Learn Nix by GekkePrutser on Monday November 22, 2021 @06:15AM (#29305177)
This is something that is coming to traditional Linux as well though, with zfs snapshots. I've had it for a long time on FreeBSD. I just snapshot before I do something big.

I see the benefit of declarative configuration as an admin at work where we need to set up many systems the same way. For home desktop use I don't really see the point, I don't think it's a tech that fits perfectly in every scenario. Like most technologies there's usecases where its benefits shine and the drawbacks are irrelevant, and others where it's the opposite.

For example I often come across software that isn't packaged for my OS and I like to just compile them and try them out without having to do the whole packaging routine.

Re:How to Learn Nix by akavel on Monday November 22, 2021 @06:28AM (#29305253)
As to "home use", personally I'm successfully keeping my dotfiles & $HOME/bin/ scripts managed with Nix + home-manager. Becomes useful when changing jobs, and also makes it easier to share new config tricks between work & home machine. Regardless if Linux or Mac.

edit: in particular, going just Nix (not NixOS) on work machine(s) allows me to fall back to apt-get/brew quickly when a particular tool is not (yet) on Nixpkgs.

Re:How to Learn Nix by ris on Monday November 22, 2021 @10:27AM (#29307339)
> For home desktop use I don't really see the point

Lucky that you don't need to run NixOS as your OS to get a lot of the advantages from it then. I use debian for my boring desktop applications but have Nix available to me for when I need any e.g. development tools.

Re:How to Learn Nix by Filligree on Tuesday November 23, 2021 @02:23PM (#29322067)
This is what I used to think, but after twenty years of running Linux, and at least twice that many reinstalls, I very much appreciate an OS that doesn't eventually bitrot underneath me.

"Just install this one package to get CUDA working"... no. If I do that, then in two months when I want to do something else I'll find my OS is no longer capable of being used that way. And in four, when I want this specific version of CUDA working again, I don't remember how. The instructions probably wouldn't work anymore anyway.

NixOS allows me to put in down in terms of code, and the code practically never stops working. It's also immortal -- I've never needed to reinstall it. If I did, it'd be painless, but that's only ever happened in case of hardware failure.

It's the best part of Nix.

Re:How to Learn Nix by tux1968 on Monday November 22, 2021 @07:30AM (#29305639)
> This is something that is coming to traditional Linux as well though, with zfs snapshots.

Has there been a change in ZFS licensing? I thought it was always going to remain poorly integrated into the Linux ecosystem.

Re:How to Learn Nix by pxc on Monday November 22, 2021 @09:32AM (#29306660)
> I thought it was always going to remain poorly integrated into the Linux ecosystem.

Interestingly, NixOS excels at ZFS integration.

Because NixOS builds everything from source with transparent binary caching, always upgrades your system as an integral while, and performs upgrades atomically, you'll probably not even notice that ZFS isn't in the mainline kernel as you use it. NixOS will never upgrade your kernel to one that's incompatible with whatever version of ZFS is in the repos, and it'll never leave you in a partially upgraded state where your new kernel is installed, but your new ZFS modules are not— even if you pull the power during an upgrade.

ZFS feels very native on NixOS. It's great

Re:How to Learn Nix by tux1968 on Monday November 22, 2021 @08:24PM (#29313607)
To my knowledge, the integration with the kernel is still not very good. As someone else mentioned in a reply, there are large swathes of the Solaris kernel with duplicate functionality included in the Linux kernel solely to support ZFS, because native integration is too difficult in face of the licensing and maintenance issues.

It remains a kludge rather than something that can really be thought of as an integrated Linux solution. Even if it works okay in some situations.

Re:How to Learn Nix by pxc on Monday November 22, 2021 @10:12PM (#29314210)
Is the Solaris Porting Layer really due to a licensing issue or just a ZFS portability issue? FreeBSD's ZFS implementation reportedly has a similar portability shim.¹ The new OpenZFS implementations for Windows and macOS each have their own Solaris Porting Layer, too.

If what you want is just snapshotting and you want something that's in the mainline kernel, I guess there's BTRFS. Bcachefs seems to be coming along nicely, but who knows when it'll really be ready.

——

1: https://papers.freebsd.org/2019/BSDCan/jude-The_Future_of_Op...

Re:How to Learn Nix by crypt0x on Monday November 22, 2021 @08:02AM (#29305900)
I can ignore the licensing for my personal stuff (and some work might be able to, too) but from a technical perspective I find the SPL translation layer and fs caching overhead much greater pill to swallow. It’s basically bolting on Solaris as a 2nd memory system just for zfs. I really hope this hack is recognized for what it is sooner rather then later…
Re:How to Learn Nix by boomboomsubban on Monday November 22, 2021 @08:49AM (#29306255)
No. It's poorly integrated but well maintained in the Linux ecosystem. Certainly usable.
Re:How to Learn Nix by Filligree on Monday November 22, 2021 @09:24AM (#29306577)
With the exception of NixOS, with which it's well integrated. The integration is a bit of an oddball, though.

Kinda typical... nice to have though!

Re:How to Learn Nix by pimeys on Monday November 22, 2021 @07:46AM (#29305778)
You can do the same with btrfs too. I think SuSE already integrates this, and I used to do that with Arch Linux before I started using NixOS.
Re:How to Learn Nix by scns on Monday November 22, 2021 @09:36AM (#29306690)
SUSE uses btrfs as the default fs for years. A snapshot is taken before each upgrade automatically.
Re:How to Learn Nix by heavyset_go on Monday November 22, 2021 @03:19PM (#29311142)
> This is something that is coming to traditional Linux as well though, with zfs snapshots. I've had it for a long time on FreeBSD. I just snapshot before I do something big.

This has been available on traditional Linux for quite some time with btrfs snapshots.

Re:How to Learn Nix by pxc on Monday November 22, 2021 @09:26AM (#29306600)
> You have to commit to learning NixOS and understand that you are only learning NixOS, it won't help you use anything else.

This is kind of true on a surface level, but NixOS experience can be super helpful for setting up other distros because it turns Nixpkgs into a repository of high quality examples and demos that are always up to date.

Once you learn some basics of reading Nix code and how the NixOS module system works, the Nixpkgs repo itself becomes an excellent cross-distro resource on how to configure Linux software, much like the Arch and Gentoo wikis. I often consult Nixpkgs on how to do things in Linux for the purposes of configuring another distro or helping another user to do so! :)

Re:How to Learn Nix by ivank on Monday November 22, 2021 @04:26AM (#29304500)
The NixOS way of doing things (a layer on top of plain config files) is inevitable once configuration management is taken seriously: one needs to be able to merge configuration values from multiple source files; for example, a generic role plus some more machine-specific role, working together to produce one systemd unit or file in /etc. The modules in nixpkgs effectively make it possible to combine configuration values to produce most of the config files that Linux applications want.

If one weren't using NixOS to do it, it would be done with your own templates and configuration management, and probably without the huge advantage of being able to rebuild a whole immutable system without leftovers from prior configurations.

Re:How to Learn Nix by mindslight on Monday November 22, 2021 @10:54AM (#29307735)
Doing programmatic configuration with a traditional distribution isn't difficult. I've got a python script that starts with a tree of config files and a top level file that says what files to consider per-machine. Each config file is run through Jinja2. Some templating even pulls data from a LibreOffice spreadsheet [0]. By default the script only pushes files that haven't been remote, so if you do deviate and edit a config file on a machine you can diff it to merge those changes back into the centralized config before overwriting.

Having said that, I'm moving towards NixOS for reasons detailed in another comment.

[0] It's ugly but it works. I'd love to find a lightweight curses-based data structure editor.

Re:How to Learn Nix by temptemptemp111 on Monday November 22, 2021 @05:38AM (#29304956)
Where is the evidence for this? Where is the evidence that you can and should mix config management all of the way down the OS stack? How many containerization concepts do we need? Docker, lxc, VMs, and now NixOS? If it were a legitimate abstraction layer, then wouldn't it have caused fewer problems in implementation? And wouldn't it have seemed more intuitive to Unix experts? Yes... Reinventing the wheel again. I'm open to nicer restructuring of the Linux fileystem, but this is really re-inventing the wheel trying to polish over ugly parts that are ugly for a reason. Keep useful abstractions separate!
Re:How to Learn Nix by kohlerm on Monday November 22, 2021 @08:44AM (#29306215)
One problem that NixOS solves is to be able to use different tools on the same host in different versions easily(1) and in a reproducible way(2). Docker containers can be used to solve 1), but they are in some sense overkill and quite a few uses cases. If you are a developer who only wants do use different compilers then Docker containers are not really ideal, because they also enforce process isolation. Also there is the popular believe that Docker containers also solve 2) that is not really completely true. Yes you can run a Docker image in a reproducible way on different machines, but cannot necessarily reproduce the Docker image, at least not with the standard Docker tools. You can use Nix to create Docker images in a reproducible way.
Re:How to Learn Nix by chriswarbo on Monday November 22, 2021 @12:14PM (#29308806)
> How many containerization concepts do we need?

Nix and NixOS aren't containers (or VMs, etc.).

> If it were a legitimate abstraction layer, then wouldn't it have caused fewer problems in implementation? And wouldn't it have seemed more intuitive to Unix experts? Yes... Reinventing the wheel again.

The basic concept of Nix is (a) use the `--prefix` argument of ./configure scripts to keep things apart, and (b) use the `PATH` end var to choose what we want to run.

In comparison, containers are much more recent, require more invasive changes (i.e. support from the kernel), etc.

Personally, I like using containers to run binaries. Putting a whole Linux/Busybox installation inside one seems to defeat the point though...

Re:How to Learn Nix by chriswarbo on Monday November 22, 2021 @12:01PM (#29308629)
> Docker, lxc, VMs, and now NixOS?

NixOS came out in 2003. For context, that's when Xen came out.

LXC came out in 2008; KVM (Linux's built-in VM support) came out in 2007; Docker came out in 2014.

Re:How to Learn Nix by seniorivn on Monday November 22, 2021 @06:19AM (#29305202)
most people who have claim to be unix experts and cannot grasp nix are usually just don't like functional languages

those who do, say that it's a great idea, but implementation is a bit hacky and not well documented

Re:How to Learn Nix by _2paq on Monday November 22, 2021 @04:32AM (#29304530)
This is why I feel efforts like Fedora Silverblue might end up becoming mainstream in the years to come rather than esoteric projects like NixOS.

I personally dislike both projects though, when it comes personal desktops. Silverblue is heavily influenced by Flatpak and I don't expect RPMs for GUI applications to survive in Fedora. NixOS needs you to learn Nix which is a pretty steep learning curve and like you said, that knowledge probably won't translate anywhere else. You're probably better off investing your time learning things like shell/python scripting, Ansible, and Docker/podman.

Re:How to Learn Nix by oneplane on Monday November 22, 2021 @06:12AM (#29305163)
Flatpak and the likes are similar enough to Apple's "bundle" concept where you put all the versions, dedicated libraries and frameworks inside the bundle for your 'thing' that you want to distribute. It has been proven to work well (or well enough). I suppose the additional technology behind overlays/bindmounts etc. is different since a Darwin bundle is practically just a directory with some predetermined layout but the experience is the same.

Once it doesn't depend on (yet again) a daemon, registry, and other system-level components but is understood by the shell (or DE) instead, you get a user experience that something like Nix cannot deliver (or at least, not without cutting down on the whole "learn this language to then learn those features to then get work down" thing).

Re:How to Learn Nix by _2paq on Monday November 22, 2021 @06:58AM (#29305440)
The bundle concept applies more to AppImages than to Flatpak. Flatpak downloads common runtime libraries and packages and uses them to run all GUI packages in a sandboxed environment using bubblewrap. OStree is also involved.

I dislike Flatpak because it encourages package maintainer obsolescence. I heard a guy from OpenSUSE saying in a MicroOS presentation that why create, manage, and use RPMs when we can just use Flatpak. I also don't want to touch Flatpak anymore because people from GNOME are involved in it.

Re:How to Learn Nix by pxc on Monday November 22, 2021 @10:18AM (#29307206)
I have to admit that Flatpak's runtime deduplication is impressively good, despite preferring the Nix approach.

It's a shame to hear that kind of talk coming from the openSUSE world when Zypper did so much to raise the bar for high-level Linux distro package management tools. :(

openSUSE does an awesome job getting a hell of a lot of mileage out of RPM, from the vendor-based repo management to BTRFS snapshots to the huge and powerful (cross-distro!) automated build service.

Re:How to Learn Nix by _2paq on Tuesday November 23, 2021 @12:25AM (#29314870)
> It's a shame to hear that kind of talk coming from the openSUSE world when Zypper did so much to raise the bar for high-level Linux distro package management tools. :(

Yeah, I don't think it'll last in the foreseeable future judging by how these distros are jumping on the Flatpak/Snap bandwagon. For these distros, package management might as well be dead.

I expect a few distros, such as Alpine Linux and Arch Linux, to remain relatively free from the influence of Flatpak and that's what I'll continue to use on my personal machines.

Re:How to Learn Nix by seniorivn on Monday November 22, 2021 @06:11AM (#29305156)
right now NixOS is for a small subset of geeks(who are ok with using custom functional language for pretty much all configuration) but it's entirely possible to make a GUI based like a SUSE configurator based on nix, and with mature enough nix ecosystem it will work flawlessly an be powerful and simple to use for the end user
Re:How to Learn Nix by wizeman on Monday November 22, 2021 @08:27AM (#29306073)
> it's entirely possible to make a GUI based like a SUSE configurator based on nix

There is such a project already: https://github.com/nix-gui/nix-gui

Re:How to Learn Nix by oneplane on Monday November 22, 2021 @06:14AM (#29305170)
For the end user it doesn't matter if a GUI is using some nix-thing in the background. It could just was well run dpkg/rpm behind the scenes and as long as the result is the same it really doesn't matter.

This is also why Nix and NixOS painted itself in a corner; the presented value is only relevant if you are hacking away at it. When you have a smooth GUI experience it really no longer matters what the technical goodness underneath is.

Re:How to Learn Nix by ratorx on Monday November 22, 2021 @07:28AM (#29305613)
I think the point is that Nix makes it a lot easier (in some ways) to build a more reliable system GUI, rather than other package managers because of declarativity being a first-class feature.

Users shouldn’t have to care what their GUI uses underneath, but it could be the difference between building your own pseudo-declarative layer (which you now have to maintain in perpetuity and handle all the small edge cases), or getting something that is already declarative as the backend and simply generating a config file from the GUI (https://github.com/nix-gui/nix-gui).

EDIT: Also composition. Users could, if they wanted to, augment the GUI generated configuration using the built-in Nix features for composition with config files, which is a lot easier than trying to do the same with traditional system managers.

Re:How to Learn Nix by oneplane on Monday November 22, 2021 @11:58AM (#29308592)
I doubt a user wants or cares about any of that. User story:

As a User I want to select an application to run so that I can use the application.

This applies to practically everything, if you want to play a game, you don't want to dick around with installers, managers, layers, configurations etc. Just point and click, that's all it should need.

Re:How to Learn Nix by ratorx on Monday November 22, 2021 @12:18PM (#29308888)
My main point was in the first paragraph. Users care about reliability and I was justifying why I think Nix has the potential to be a more reliable base for a GUI than other options.

I also do think certain users will care about e.g. extensibility/composabilty, as soon as they have to do anything outside of the officially blessed path. Having the ability to compose things nicely is pretty useful. It’s the difference between having to recreate the entire GUI configuration manually and just being able to dip into the config for the (likely small) non-standard part of the system.

Re:How to Learn Nix by oneplane on Monday November 22, 2021 @12:38PM (#29309192)
While I agree with that, operating systems like macOS and Windows have shown that ease of use still beats other features when a user simply wants to 'do' something.

As good (or as bad) as the technical underpinnings can be, as long as the user gets what they want most of the time they are fine with it.

Nix is one big advantage of course and that is that is isn't a commercial endeavour beholden to markets and income. So it doesn't really matter what general users might want or think (at least not at this stage). We also still have the same problem that is always present and that is content availability. If a user wants to install a Netflix client but none is available, it doesn't matter how good the tools are. Even the best UX can't help when the desired content isn't available.

Re:How to Learn Nix by otabdeveloper4 on Monday November 22, 2021 @04:46AM (#29304613)
Nix isn't a package manager, it's a system for making ad-hoc, repeatable computing environments.

The "package manager" paradigm doesn't fit Nix that well, which is why it's a painful experience when you come to it from the angle that it's another Linux distro.

(IMO it makes more sense to think of Nix as "declarative Docker that doesn't need Linux namespaces".)

Re:How to Learn Nix by grawp on Monday November 22, 2021 @06:15AM (#29305176)
Thisss! I'm very disappointed that most people seriously misunderstand what Nix is. Some calls it just another package manager and others dare to call it another Docker... while i'm screaming in horror internally.
Re:How to Learn Nix by piaste on Monday November 22, 2021 @09:14AM (#29306465)
> Some calls it just another package manager and others dare to call it another Docker

To be fair, when it gets installed on a personal, non-developer desktop machine, Docker typically is just another package manager.

Re:How to Learn Nix by pxc on Monday November 22, 2021 @01:59PM (#29310272)
Nix is pretty unlike the package managers of most popular distros, but it's not so dissimilar to other source-based package managers, like Gentoo's Portage. The basic idea that you have a giant monorepo of build recipes and a tool that automatically builds packages from source according to it is the same.

It's absolutely true that you're missing out if all you do is use `nix profile install` like you might use `apt-get install`, though.

Re:How to Learn Nix by otabdeveloper4 on Monday November 22, 2021 @04:11PM (#29311612)
No, not really.

The projects do rely heavily on Nix for infrastructure stuff, and I have to explain it to unprepared developers often.

The best angle is to explain it as "like Python venvs, except works for any combination of programming languages". That sets for correct expectation for feature set and complexity.

P.S. The single biggest huge blocker is lack of support for nix-shell in VSCode and JetBrains IDEs. Every other complaint is a minor trifle in comparison.

Re:How to Learn Nix by pxc on Monday November 22, 2021 @05:41PM (#29312448)
> The single biggest huge blocker is lack of support for nix-shell in VSCode and JetBrains IDEs. Every other complaint is a minor trifle in comparison.

For the VSCode case, does the Nix Environment Selector extension not do what you want? https://marketplace.visualstudio.com/items?itemName=arrteria...

> No, not really. [...] [E]xplaining it as "like Python venvs, except works for any combination of programming languages" [...] sets for correct expectation for feature set and complexity.

That's definitely a good description of the development environment use case, for people who know what Python venvs are for. It's also accurate, as far as Nix is about Nix profiles. Nix profiles are like Python venvs.

But all or close to all of the packages in Nixpkgs work just fine even if you have no profile at all set up for them— they behave correctly even if you invoke them directly from their paths in /nix/store. If you look at the install target as `/nix/store` rather than `/nix/var/nix/profiles/...`, then `nix-build` is just a source-based package manager in the ordinary sense which:

• installs each package to a unique, content-addressed-ish prefix

• uses the Nix language and Bash like Homebrew uses Ruby, Portage uses Ebuilds + Bash, MacPorts uses Tcl, etc.

• happens to have a really good build caching story

And your tools that build Nix profiles (`nix-env`, `nix profile`, `nix-darwin` and `nixos-rebuild`) aren't doing package management in the sense of building or installing anything, but instead just build convenient facades (out of symlinks) for accessing all of those packages installed to /nix/store in a more convenient way. The venv-like properties of those facades (symlink forests) just emerge from the one-prefix-per-package strategy of the underlying package manager. (In the case of profile managers that manage services, they also run some activation scripts.)

All of that is not to say that what I outlined above would be a better strategy for describing Nix to developers who just want to take advantage of environments that their DevOps team has prepared for them. I think you've settled on a really good explanation, for the reason that you outline.

If you're the Nix guy at work, you probably already understand what I wrote in this post, and have good reasons for preferring to present Nix to the developers that you support in the way you do. What I want to point out is more for the benefit of others, especially people who've done packaging or sysadmin work with other distros but maybe don't get how Nix works, maybe because they're turned off by all the FP jargon.

The lesson is this: there is an old-fashioned, familiar sort of package manager underneath the tools Nix users interact with. The essence of how that package manager is different from what came before can be boiled down to a single sentence: each variation of every package gets installed to a unique prefix. Once you have that, you can do wonderful things like build in snapshot-free rollbacks; allow unprivileged, per-user installation of packages; or generate venv-like per-project environments; and all of the other cool things Nix enables. Nix's complexity and power both follow from that one tweak, from what it took to get there on the one hand (the concept of derivations and various properties of the Nix language) and what it buys you once you have it (polyglot, venv-like setups and lots of other goodies).

Re:How to Learn Nix by alufers on Monday November 22, 2021 @05:03AM (#29304748)
The knowledge is one thing, because you can always learn how to do things the "Nix way" (either by reading the incomplete documentation or tinkering for hours until the thing works).

But the real problem is that software does not understand nix either.

For example loads of scripts expect /bin/bash to exist, but on NixOS it is missing. Want to run a random python script from github? Well that's a bummer, because there is no nix version of a random library this script uses. Also no-machine server and Chrome Remote Desktop don't work, and these are the two remote desktop solutions which work on spotty 4G.

And I had to ditch NixOS, because my employer forced me to use a proprietary VPN, and I there is no way it would run on NixOS.

Re:How to Learn Nix by nvarsj on Monday November 22, 2021 @05:18AM (#29304840)
Just to say, there are always ways to deal with what you describe. For /bin/bash, create a symlink from /bin/bash to bash:

  system.activationScripts.binbash = ''
    mkdir -m 0755 -p /bin
    ln -sfn ${pkgs.bash}/bin/bash /bin/.bash.tmp
    mv /bin/.bash.tmp /bin/bash # atomically replace /bin/bash
  '';
For python, you're best off using a virtualenv anyways. For proprietary binaries, you can almost always get them to run using steam-run. But the nicer way is a wrapper script to set up LD_LIBRARY_PATH, or custom derivation to patch their ld lib paths.

Yeah it requires some elbow grease sometimes, but what distribution doesn't? Maybe Fedora/Ubuntu? I think the pain really is all that prior Linux knowledge is non-transferable and you have to learn how to fix things in the Nix way.

Re:How to Learn Nix by alufers on Monday November 22, 2021 @09:56AM (#29306904)
> wrapper script to set up LD_LIBRARY_PATH, or custom derivation to patch their ld lib paths.

There is your problem, I don't want to spend time writing wrapper scripts, or researching how to craft my buildFHS for every little piece of software I will run once for an oddly specific purpose.

Running the proprietary VPN on Arch Linux was as simple as running debtap, and then installing the package via pacman, even though the package shipped by the vendor was made for Ubuntu. It even figured out the dependencies automatically.

I know I could do the same thing on NixOS, but it would be way more clunky and time consuming. For example: this is how a package is installed from a .deb using nix: https://github.com/NixOS/nixpkgs/blob/nixos-19.09/pkgs/tools...

If Arch can do it in two commands, so should NixOS, just with two lines of nix :)

Re:How to Learn Nix by whateveracct on Monday November 22, 2021 @01:13PM (#29309711)
It could probably be automated more. It's just that most NixOS users have low interest in automation .deb -> Nix conversion since it's not something you actually run into often as a NixOS user.
Re:How to Learn Nix by pxc on Monday November 22, 2021 @12:30PM (#29309059)
Check out envfs, which automagically puts symlinks like that in place for you in a systematic way!

https://github.com/Mic92/envfs

Re:How to Learn Nix by seniorivn on Monday November 22, 2021 @06:15AM (#29305180)
you should not create such an imperative simlink almost anything can be packages with nix in a minute or two, so any code you found out the internet would be easy to run and it will take not much more time than to simply check it's build config for malicious code, which you should do anyway
Re:How to Learn Nix by YuukiRey on Monday November 22, 2021 @07:38AM (#29305701)
Maybe if you use buildUserFHS and --impure a lot. But NodeJS applications that try to download binaries at install time or python packages with conflicting package versions definitely take more than a minute or two. Just look at the history of Anki in Nixpkgs, or the derivations for JetBrains products or Cypress or any of the other packages that took consistent effort by multiple contributors to even get them working in the first place.

I think it's important to manage expectations about Nix and that includes being realistic about what's easy and simple what isn't.

Re:How to Learn Nix by nvarsj on Monday November 22, 2021 @10:45AM (#29307605)
Yeah, I am aware what I did above would make a lot of nixos purists shudder. But from a pragmatic pov it saves me a lot of time. It's mostly to deal with repos at clients that are filled with scripts hardcoded to /bin/bash.
Re:How to Learn Nix by xfer on Monday November 22, 2021 @06:34AM (#29305286)
If your software can run on linux it's extremely unlikely to not work on NixOS.

In fact proprietary binaries will be much easier to run since you don't have to do with non-reproducible builds in some source repo/build system.

Have you considered reading the manual? NixOS is not for you if you don't want to spend time learning the basics.

I have run xilinx vivado inside FHS within 15mins. Mostly figuring what libraries are needed for all binaries.

https://nixos.org/manual/nixpkgs/stable/#sec-fhs-environment...

Re:How to Learn Nix by alufers on Monday November 22, 2021 @09:51AM (#29306852)
I really tried making a derrivation for for the nomachine server, but it consists of a wrapper script in bash which for some reason is very long and complicated, this script calls a binary which required some libraries which were missing in the NixOS repo, and everyting assumed the program was installed in /opt/something. Then I tried steam-run, but the program just segfaulted on me when I tried. This is where I reckoned investing more time was not worth it.

On Arch I just do `yay -S nomachine` and call it a day.

But I really believe that someday the NixOS community will catch up, but currently it is not for me, since sometimes I want to get stuff done and not tinker with my system.

Re:How to Learn Nix by xfer on Wednesday November 24, 2021 @01:49AM (#29327518)
I played Dota2 in NixOS for years, so i am not sure why steam wouldn't work for you(it uses FHS too). You can always ask for help in discourse/matrix channel.

> since sometimes I want to get stuff done and not tinker with my system.

Plenty of people do get their work done on NixOS, so good luck with that attitude.

Re:How to Learn Nix by huijzer on Monday November 22, 2021 @06:04AM (#29305114)
> You have to commit to learning NixOS and understand that you are only learning NixOS, it won't help you use anything else.

As a NixOS user, I did learn a lot about what is part of Linux distributions and what is part of the kernel, and how they interact. Compared to my previous Ubuntu knowledge, of course. If I would have ran Arch, I would have learned similar things.

Re:How to Learn Nix by mindslight on Monday November 22, 2021 @10:47AM (#29307640)
I bounced off NixOS a few times as well. In addition to what you've said, I also didn't find it compelling because I already had a way of doing programmatic configuration and functional system management under Debian using my own scripts. So I didn't particularly see what converting everything over to NixOS configs would get me.

What made NixOS stick is running up against some problems where Debian itself was ill-suited and seeing Nix's power. For example, building an image for a Raspberry Pi can be done with a handful of config lines. Changing between a cross compile and an emulated compile is also a handful of lines. This kind of power feels akin to the general lisp / functional curse where certain things become so easy they aren't even well documented because once you understand the system it's second nature.

Another benefit - I've modified kernel source and I've written my own modules, but they always fell by the wayside due to the maintenance burden of a compiling a custom kernel package. With Debian, I would end up reading kernel source plenty of times to figure out what was going on, but it was effectively read only. Whereas with NixOS, adding kernel overlays is straightforward. Using what is essentially a source distribution plays to the larger philosophy of Free software.

Re:How to Learn Nix by larusso on Monday November 22, 2021 @07:07AM (#29305492)
Same here. I still flock to the page every now and then and think about to give it yet another shot. But my main usecase is to develop software. I work with java, rust, ruby, JS and different other languages that needs custom treatment when doing things the nix way. Like writing a custom nix shell env file which deals with npm dependencies and the like to have all the glory deterministic package updates etc. I guess I will try it again at one point.
Re:How to Learn Nix by rgoulter on Monday November 22, 2021 @04:49AM (#29304636)
This is a pretty good take. Although I'd further emphasise: knowledge of Linux is "necessary but not sufficient" for using NixOS. NixOS requires additional knowledge, rather than a different set of knowledge.

I think for many developers with Linux experience, probably getting a reasonable NixOS desktop setup is straightforward.

There are some compelling benefits to Nix/NixOS, but these also require getting past a steep cliff in the difficulty curve.

Re:How to Learn Nix by evh on Monday November 22, 2021 @11:48AM (#29308462)
>I think for many developers with Linux experience, probably getting a reasonable NixOS desktop setup is straightforward.

I took this as an excuse to try NixOS myself and an opportunity to provide anecdata.

Previous Linux experience: Lots, including about 7 years of Gentoo use, some Arch and the usual distro hopping before that. Mostly on laptops (not counting VMs). Lately it's mostly been the BSDs so I'm a little lost.

It took me about 45 minutes from searching for their site to have a working XFCE install using their minimal install ISO with VirtualBox. Certainly a different experience, but with their install guide and searching "nixos xfce" you'll get it done.

Promptly rebooted and went for an encrypted ZFS root - less straightforward but after a few PEBKAC snags I got it up in an hour or two.

My immediate impression is that this is great but not being allowed to just

    # which zsh >> /etc/shells
rubbed me the wrong way. Definitely something I'll consider using in the future, seems like a good fit for i.e. a VPS you might want to move easily.

Naturally I haven't learned the config language fully, but it seems easy enough if the docs aren't terrible.

Re:How to Learn Nix by pxc on Monday November 22, 2021 @10:28PM (#29314293)
Thanks for sharing your experience!

> My immediate impression is that this is great but not being allowed to just `# which zsh >> /etc/shells` rubbed me the wrong way.

Yep. That kind of thing will come up; on NixOS, root's interactive whim doesn't own /etc— `nixos-rebuild` owns /etc. But of course, both root and nixos-rebuild are you, so that's not so bad. :)

For those curious (I assume the parent poster already figured it out) the NixOS way of enabling ZSH as a login shell is the following one liner:

    programs.zsh.enable = true;

which will both ensure that it is installed and on the PATH, and add it to /etc/shells for you.

As a rule of thumb, it's generally a good idea to check the NixOS options to see if there's a module defined for configuring a program before just adding it to your `environment.systemPackages`. Here's NixOS' zsh configuration options, for example: https://search.nixos.org/options?channel=21.05&from=0&size=5...

(`programs.zsh.{shell,prompt,loginShell,interactiveShell}Init` are your escape hatches; you can put whatever custom zsh scripting you want in there)

Re:How to Learn Nix by whateveracct on Monday November 22, 2021 @01:15PM (#29309726)
> This is a pretty good take. Although I'd further emphasise: knowledge of Linux is "necessary but not sufficient" for using NixOS. NixOS requires additional knowledge, rather than a different set of knowledge.

You can use NixOS to learn more about Linux quite well. You can't really ruin everything by mucking around at the low-level. Just rollback to previous generation. I've definitely learned a lot due to NixOS allowed me to hack with impunity.