HNHacker News
TopNewBestAskShowJobs

Arkh4m

62 karma · joined December 7, 2011

submissionscomments
Arkh4m··on Ditch your version manager
There is no need to literally fork the nixpkgs repo. Most language derivations were written with the idea of supporting multiple versions at the same time. In this guide (https://www.breakds.org/post/nix-shell-for-nodejs), the key example is this one:

    let pkgs = import <nixpkgs> {};

        buildNodejs = pkgs.callPackage <nixpkgs/pkgs/development/web/nodejs/nodejs.nix> {};
        
        nodejs-8 = buildNodejs {
          enableNpm = true;  # We need npm, do we?
          version = "8.17.0";
          sha256 = "1zzn7s9wpz1cr4vzrr8n6l1mvg6gdvcfm6f24h1ky9rb93drc3av";
        };
    in pkgs.mkShell rec {
      name = "webdev";

      buildInputs = with pkgs; [
        nodejs-8
        (yarn.override { nodejs = nodejs-8; })
      ];
    }

where we import the normal nixpkgs, then we use `callPackage` to re-use the code that was written by the Nix mantainers, and we specify our own version and SHA.

If the derivation hadn't been written to be reusable what you can do is to copy this whole directory https://github.com/NixOS/nixpkgs/tree/nixos-21.05/pkgs/devel... to your local project and import the nix files locally. In this case, some of the artifact might be missing from the nix cache and you might need to compile some from source. We do this in some cases and upload the artifacts to our private store on https://www.cachix.org so that no engineer has to recompile them again on their own computer.

Arkh4m··on Ditch your version manager
That's the point: without using Nix, you'd have to do LD_LIBRARY_PATH hacking to have two programs use two different versions of glibc. When people say "oh nix looks so complicated I can do this using bash scripts" I reply "well show me these beautifully expressive and simple bash scripts then".
Arkh4m··on Ditch your version manager
Then you'd have to learn to read Nix expressions. The original expression that builds all ruby versions is here: https://github.com/NixOS/nixpkgs/blob/6120ac5cd201f6cb593d1b... Here's an example that shows how to build a customized version for NodeJS https://www.breakds.org/post/nix-shell-for-nodejs
Arkh4m··on Ditch your version manager
Here is an example of doing what you want https://gist.github.com/Arkham/31297c1d75fc59f723a50063bc0f5...

I found the nixpkgs versions using this tool: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable...

Arkh4m··on Ditch your version manager
Here is an example if you absolutely want to pin Ruby to 2.6.7 while pulling all other packages from a more recent set of packages https://gist.github.com/Arkham/31297c1d75fc59f723a50063bc0f5...

I found the nixpkgs version using this tool: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable...

Arkh4m··on Ditch your version manager
Here's an example https://gist.github.com/Arkham/31297c1d75fc59f723a50063bc0f5...

I used this tool to find the specific nixpkgs version https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable...

Arkh4m··on Ditch your version manager
Here is an example if you absolutely want to pin Ruby to 2.6.7 while pulling all other packages from a more recent set of packages https://gist.github.com/Arkham/31297c1d75fc59f723a50063bc0f5...

I found the nixpkgs version using this tool: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable...

Note that Ruby 2.6.8 fixes three severe vulnerabilities present in Ruby 2.6.7, while being backward compatible, so I don't see why you'd want that.

Arkh4m··on Ditch your version manager
First, dependency manager vs package manager. Potayto potatoh.

Second. The reason I recommend direnv is because of ergonomics, so you don't have to remember to reload your shell. Most current version managers either do it themselves through shell hooks or ask you to install direnv. Point taken on using brew: I've changed it to use nix-env.

Third. Yep. Sort of like having to learn English before you can learn programming.

Fourth. As they say: start with the basics.

Fifth. No other package manager can freeze the complete dependency set you are using AND allow you to revert it exactly when things don't work. That's the power of declarative, reproducible builds: you try to update and it doesn't work? No problem, revert to the last working version and things are all good again.

Sixth. Ever tried updating a project using a Dockerfile that uses an old version of ubuntu? Then you can't find the packages anymore or no is building them anymore for the new version of Ubuntu and you have to pull random PPAs from the Internet to get things to work? In Nix, you can keep two pinned nixpkgs versions at the same time. In this way you can keep working on upgrading your project one working step at the time.

So yeah, it's not just cHeCKmATe FP-atheists sort of stuff.

Arkh4m··on Show HN: Tracqlist - The desire way to listen to music on Youtube
It looks great, very very polished. Congrats!
Arkh4m··on Redpomo: Redmine, Pomodoro technique and Todo-txt. Together.
I've tried this and it looks interesting; probably there are too many tools to install to get it working though, i.e. todo.txt looks a bit like garbage to me.
Arkh4m··on Wordless: stop writing Wordpress themes like it's 1998.
This looks really like what I needed, it looks awesome!