Best way to install pre-release versions of software

Hi! I want to install the pre-release (insiders) version of VS Code. What would be the most convenient way to do that?

Here’s the corresponding derivation from nixpkgs:

The best solution I have at the moment is to clone nixpkgs repository locally, edit that file to use version = "latest", "channel = "insiders", and then run nix-env -iA vscode -f ./path/to/local/repo. Is there a way to override those version/channel/hash without literally editing the file? Bonus point for a solution which does not require me to hunt for the hash on Microsoft’s web-site :slight_smile:

One way to achieve this would be to move the bindings from the let block into the function signature (and contribute this change upstream):

{ stdenv, lib, fetchurl, unzip, atomEnv, makeDesktopItem,
  gtk2, makeWrapper, libXScrnSaver, libxkbfile, libsecret
, version ? "1.25.1"
, channel ? "stable"
, sha256hashes ? { "i686-linux" = …; … }
}:
let plat = …; sha256 = sha256hashes.${plat};
…

Then you can install the expression vscode.override {channel = "insiders"; sha256hashes = {…};}.

1 Like

The issue is that the let .. in binding is creating a scope that is not reachable from the overrides so the only way to change these variables is by actually changing the source code by forking https://github.com/nixos/nixpkgs and then run nix-build -A vscode in the repo or nix-env -f . -iA vscode to install it to the current user profile.

Now looking at the source code, these variables are only used to compose the derivation that will be given to the vscode src attribute. So if you don’t want to fork nixpkgs another option would be to use pkgs.vscode.overrideDerivation { src = fetchurl { url = "..."; sha256 = "..."; }; } for your particular platform.

2 Likes

being able to override/overrideAttrs is one top advantage imo of nix. It’s always frustrating when not being able to override a derivation. Maybe we should run some script on nixpkgs to find and fix such derivations.

Hello,

I use this for vscode

{pkgs}:

with pkgs;

let

  version = "1.25.1";
  hie = (import ./hie.nix { inherit pkgs; });
  apps = with haskellPackages; with pythonPackages; [
        binutils.bintools
        cabal-install
        cabal2nix
        gcc
        ghc
        cabal-helper
        alsa-core
        gnumake
        hdevtools
        hie
        hoogle
        ipython
        perl
        stack
  ];
  plat = "linux-x64";
  channel = "stable";
  archive_fmt = if stdenv.system == "x86_64-darwin" then "zip" else "tar.gz";

in

  vscode.overrideDerivation (old: {
    name = "vscode-${version}";
    src = fetchurl {
      name = "VSCode_${version}_${plat}.${archive_fmt}";
      url = "https://vscode-update.azurewebsites.net/${version}/${plat}/${channel}";
      sha256 = "0f1lpwyxfchmbymzzxv97w9cy1z5pdljhwm49mc5v84aygmvnmjq";
    };
    postFixup = old.postFixup + ''
      wrapProgram $out/bin/code --prefix PATH : ${lib.makeBinPath apps}
    '';
  })

https://github.com/apeyroux/nixpkgs-config/blob/master/vscode.nix with this config.nix **

with import <nixpkgs> {};

{
  allowUnfree = true;
  packageOverrides = pkgs: rec {
    vscode = (import ./vscode.nix { inherit pkgs; });
    emacs = (import ./emacs.nix { inherit pkgs; });
    kitty = (import ./kitty.nix { inherit pkgs; });
  };
}

https://github.com/apeyroux/nixpkgs-config/blob/master/config.nix

Regards

Doing that right now (done!)! And what would be the right invocation to use those overrides with nix-env’s command line?

The following works:

λ nix-env -f . -i -E \
     'f: (f {}).vscode.override {channel="insiders"; version="latest"; }'

Is there anything simpler?

1 Like

For posterity, I ended up just adding the required override to my configuration.nix:

Still wish that I could do just nix-env -p vscodeInsiders --hash xxxxxxx somehow.