From eb4f455cf1980b3a7377c5bd1b26dda75fa05054 Mon Sep 17 00:00:00 2001 From: Oren Rozen Date: Sat, 6 Jun 2020 16:36:35 -0500 Subject: [PATCH] add vscodeEnv to shell.nix --- .gitignore | 4 ++++ default.nix | 9 ++++----- shell.nix | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 9af4431..9800ac5 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,7 @@ cabal.project.local~ .HTF/ .ghc.environment.* .directory +.vscode-exts/ +.vscode-globalUserData/ +.vscode/ +mutable-extensions.nix diff --git a/default.nix b/default.nix index eab48a7..9cd0b1b 100644 --- a/default.nix +++ b/default.nix @@ -1,10 +1,9 @@ -let - ghcVersion = "ghc865"; - misoPkgs = import (builtins.fetchTarball { +{ ghcVersion ? "ghc865" +, misoPkgs ? import (builtins.fetchTarball { url = "https://github.com/dmjio/miso/archive/561ffad.tar.gz"; sha256 = "1wwzckz2qxb873wdkwqmx9gmh0wshcdxi7gjwkba0q51jnkfdi41"; - }) {}; -in + }) {} +}: with misoPkgs.pkgs; with haskell.packages."${ghcVersion}"; diff --git a/shell.nix b/shell.nix index 1ac6008..6ddfbf8 100644 --- a/shell.nix +++ b/shell.nix @@ -1,9 +1,43 @@ -let pkgs = import { }; -in (import ./.).env.overrideAttrs (_: { +{ ps ? import {} +, nixpkgs ? import (ps.fetchFromGitHub { + owner = "NixOS"; + repo = "nixpkgs"; + rev = "f75d62941d8ad616bfc334ae19d71a0a6677dd19"; + sha256 = "0n88r4fw1syad9zl7r40r7xlxwx38ni8s9hzyayxssr21ii2p38h"; +}) {} +, ghcVersion ? "ghc865" +}: +with nixpkgs; +let + drv = import ./. { inherit ghcVersion;}; + hie = + ((import (fetchTarball "https://github.com/infinisil/all-hies/tarball/master") {}) + .selection { selector = p: { ${ghcVersion} = p.${ghcVersion}; }; }); + +in +drv.env.overrideAttrs (shellEnv: { + buildInputs = shellEnv.buildInputs ++ [ + cabal2nix + hie + (vscode-utils.vscodeEnv { + #usually this path go to tmp but feel free to change it wherever you think it is good place to the "fake" global folder + #putting it on empty string will leave the default one. + user-data-dir = "./.vscode-globalUserData"; + #this file will be updated/created automaticly by vscode in result of using vscode GUI to install/uninstall extensions(can be changed manually to) + mutableExtensionsFile = ./mutable-extensions.nix; + #this extensions will be stored in the nix store and cannot be modified from vscode GUI + nixExtensions = [ + { name = "vscode-hie-server"; publisher = "alanz"; version = "0.0.40"; sha256 = "1cmlgidjma41s5zq5161gcxxmk5lfzcm8dvznls04y5l7q9b0gca"; } + { name = "language-haskell"; publisher = "justusadam"; version = "3.2.0"; sha256 = "190h1hky2yy5n00ncqf15mmaizgpm3w9pzvasmi2gangpg4qb6y5"; } + ]; + + # configuration for settings files- those will be overrides/create over the one in .vscode folder + # settings = {}; + # keybindings ={}; + }) + ]; + shellHook = '' - PATH="$PATH:${pkgs.ghc}/bin:${pkgs.cabal-install}/bin:${pkgs.nwjs-sdk}/bin:${pkgs.ghcid}/bin:${ - ((import - (fetchTarball "https://github.com/infinisil/all-hies/tarball/master") - { }).selection { selector = p: { inherit (p) ghc865; }; }) - }/bin"''; -}) \ No newline at end of file + echo 'to start editor with HIE run on the root of the folder: code .' + ''; +})