News for hackers. Stuff that matters.
Re:Nix and NixOS, my pain points by 40yearoldman on Saturday December 24, 2022 @11:55PM (#34124414)
I keep reading, this, and keeping being told this. Yet I switched every system over to nix and have found no thing but the best examples documentation and help from nix to do so.

Within the span of a afternoon and a bit a reading I went from zero, to a script that lets me setup an entire dev systems with just a few commands in a vm, and or even on hardware.

If anything the Nix documentation is just as good as every other thing out there. What is different is there are more than one way to do many things in Nix. This to me I think is the core of complaints. Its a language, and thus the language has may expressions that result in the same outcome.

The second bit I think people struggle with is it is functional. If you look at Nix complaints they appear to nearly be identical to that of Haskell.

Re:Nix and NixOS, my pain points by CapsAdmin on Sunday December 25, 2022 @06:07AM (#34126190)
I also didn't notice that the documentation was especially bad. I'm thinking maybe it makes more sense for some programmers?
Re:Nix and NixOS, my pain points by kstenerud on Sunday December 25, 2022 @07:18AM (#34126598)
Then you are a superhuman. I too went through weeks of pain and suffering to get my nixos hypervisor running, and if I were to lose my script and have to start from scratch again, I'd just install Debian instead.

I would never recommend nixos to anyone. The concept is awesome, but the execution is terrible.

Re:Nix and NixOS, my pain points by prox on Sunday December 25, 2022 @09:45AM (#34127635)
What I often find is this “ought to know” treshold. Parent comment user is probably familiar with lingo you are not. Documentation often assumes a certain level and a writer does not imagine a less capable user.
Re:Nix and NixOS, my pain points by pxc on Sunday December 25, 2022 @01:21PM (#34129647)
Yes, the Nix community has great reference docs for people who already know how things work, for most things imo. At the same time, it isn't always obvious enough where to find a good introduction to terms and concepts used. But materials of that kind are increasingly available and general gaps are being filled with a lot of focus lately.
Re:Nix and NixOS, my pain points by laserlight on Sunday December 25, 2022 @08:10AM (#34126935)
By documentation, I believe people mean tutorials. At least, lack of tutorials is my complaint. I've read all introductory material. I want to build a customized version of emacs on nix, yet I have no idea how to do it or where to start.
Re:Nix and NixOS, my pain points by scoopertrooper on Sunday December 25, 2022 @08:54AM (#34127233)
Why use a tutorial when ChatGPT has you covered?

> How do I create a nix package that clones eMacs from GitHub and builds it from source?

{ pkgs ? import <nixpkgs> {}, fetchFromGitHub }:

let

  emacsSrc = fetchFromGitHub {

    owner = "emacs-mirror";

    repo = "emacs";

    rev = "master";

    sha256 = "0xabcd1234";

  };
in pkgs.stdenv.mkDerivation {

  name = "emacs";

  version = "27.1";

  src = emacsSrc;

  buildInputs = [ pkgs.autoconf pkgs.make ];

  configurePhase = ''

    autoconf

    ./configure --prefix=$out

  '';

  buildPhase = "make";

  installPhase = "make install";

}
Re:Nix and NixOS, my pain points by delroth on Sunday December 25, 2022 @09:01AM (#34127287)
As usual for ChatGPT this is full of mistakes and bad code. The buildPhase and installPhase it writes are completely unnecessary and worse than the default, the configurePhase might work in some cases but most likely won't, and it's unnecessary when instead autoreconfHook should be used, stdenv/autoconf should be taken as an argument for the function returning the derivation, autoconf should be a nativeBuildInput, make is already in stdenv, etc.
Re:Nix and NixOS, my pain points by toastal on Sunday December 25, 2022 @12:54PM (#34129380)
You're also supposed to call the pre and post hooks for these phases.
Re:Nix and NixOS, my pain points by Rexogamer on Monday December 26, 2022 @06:45AM (#34136880)
More fundamentally, even if the code produced by ChatGPT worked and was high-quality, why should a new user have to rely on a chatbot instead of useful/up-to-date tutorials and guides?
Re:Nix and NixOS, my pain points by steeleduncan on Sunday December 25, 2022 @05:31PM (#34132180)
> sha256 = "0xabcd1234";

Am I right in assuming this is a ChatGPT misunderstanding, or is it a wildcard SHA256 in nix to allow any download?

Re:Nix and NixOS, my pain points by tadfisher on Sunday December 25, 2022 @11:32PM (#34134612)
Definitely not a wildcard, such things are not allowed. You can fetch at evaluation time with the built-in fetchers (builtins.fetchgit, builtins.fetchTarball, etc) and not provide a hash, which makes the expression "impure", which means the expression wouldn't be acceptable in nixpkgs and it has consequences for flakes.
Re:Nix and NixOS, my pain points by masklinn on Sunday December 25, 2022 @12:33PM (#34129135)
> It's a language, and thus the language has may expressions that result in the same outcome.

First it's a distribution and a package manager, and the guidance regarding these is sub-par. Especially with what there is of documentation being split between the old and new UIs, then being told about flakes but that they're experimental so it's not clear whether you should or should not use them.

I just went to the nix website, clicked "first steps with nix" and I get https://nixos.org/guides/ad-hoc-developer-environments.html

Is that useful? I'm sure to somebody who already knows what they want out of nix it is, but the first thing I'm told is that shell environments exist and are useful to "use the tool without having to install the software.". Ok, but what if I want to install the software? Then there's listing of what's essentially a magical invocation out of nowhere:

    $ nix-shell -p 'python38.withPackages (packages: [ packages.django ])'
I can understand that (or at least reach what I assume is an understanding), but there's no real explanation to give me knowledge to expand upon, if anything the explanations are worse than useless:

> We create an ad hoc environment with $PYTHONPATH set and python available, along with the django package.

thank you very much, that confirms I'd about interpreted the line correctly, but you've not told me what `withPackages` is or where `packages.django` comes out of so I'm not really helped.

And apparently the next step is "declarative and reproducible developer environments", or possibly "towards reproducibility: pinning Nixpkgs"? Or even better, "To quickly setup a Nix project read through Getting started Nix template", I have no clue what a nix project is or why I'd want one.

There's not just a step missing here, there's an entire floor, possibly building. It's like the nix community saw how git is taught and went "we can do worse".

Re:Nix and NixOS, my pain points by soraminazuki on Sunday December 25, 2022 @02:21PM (#34130254)
> Is that useful? I'm sure to somebody who already knows what they want out of nix it is, but the first thing I'm told is that shell environments exist and are useful to "use the tool without having to install the software.". Ok, but what if I want to install the software?

Why would you go to https://nixos.org/learn.html, click on an introductory example titled "Ad-hoc developer environments" and complain that it doesn't explain how to permanently install software?

> but there's no real explanation to give me knowledge to expand upon

Again, you're pointing to a page containing TLDR examples. That's not the right place for an in-depth explanation.

> There's not just a step missing here, there's an entire floor, possibly building. It's like the nix community saw how git is taught and went "we can do worse".

No surprise because you missed the entire manual.

Re:Nix and NixOS, my pain points by masklinn on Sunday December 25, 2022 @02:52PM (#34130578)
> Why would you go to https://nixos.org/learn.html, click on an introductory example titled "Ad-hoc developer environments" and complain that it doesn't explain how to permanently install software?

Because it's also the one labelled "First Steps with Nix". As in, the big orange button which immediately follows "Install Nix", and the second thing the Nix community apparently wants me to do to learn nix.

I literally did three things: I opened the nix website, I clicked "learn" (it's also what you get when you click "getting started" from the front page by the way), assumed I'd installed nix (I did check if there was seemingly critical information there, there isn't) then I clicked the following step.

I'm not quite sure what you'd want me to do.

> Again, you're pointing to a page containing TLDR examples. That's not the right place for an in-depth explanation.

I'm not asking for an in-depth explanation, I'm asking for pointers to the surface basics. The page tells me that "we’ll cover that in later tutorials" but I've no idea where those are, and none of the 5 links listed in the "next steps" seems helpful in any way. The least unpromising one ("Nix language basics") certainly didn't tell me anything about python.withPackages.

And again it's not "a page containing TLDR examples", it's what the website told me to start with.

> No surprise because you missed the entire manual.

The manuals which are at the bottom of the page (so one would assume the things to check after the one at the top of the page)?

And which are if anything even worse? The first one ("Nix Manual") goes directly from "you can upgrade packages" and "nix lets you rollback profiles" to "the nix language" to "advanced topics: remote builds".

I still have no answer to any of my question, but now I know that I can configure how many cores Nix will use when it builds derivations.

I still don't know what a nix project is or why I would want one, why I would want a derivation, though the manual does tell me they're important (why?)

Re:Nix and NixOS, my pain points by soraminazuki on Sunday December 25, 2022 @03:58PM (#34131164)
I still don't get why "first steps with Nix" has to include installing packages permanently. Making persistent changes is exactly the kind of thing that is better avoided before users have had the chance to learn anything.

> And again it's not "a page containing TLDR examples", it's what the website told me to start with.

So the website recommended you to read a page containing introductory examples. Not sure why you insist otherwise.

> And which are if anything even worse? The first one ("Nix Manual") goes directly from "you can upgrade packages" and "nix lets you rollback profiles" to "the nix language" to "advanced topics: remote builds".

What? The there are far more chapters in the Nix manual than just the three you mentioned.

Re:Nix and NixOS, my pain points by masklinn on Sunday December 25, 2022 @06:09PM (#34132492)
> I still don't get why "first steps with Nix" has to include installing packages permanently.

Because if I don't know nix (which, you know, would be why I'd be reading introductory material) I'd be looking to use it, and my basis would be to do would be the way every other distro works.

And if I have to type `nix-shell -p python38` every time I want to run Python and `nix-shell -p vimMinimal` every time I want to edit a file, the experiment is not going to last long.

> So the website recommended you to read a page containing introductory examples. Not sure why you insist otherwise.

I'm not "insisting otherwise", I'm observing that it's confusing, utterly useless, and provides no real guidance towards improvement. And it's where the site told me to go as my second step into nix.

But apparently you're perfectly happy that this is what the "first steps with nix" should be (after having berated me for going there), so... proving the point I guess.

> What? The there are far more chapters in the Nix manual than just the three you mentioned.

Have you actually looked at them? ever?

1 is a quick overview of the entire thing, none of it actually helpful.

2 is a few basic commands expanded upon in (4)

3 is a lot of time spent on installation details

4 is where the meat starts, "You can upgrade package" is 4.1, "profiles are a thing" is 4.2, 4.3 is "nix will eat your disk space" (useless to a beginner), 4.4 is "channels" (even worse), 4.5 is "sharing packages between machines" which could not be less useful at this point./

5 is, as I said, "the nix language" covering the basics, with 5.4 mentioning derivations and going into plenty of details, none of them actually useful or telling a beginner why they should care

Following which we reach 6.1 "remote builds.

From a beginner's perspective, tits on a bull are at least funny, the nix manual doesn't even have that going for it.

Have a nice day, I'm done wasting time on you.

Re:Nix and NixOS, my pain points by soraminazuki on Sunday December 25, 2022 @10:08PM (#34134136)
First of all ...

> after having berated me

Wow, I must be a terrible person, except I never recall berating you. I double checked, and it's just me expressing my disagreement. I'm not the one saying things like "It's like the nix community saw how git is taught and went 'we can do worse'" or "I'm done wasting time on you."

> Because if I don't know nix (which, you know, would be why I'd be reading introductory material) I'd be looking to use it, and my basis would be to do would be the way every other distro works.

Nix isn't a drop-in replacement of apt or yum. It's possible to use it like one, but that would be missing the whole point. Most of the benefits of Nix is obtained by writing configuration files tailored for each project you're working on. That's another reason why the examples don't start off with a replacement of "sudo apt install". Creating localized development environments is one of the primary use cases of Nix.

> Have you actually looked at them? ever?

Of course I did. I read the entire manual when I learned Nix. That's why I get the impression that your summary of the Nix manual makes it look more distorted than it actually is.

For example:

> 1 is a quick overview of the entire thing, none of it actually helpful.

The said overview includes instructions for installing packages permanently. You clearly stated that is what you were most interested in, so it actually should've been helpful for you.

Re:Nix and NixOS, my pain points by 40yearoldman on Monday December 26, 2022 @02:21AM (#34135529)
> First it's a distribution and a package manager

Nope, it's a language, and thinking of it as those things, even more so firstly is probably part of the struggle.

It's a language that you use to get your computer to do specific things. In this case, it might be a "package manager" and in the other case it could be a "distribution".

When you write go or rust to print "hello world" to the terminal you don't go around and call these things "printers", or "hello worlders".

It's a language, just like rust, go, php, bash, ed, awk, and brainfuck. Your first example even shows you using the language why proclaiming ahah! shell thing, or package manger! -> `'python38.withPackages (packages: [ packages.django ])'` is using this language to instruct the computer to do something. If you don't want to take the time to learn the language and understand its outputs, and want to just think "this is a package manager" then you are going to get lost.

Re:Nix and NixOS, my pain points by masklinn on Monday December 26, 2022 @03:32AM (#34135824)
> When you write go or rust to print "hello world" to the terminal you don't go around and call these things "printers", or "hello worlders".

That is the exact reverse of the relationship between Nix and Nix.

When I write in Go or Rust, a printer is a tool I might use to achieve a specific sub-part of my over-arching goal.

My goal is not writing nix programs, I've got better programming languages available for that. Nor are the nix OS or package managers utilities of nix. The relationship is the opposite: the nix language is a tool provided to manage software or distribution in order to actually do things.

> Your first example even shows you using the language why proclaiming ahah! shell thing, or package manger!

Aha yes, that well known language of whatever apt is, checkmate!

> If you don't want to take the time to learn the language

I don't even mind that, I'm pointing out that the official nix documentation I got from the official nix site following its own recommendation gave me something utterly unhelpful which neither helps me in furtherance of my goals, nor provide any obvious steps towards that.

Having learned that `python38.withPackages` is a function called with an other function `packages: [packages.django]` as parameter does not help me either.

> want to just think "this is a package manager" then you are going to get lost.

I guess I should remove nix then, since it's not a package manager and that's what I'm looking for?

You should maybe think of fixing the branding by the way, because some folks slander nix by calling it an OS, and there's pages talking about "nix: the package manager".

In fact that's literally the tagline of the primary manual:

> Nix Manual: Nix is a package manager which comes in a form of many command line tools.

> Introduction: Nix is a purely functional package manager.

Re:Nix and NixOS, my pain points by 40yearoldman on Wednesday December 28, 2022 @09:46PM (#34168863)
> My goal is not writing nix programs

That is your issue. This is a language to write "operating systems" and "packages" it is not really a "package manager".

You use different programs and libraries to work with different systems.

>I guess I should remove nix then, since it's not a package manager and that's what I'm looking for?

Yes, I think that is the flaw, it's a language, that lets you write code that produces an output.

Re:Nix and NixOS, my pain points by soraminazuki on Sunday December 25, 2022 @01:56PM (#34129963)
Nix actually has far better than average documentation compared to other typical open source projects. I started using Nix years ago on Ubuntu to quickly install a package that wasn't present in Ubuntu's repository. Eventually, I began customizing packages using Nix expressions. Before I knew it, I migrated my existing systems over to NixOS. What I can say is it wasn't at all the uphill struggle that's associated with Nix in online discussions. Even though the documentation isn't perfect and going through active improvements, there's a considerable gap between Nix's reputation regarding documentation and my own actual experience.

What surprises me is that people tout RPM/Chef as easier replacements to Nix/NixOS. The assumption about those being "replacements" of each other is questionable because they address different needs. What's even more questionable is the part about RPM or Chef being easy. I have dealt with those two for years as part of my day job, and they're both far from easy. I still have troubles with them to this day. Documentation is far more lacking than Nix, and it's not because things are obvious. If you encounter any trouble, you almost always have to dive into the source code. Navigating the source code of RPM or Chef is a nightmare because the code is scattered across countless different repositories and it's impossible to guess where to look for to begin with. Choice of programming languages doen't help here too. Chef is written in Ruby, which has a tendency of making code ungreppable due to its metaprogramming features. RPM has its own macro syntax which works similar to the C preprocessor. It's very terse and full of gotchas. Navigating around Nix code is much, much easier in comparison. Everything you need is in a single repo, https://github.com/NixOS/nixpkgs, and written in a JSON-like language.

Many people also claim that Nix is hard because it requires a functional programming background. That too doesn't match my experience. Nix expressions are basically JSON with functions. Learning the syntax is a non-issue if you know JSON and some common programming language constructs like conditionals, functions, map, filter and reduce. The only functional programming exposure I had prior to Nix was LISP, in a university classroom. Yet I didn't experience problems learning the syntax. The hard part is learning how to actually utilize the language. The documentation and some grepping around of the Nixpkgs codebase helped a lot with this.

Re:Nix and NixOS, my pain points by tsuujin on Sunday December 25, 2022 @02:25PM (#34130301)
My complaint is chiefly about practical implementation. “I want to use nix as a package manager across systems” is far too difficult for a new user.

One document tells you to flakes, another tells you that it’s experimental and should be avoided.

One document tells you that you should use Darwin modules and home manager, and then completely omits the fact that the linked home manager scripts don’t work with Darwin by design leading to “why the fuck isn’t this file they tell me should be auto generated not being created”.

Because the official docs don’t seem to cover real world use cases, you end up relying on a labyrinth of out of date and conflicting user contributed tutorials and it is very frustrating.

Once you know what to do nix is simple enough, but learning what to do is outright painful; if you don’t believe me look to the other replies to my comment.