I might regret asking this but -- is there a guide out there to nix for human beings?

I like the idea of nix in theory but every time I look at any nix documentation or configuration files my eyes glaze over after about 12 seconds and I give up.

(really what's happening is that I’m using a Mac right now, I miss Linux package managers, I'm mad at homebrew, I'm somewhat hopeful that nix can help me manage my packages more sanely, but I'm unwilling to spend a million hours learning nix)

the way I'm currently using nix is to:
1. just replace `brew install graphviz` with `nix-env -iA nixpkgs.graphviz`
2. put /Users/bork/.nix-profile/bin in my PATH
3. that's it

and it works pretty well but it's so different from the Correct Way to use nix that it's very hard to learn how to do new things like define my own custom packages

(no need to tell me this is Wrong Way to use nix, I promise I know that :))

@b0rk that is a correct way to use nix
@cadey @b0rk yep, there's nothing wrong about that! You might enjoy the lovely new guide to Nix from @determinatesystems https://zero-to-nix.com/
Zero to Nix

Your guide to learning Nix and flakes

@cadey @b0rk

That's how I've encouraged others to take it up, no need to complicate package management unless you have the want/need.

@newplagiarist @cadey thank you! it's actually super helpful to know that this is a normal thing to do, when I read about nix online all I ever see is people explaining why using nix-env in this way is Not The Nix Way
@b0rk @newplagiarist Do you want me to mint you a certificate that says you're using it correctly?

@b0rk @newplagiarist @cadey You lose the reproducibility and immutability offered by other workflows, but if you don't need those, don't have to care about them.

The purists often make this kind of good tool a hassle. A brick is enough to drive a nail into a wall, but the hammer crowd is lurking at you.

@karitham
As someone frequently on the purist end of the spectrum, I'll keep this wonderful metaphor in mind.
@b0rk @newplagiarist @cadey
@b0rk @newplagiarist @cadey it's certainly the right way to use Nix, perhaps you don't get all the benefits but it comes at a much smaller cost then the other ways (said learning curve). It's also probably the one documented the most.
@b0rk people have been bit by some of the wharts of it which is why https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-profile.html was added that has also easier to remember. Others simply prefer more declarative alternatives because they can be committed to dotfiles and replicated on a different machine.
nix profile - Nix Reference Manual

@b0rk
The idea of there being "the correct way" is extremely overrated. I'd go as far as to say that Nix is best used erratically
@b0rk Same here! Maaaybe sometime I will learn how to create flakes and derivations and how everything fits together, but for now nix as a brew replacement (along with modest use of nix-shell for ephemeral installs) is pretty good!

@b0rk That’s perfectly fine, IMO. There are many ways to use Nix.

I personally like to just not install things as much as possible, and use `nix run nixpkgs#graphviz` or `nix-shell -p graphviz`.

@b0rk i started like that then added some shell.nix in some projects

@b0rk I've contributed packages to nixpkgs and what you're doing is pretty much how I use nix on my Mac.

There may exist a wrong way to use nix, but I don't think you've found it.

@b0rk if you take a look let us know what you think! We’ve heard a lot of good feedback, and have worked pretty hard to take it to the next level. More material coming soon… maybe we could collab on something :).

@grahamc

@b0rk Seems like a legit way to use Nix to me! (Tiny tip: you can often do ‘nix-env -i graphviz’, saving a little typing.)
@b0rk I enjoyed this video series which was my introduction to nix: https://youtube.com/playlist?list=PLRGI9KQ3_HP_OFRG6R-p4iFgMSK1t5BHs
Nixology

A series of videos I've been releasing within Shopify to help promote and educate about Nix. I eventually realized that very little of this is Shopify-specif...

YouTube
@b0rk Your usage is 100% valid. `nix-channel --update &&
nix-env --upgrade` is the only other command I'd throw in there every so often (similar to `apt-get update && apt-get upgrade`).

@b0rk I think it depends on how deep down the rabbit hole you want to go.

I’d argue the Next Step would probably be playing around with home manager, but you definitely don’t have to. Especially if all you want is to install packages and be done with it.

GitHub - nix-community/home-manager: Manage a user environment using Nix [maintainer=@khaneliman, @rycee]

Manage a user environment using Nix [maintainer=@khaneliman, @rycee] - GitHub - nix-community/home-manager: Manage a user environment using Nix [maintainer=@khaneliman, @rycee]

GitHub
@b0rk actually there is probably some in between step where you make a file that lists the packages you want installed, but I’ll be honest I skipped that one.
@b0rk this is fine and good. I've done the same before on Linux when I wanted to get a very recent version of something without having to upgrade away from an LTS version of some distro I was using.

@b0rk That is pretty much the way I use it.

For me after I got that sorted out I started to use:

(1) Home Manager, only to install packages (not to manage my dotfiles) and
(2) shell.nix , this is an example for a Ruby on Rails app: https://gist.github.com/dmitryrck/b2efe3b65bd222dd70d5c8d23417948f (basically you create the shell.nix and then run nix-shell to get inside a "sandbox")

