21 Jun 2016, 02:52

NixOS Recipes - vscode backport to 16.03

vscode is the new IDE from Microsoft. It is currently in the NixOS master branch. However, it is not backported to 16.03 (nor should it be!). This is my backport, presented without much walkthrough.

Note: I’m currently using nixos-version: 16.03.948.a96c308 (Emu) .

Nix Commands

A series of Nix commands needed to be backported:

let
    # backport to 16.03, for makeSearchPathOutput
    getOutput = output: pkg:
      if pkg.outputUnspecified or false
        then pkg.${output} or pkg.out or pkg
        else pkg;

    # backport to 16.03
    makeSearchPathOutput = output: subDir: pkgs: lib.makeSearchPath subDir (map (getOutput output) pkgs);
in

These commands were found via trial-and-error, when nixos-rebuild would fail and then use ack to find the required function definition.

atom/env.nix

I had to backport atom/env.nix, with a change:

commit id: b07051c

3a4
> , makeSearchPathOutput
16c17
<   libPath64 = lib.makeSearchPathOutput "lib" "lib64" packages;
---
>   libPath64 = makeSearchPathOutput "lib" "lib64" packages;

This was copied to /etc/nixos/atom-env.nix

vscode/defaut.nix

vscode/default.nix was copied directly, unmodified, to /etc/nixos/vscode.nix

configuration.nix

The main configuration.nix file defines our required functions (getOutput, makeSearchPathOutput), imports the atomEnv package with the required functions and gconf (pulled from top-level/all-packages.nix), then include vscode with the given atomEnv.

{ config, pkgs, lib, ... }:
let

    # backport to 16.03, for makeSearchPathOutput
    getOutput = output: pkg:
      if pkg.outputUnspecified or false
        then pkg.${output} or pkg.out or pkg
        else pkg;

    # backport to 16.03
    makeSearchPathOutput = output: subDir: pkgs: lib.makeSearchPath subDir (map (getOutput output) pkgs);

    # backport to 16.03
    atomEnv = (pkgs.callPackage /etc/nixos/atom-env.nix) {
      gconf = pkgs.gnome.GConf;
      makeSearchPathOutput = makeSearchPathOutput;
    };

    # backport to 16.03
    vscode = (pkgs.callPackage /etc/nixos/vscode.nix) {
	  atomEnv = atomEnv;
    };
in
{
  environment.systemPackages = with pkgs; [
    ...
	vscode
  ];
}