News for hackers. Stuff that matters.
Re:Ask HN: Best Alternative to Homebrew in 2021? by chriswarbo on Tuesday November 02, 2021 @10:59AM (#29082243)
> I think the problem with Nix is that it is actually not a package manager but a build tool (that provides some package management utilities). People try Nix with the assumption that it should be as easy as apt-get (for example), but found tutorials with a block of code in a weird language...

Indeed, I've been using Nix for many years (on Ubuntu, NixOS and macOS), and I now find the apt-get style 'considered harmful'.

Instead, I define a single Nix derivation ("package") which provides everything I want in its 'bin/' directory, e.g.

    with nixpkgs;
    buildEnv {
      name = "my-macbook-programs";
      paths = [ bash gimp /* etc */ ];
    }
The nix-build command creates a symlink called `result`, so I put `/path/to/my/git/repo/result/bin` in my $PATH.
Re:Ask HN: Best Alternative to Homebrew in 2021? by pca006132 on Tuesday November 02, 2021 @11:11AM (#29082420)
Just wondering, what is the benefit of doing this over nix-env for system-wide applications?

For project specific environments, I usually use `shell.nix` (maybe I should switch to flakes now) together with direnv that runs nix-shell automatically when you enter the directory.

For beginners to Nix, I think they should do the transition gradually, there are so many concepts in Nix that may be unfamiliar to them. I think getting a system to work quickly (maybe in a not so idiomatic way) is more encouraging than asking them to read Nix Pills and understand how packaging works in Nix :)

Re:Ask HN: Best Alternative to Homebrew in 2021? by chriswarbo on Tuesday November 02, 2021 @12:13PM (#29083337)
`nix-env` is an imperative command, whilst writing a .nix file is declarative. In particular, the latter can be managed using git, e.g. here's mine: https://github.com/chriswarbo/dotfiles/blob/41c5c4643845f437...

That's actually over-complicated, since I used to use nix-darwin and haven't bothered to un-pick it yet.

Re:Ask HN: Best Alternative to Homebrew in 2021? by rgoulter on Tuesday November 02, 2021 @07:07PM (#29088737)
You could use nix-env to install the file with `nix-env --install --file default.nix` rather than using nix-build + symlinking the result.

What are the advantages of just nix-build, and adding the result/bin/ to path? Arguably, `nix-env --install` modifies the underlying profiles which manage symlinks. (nix-build + add to PATH is imperative invocation; but `nix-env --install` is and imperative invocation with a stateful effect).

e.g. of "how could that be bad?". I'd managed to get myself into a confusing state with `nix-env --install`. When setting up NixOS, I'd installed firefox as the root user. Months later, in my normal user account, I was confused why such an old firefox was installed (since my profile didn't install firefox). I can't remember exactly, but this also somehow caused problems with fontconfig. -- Probably easily avoidable; but if you don't know what you were doing, you might also try all sorts of install commands and forget.

Re:Ask HN: Best Alternative to Homebrew in 2021? by pxc on Tuesday November 02, 2021 @10:04PM (#29090278)
`which -a` and `realpath` are your best friend when you're dealing with a multiuser package manager! Together, they make it easy to figure out if a package comes from your user profile, the default imperative profile, the system profile, or a transient shell profile