shell.nix for ruby projects

shell.nix for ruby projects. GitHub Gist: instantly share code, notes, and snippets.

Gist

@b0rk I am using macOS and Linux, and I install the same tooling on both and in the same way.

On macOS I only have XCode and Nix (no homebrew) and on Linux the dev tools (build-essential) and Nix as well.

@b0rk I think there are a lot of ways to ‘Nix. I just do a lot of searches, the “nix by example” series covers a lot of areas, also reading the existing packages you can pick up some tips. Hope it helps.
@b0rk I haven't done it myself, but lobste.rs liked this one: https://zero-to-nix.com/
Zero to Nix

Your guide to learning Nix and flakes

@jjasghar @b0rk seconded, and it is (correctly) pro-flakes in content

@b0rk Nix will be helpful but it's hell.

Flakes are nicer than what we had before but the docs are non-existent and writing anything yourself is impossible. I've been daily driving nix for a year and I still can't write anything other than slightly editing existing config or copying other's.

Language was not made to be read or written and that's a pain. Docs are terrible too and there's no way around it.

Nix pills are the best part of the docs, so you should start there if you are new to it.

@karitham This is precisely why I'm trying _really_ hard to make Guix work. it doesn't have the breadth of support that Nix does - but the docs are pretty good and I can easily write my own file/configuration.

But Nix keeps calling to me with it's the less restrictive definition of what a package is and bigger community. (And MacOS support)

@b0rk this might be a good site https://zero-to-nix.com/ didn’t read it yet so I can’t comment on it
Zero to Nix

Your guide to learning Nix and flakes

@zaherg @b0rk agree this is a nice start to get your feet wet
@b0rk I’m due to learn it as well and I’ve been eyeing the docs and new installer from Determinate Systems here: https://zero-to-nix.com/start
Zero to Nix

Your guide to learning Nix and flakes

Zero to Nix
@b0rk Have you tried macports on macOS? I find it's much more well-behaved
@ranvel I haven't! i'll take a look

@ranvel @b0rk Seconded. It's the original package manager and it's better in a few ways: https://www.reddit.com/r/MacOS/comments/108v3y7/homebrew_appreciation_post_best_package_manager/j3wcblk/ (not my post). One immediate difference is that "port install" requires sudo. Maybe that's why so many users seem to prefer homebrew...? Of course it's actually needed because macports is more diligent about permissions. #macports #homebrew

Edit: sorry, I compared it to Homebrew because I don't know nix.

Homebrew appreciation post - best package manager for Mac

