Skip to content

Instantly share code, notes, and snippets.

@purcell
Last active May 22, 2020 02:43
Show Gist options
  • Save purcell/e1be2eaf2b79b44b714b82b5b99ba49b to your computer and use it in GitHub Desktop.
Save purcell/e1be2eaf2b79b44b714b82b5b99ba49b to your computer and use it in GitHub Desktop.
shell.nix with nimlsp
let
# Assumes niv sources, which should include the repos for
# nimlsp, ast-pattern-matching and jsonschema.
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs {};
unpackedSource = d: d.overrideAttrs (orig: {
name = "${orig.pname}-source";
phases = ["unpackPhase" "patchPhase" "installPhase"];
installPhase = "mkdir $out; cp -aR . $out/.";
});
nimlsp = pkgs.stdenv.mkDerivation {
name = "nimlsp";
src = sources.nimlsp;
buildInputs = [ pkgs.nim ];
buildPhase = ''
mkdir -p $TMPDIR/.nimcache
mkdir -p $out/bin
nim c --nimcache:$TMPDIR/.nimcache \
-d:tempDir= \
-d:explicitSourcePath:${unpackedSource pkgs.nim} \
--path:${unpackedSource pkgs.nim}/nimsuggest \
--path:${sources.nim-ast-pattern-matching}/src \
--path:${sources.nim-jsonschema}/src \
-o:$out/bin/nimlsp src/nimlsp
rm -r $TMPDIR/.nimcache
'';
phases = ["unpackPhase" "buildPhase"];
};
in
pkgs.mkShell {
NIX_PATH = "nixpkgs=${sources.nixpkgs}";
buildInputs = [
pkgs.nixpkgs-fmt
pkgs.niv
pkgs.nim
nimlsp
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment