News for hackers. Stuff that matters.
Re:What Is Nix? by takeda on Wednesday May 20, 2020 @08:12PM (#23253533)
You can use Nix on MacOS X and with nix you don't need brew.

I used it for few years that way.

If you use nix-darwin + home-manager you can also configure your mac the way you would NixOS.

Amazing tools that discovered not long ago (they aren't specific to os x) is:

niv - makes pinning to specific repos/versions in repos much easier which helps with reproducibility, especially pinning of nixpkgs version which is now controlled in your source code.

direnv + lorri - you no longer need to invoke nix-shell just cd the directory and all tooling you need for your project is suddenly available which is AWESOME.

Here's an example of using them together with packaging a python project[1] if you have lorri and direnv installed and cd to the directory, not only you have the right python version installed but also all dependencies and even the "hello" command becomes available, as if you installed it through `pip -e .`

[1] https://github.com/takeda/example_python_project

Re:What Is Nix? by tomberek on Wednesday May 20, 2020 @09:04PM (#23253835)
I've had luck with using the approach in here https://nixos.wiki/wiki/Python#Emulating_virtualenv_with_nix... because it allows the escape hatch of using pip if something isn't packaged and I want to quickly try something out. I have also been meaning to try mach-nix which may obviate the need for pip at all. Having a good standard skeleton for a python/nix project would be super helpful to add to the wiki, etc.
Re:What Is Nix? by takeda on Thursday May 21, 2020 @12:08PM (#23260200)
I tried multiple solutions myself, this one is the closest to what I want, because:

- overlays the packages on top of nixpkgs - understands setup.cfg and can get dependencies from it

It is still not perfect, but when I find some time I think to submit a PR to nixpkgs to improve setupcfg2nix. Particularly it doesn't understand tests_require which you can list dependencies to run unit tests. Nix has equivalent checkDepends.

Re:What Is Nix? by jdlshore on Wednesday May 20, 2020 @08:57PM (#23253788)
Unfortunately, the security updates introduced in MacOS Catalina have made installing Nix on the latest version of MacOS a fairly involved process.[1] I looked at using it when I rebuilt my computer recently and decided to wait until it was more baked.

[1] Catalina restricts which directories can be added to the root dir. Nix uses /nix.

Re:What Is Nix? by endgame on Wednesday May 20, 2020 @09:18PM (#23253925)
There is a way to deal with the latest round of developer-hostile changes from Apple:

https://github.com/NixOS/nix/issues/2925#issuecomment-604501... documents the workaround but if you don't have a direct link it's almost impossible to find because GitHub's UI is terrible.

Re:What Is Nix? by foldr on Thursday May 21, 2020 @03:46AM (#23255827)
The problem here really seems to be with nix. The /nix path shouldn't be hard coded. (Security concerns aside, I don't want a package manager to clutter up my root directory.)
Re:What Is Nix? by casept on Thursday May 21, 2020 @04:22AM (#23256035)
It's necessary to hardcode paths in order to ensure that the exact version of a dependency is linked into the executable. Without this mechanism, nix packages would not be reproducible and self-contained.

Also, the path isn't really hardcoded. You can use a custom path, but that means you can't use binary caches.

Re:What Is Nix? by foldr on Thursday May 21, 2020 @05:11AM (#23256343)
I'm sure there are reasons for it, but it still sucks.

It ought to be possible to use binary caches and still swap out the path. (Modifying a string in an ELF executable isn't that hard.)

Re:What Is Nix? by catern on Thursday May 21, 2020 @10:45AM (#23258972)
It's not just ELF executables that hardcode the path. There's a ton of different ways to run software which all use hardcoded paths. Which is good! That's the entire value proposition of Nix, in a way, that it's now safe to use hardcoded paths. But you can't edit all those different hardcoded paths in all those different filetypes.
Re:What Is Nix? by foldr on Friday May 22, 2020 @04:57AM (#23269995)
Where else are paths hardcoded? This seems like a huge mess.
Re:What Is Nix? by catern on Friday May 22, 2020 @04:59PM (#23276941)
Just picking one example off the top of my head, pkg-config files.
Re:What Is Nix? by bennofs on Thursday May 21, 2020 @05:59AM (#23256597)
Modifying a string in ELF is hard. As long as the string has the same length as the original one, it has a good chance to work (but still fails for compressed data). But if you want an arbitrary directory, you need to replace it with a different length path, and that will probably break a lot of things.
Re:What Is Nix? by takeda on Thursday May 21, 2020 @12:00PM (#23260071)
The nix author created utility called patchelf which is used by nix all the time during the build (to rewrite library paths).

As far as I know it creates a new elf each time it is called (it doesn't modify a file on place) so the length of library name is not an issue.

Re:What Is Nix? by foldr on Thursday May 21, 2020 @07:01AM (#23256943)
It's not that hard if you leave some spare space for string constants in the .rodata section. Nix already patches ELF executables as things stand.
Re:What Is Nix? by ris on Thursday May 21, 2020 @06:03AM (#23256624)
The problem is how it affects all the hashes, which aren't recalculable in such an easy way.
Re:What Is Nix? by foldr on Thursday May 21, 2020 @07:00AM (#23256938)
Could you not check the hashes before doing the substitution?
Re:What Is Nix? by autojoechen on Saturday May 23, 2020 @01:07PM (#23284571)
Re:What Is Nix? by fiddlerwoaroof on Wednesday May 20, 2020 @08:23PM (#23253598)
This is only sort of true: I’ve found that Nix on a Mac is great except that about 10% of the derivations just don’t work: some are excluded explicitly as broken and some just fail in strange ways and need lots of debugging.
Re:What Is Nix? by takeda on Thursday May 21, 2020 @12:35PM (#23260672)
For me, most of packages worked, the ones that didn't were actually justified to not work, definitively far more than 10% (it was more like 90% for me). The stuff that didn't work was justifiably linux specific, except one thing, that now memory escapes me what it was.