I’m very, very new to nix and nixOS both - I come from imperative workflows and very very rarely anything determinative, so this is all brand new to me.
As an example of the kind of thing I don’t understand how to do, let’s take an example repo I’ve been bouncing off: https://github.com/GideonWolfe/Chameleon
On a “normal” system, I can get pip and python ready, and then make install
and I’m off to the races.
With NixOS, I’ve got as far as adding python3 and gnumake to my configuration.nix packages. (I have also discovered that putting python in my system packages was the wrong move, so some advice on how better to go about this would be cool too.)
I can’t for the life of me wrap my head around what I’m supposed to do, and so many people online are using flakes but I’m on stable 23.11 (and quite daunted by flakes) so I’d prefer if this was from that POV.
Can anyone speak to any of these points? I’ve tried reading the docs but it’s very confusing for some reason.
Here are the basic steps though:
nix-shell
or add it straight to yourconfiguration.nix
I know it sounds a lot like , but a few pointers:
Derivation basics: This wiki page is the one that helped me understand the basics of derivations. It explains how to package stuff without extra tooling.
stdenv.mkDerivation
from nixpkgs adds a bunch of stuff, but the wiki linked doesn’t explain it (yet?). You might find more information elsewhere.There’s documentation for stdenv.mkDerivation and I apologize in advance for putting this evil upon you, but right now I don’t have any other useful bookmarks. I learned it the hard way, but if you can contribute to the https://nixlang.wiki with what you learned, you could make it easier for the next person.
As for
nix-shell
, once you’ve written yourdefault.nix
, you can wrap it in ashell.nix
and executenix-shell
in the same directory.default.nix
shell.nix
Then you can run
nix-shell
and see if your expected binary is inPATH
. Once that is confirmed, you can add your package to yourconfiguration.nix
Hopefully that helped a little.
Anti Commercial-AI license
Thank you deeply for such a thorough answer! If I make any discoveries that aren’t documented I will definitely try to contribute to the wiki.
Random question - my current setup is all done through
configuration.nix
. Do you think it would be wise at this stage to pivot to learning about flakes and using them instead (as the other comments have suggested, flakes appear to be the way to go), prior to introducing more complexity on my system (installing chameleon, etc)?I’m sorry, but I don’t use flakes, therefore my opinion on the topic should be taken with a grain of salt. To me they are unstable, the documentation worse than standard nix (which is bad enough IMO), and there a few pitfalls I’ve seen here and there that dissuade me from using it. However, there are people who swear by it 🤷
What I would recommend is to just try it out and see for yourself, then make the call. Maybe not straight away with your entire system, but you could try out some flakes project or something.
If you do want to start out with your system, then make a backup of
/etc/nixos/
, and write down somewhere which generation you’re currently on, so that you can always reboot and jump into a backup configuration.Whatever you learn with standard nix won’t be lost when/if you decide to use flakes.
Anti Commercial-AI license
Awesome advice, thanks again :)
Good luck :)