Gonna have to disagree here! Homebrew is a very troublesome package manager, and anyone who has experience with other package managers (which...

reddit
@ranvel @b0rk I moved from #Fink to #MacPorts to #Homebrew over the years and even contributed packages for the latter two. Here are my reasons for not using MacPorts:
• sudo for everything
• no third-party software repos
• no support for #Mac apps or other native packages, only command line and X11 apps
• no extensibility (e.g., https://github.com/whalebrew/whalebrew for #Docker images, https://github.com/homebrew/homebrew-bundle for repeatable installs of packages, casks, #Whalebrew images, and #AppStore apps on a new system)
GitHub - whalebrew/whalebrew: Homebrew, but with Docker images

Homebrew, but with Docker images. Contribute to whalebrew/whalebrew development by creating an account on GitHub.

GitHub
@ranvel @b0rk Some say #MacPorts insistence on sudo is a feature because plain users should not be able to install software, especially when added to one’s default PATH. In practice, both MacPorts and #Homebrew’s package files are in full scripting languages ( #Tcl and #Ruby, respectively), so with MacPorts you’re handing over the keys to the kingdom to whomever last updated a portfile.
@ranvel @b0rk And #Homebrew’s /opt/homebrew (on Apple silicon) is typically only owned and writable by the user that installed it, so IMHO it’s sufficiently restricted.
@ranvel @b0rk And that’s the strange thing: with macOS X, some folks just enhanced the Debian package manager and quickly built a distribution that worked quite good (fink). But Apple didn’t support it. The supported macports, that came from the BSD port package manager. I still find it the most useable alternative because it is really stable and behaves like a Unix package manager. 1/
@ranvel @b0rk But you don’t always get the newest upstream package versions with macports. That seems to be why people moved to homebrew. To me it seems, brew breaks well-established and meaningful Unix principles by design. It’s like some JavaScript kids have just decided to build a package manager because, well better re-invent everything, right? So I use both in parallel: if I really cannot something I need from macports, I‘ll install the brew package. Works pretty solid for years now.
Getting Started with Nix — nix-tutorial documentation

@b0rk Initially read this as “is there a guide out there to nix human beings?”
@b0rk I tried nix on macos and also gave up. https://www.macports.org is an option you should try out. It's not as extensive of a port list as brew but it works a lot more like a true ports system from linux.
The MacPorts Project -- Home

The MacPorts Project is an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, X11 or Aqua based open-source software on the Mac OS X operating system.

@b0rk As of about a month ago, yes! https://zero-to-nix.com/

I also recently saw this collection of nix guides and stuff: https://tinkering.xyz/nix-docs/

Zero to Nix

Your guide to learning Nix and flakes

@b0rk I'm looking at this too right now. Being on OSX when you're used to Linux feels very constrained.

https://zero-to-nix.com/ seems nice so far.

Zero to Nix

Your guide to learning Nix and flakes

@mhoye @b0rk @NireBryce ironically I think I’m your polar opposites in that Linux hurts and I want to go back to pre-SIP osx.

That said, I keep meaning to try this, which as a person coming from being a Macports maintainer and a homebrew user feels like “enough”. Shared in the event it is helpful: https://wickedchicken.github.io/post/macos-nix-setup/

MacOS Nix Setup (an alternative to Homebrew)

I recently got a new Macbook, and began setting up the Nix package manager to install my developer toolset. I mainly did this to try and have a working setup without installing Homebrew. Since I ran into a few issues, I wanted to briefly document what I did and why in case others wanted to try the same. Why Nix? (and why not Homebrew or MacPorts?) The short answer: hype.

@b0rk out of curiosity why are you mad at homebrew? i have the same reaction to nix, i want to love it, i want to get it.

of note this was released approx today https://determinate.systems/posts/determinate-nix-installer

Introducing the Determinate Nix Installer · Determinate Systems

A fresh new alternative to the official Nix installation scripts.

Determinate Systems
Nix journey part 0: Learning and reference materials

In this series I'll be documenting my journey learning Nix and this first installment is more of a prequel. A common complaint when learning Nix is that the documentation "is not good", and I think what people mean by that is that the documentation is spread across several sources which may or may not be easy to find, or that there is no explanation at all in official documentation. This post is a collection of both official and unofficial resources.

Tinkering

@joshbuddy @b0rk

Over the years, my attempts to not use #homebrew have always failed and I still stick to it.

To my knowledge, its the best solution to install packages and also applications ("casks"), but also to remove them (as when you need to have adobe reader / fox reader /... for reading one single file, but that you really want to get read of it afterwards)

@b0rk I have https://zero-to-nix.com/ on my todo reading list. I picked up the link from some recommedation.
Zero to Nix

Your guide to learning Nix and flakes

@b0rk I literally just started a series about this today :)

https://tinkering.xyz/nix-docs/

Nix journey part 0: Learning and reference materials

In this series I'll be documenting my journey learning Nix and this first installment is more of a prequel. A common complaint when learning Nix is that the documentation "is not good", and I think what people mean by that is that the documentation is spread across several sources which may or may not be easy to find, or that there is no explanation at all in official documentation. This post is a collection of both official and unofficial resources.

Tinkering
@b0rk https://zero-to-nix.com/ is on my reading list...
Zero to Nix

Your guide to learning Nix and flakes

@b0rk You may wish to enquire with @wimpy on this, he recently started working with https://determinate.systems , and mentioned https://zero-to-nix.com on a recent episode of the 'Linux Downtime' podcast.
Determinate Systems

Determinate Systems
@b0rk I wrote up my initial learning notes in case it's useful (with a bunch of links to where to learn more): https://www.zombiezen.com/blog/2021/12/nix-from-the-ground-up/
Nix From the Ground Up

A hands-on guide to the concepts behind Nix

@b0rk I’m in the same boat… can anybody recommend https://floxdev.com or https://devenv.sh or something like it?
flox | Environments with wings

Manage and share development environments, package your projects for others, and publish artifacts anywhere. Harness the power of Nix.

flox
@b0rk If you figure out how to replace homebre with nix I will be eagerly waiting for the blog post. As I have had similar experiences trying to learn nix

@b0rk I've been asking the same question the last few days!

I just came across https://tinkering.xyz/nix-docs/ which led me to https://ianthehenry.com/posts/how-to-learn-nix/ which is a really good read so far.

The tinkering.xyz post describes it as “This isn't so much a tutorial as it is one person's descent into madness while learning Nix. It's not a tutorial teaching you how to use Nix, it's one person's stream-of-consciousness as they learn Nix, and it's really refreshing." which is just perfect.

Nix journey part 0: Learning and reference materials

In this series I'll be documenting my journey learning Nix and this first installment is more of a prequel. A common complaint when learning Nix is that the documentation "is not good", and I think what people mean by that is that the documentation is spread across several sources which may or may not be easy to find, or that there is no explanation at all in official documentation. This post is a collection of both official and unofficial resources.

Tinkering
@b0rk Any details about why you're mad at homebrew? Warnings for the rest of us?

@b0rk
Never tried Mac, but I'd probably just run the official installer and then set up home-manager, because I find -iA very confusing

Didn't try 0toNix but people say it's promising

Hope you find your way

@b0rk
Also, there's a very welcoming (IMO) community in matrix and on discourse. At least for me, just asking people helps a bunch not to get overwhelmed