Skip to content

Instantly share code, notes, and snippets.

@savannidgerinel
Created November 30, 2017 16:23
Show Gist options
  • Save savannidgerinel/b21c2d7de45b9a16c58409704677332a to your computer and use it in GitHub Desktop.
Save savannidgerinel/b21c2d7de45b9a16c58409704677332a to your computer and use it in GitHub Desktop.
{ pkgs ? import <nixos> {}
, fetchurl ? pkgs.fetchurl
, buildFHS ? pkgs.buildFHSUserEnv
, mkDerivation ? pkgs.stdenv.mkDerivation
}:
let
pkgUrl = "https://nodejs.org/dist/v8.4.0/node-v8.4.0-linux-x64.tar.xz";
pkgSha = "7fd86abad06f96cb2f889c2a0e25686a3de3e9a078ad946ded91ee4f28d8218a";
in rec {
node-env = mkDerivation {
name = "node-env";
src = fetchurl {
url = pkgUrl;
sha256 = pkgSha;
};
phases = [ "unpackPhase" "installPhase" ];
installPhase = ''
mkdir -p $out
cp -r * $out
'';
};
node = buildFHS {
name = "node";
targetPkgs = pkgs: [ node-env
pkgs.git
];
runScript = "node";
};
npm = buildFHS {
name = "npm";
targetPkgs = pkgs: [ node-env
pkgs.git
];
runScript = "npm";
};
}
let
pkgs = import <nixpkgs> {};
stdenv = pkgs.stdenv;
node = import ~/.nixpkgs/node6-env.nix { pkgs = pkgs; };
in stdenv.mkDerivation rec {
name = "node-working-shell";
buildInputs = [ node.node
node.npm
];
shellHook = ''
export PS1="[$name] \[$txtgrn\]\u@\h\[$txtwht\]:\[$bldpur\]\w \[$txtcyn\]\$git_branch\[$txtred
\]\$git_dirty \[$bldylw\]\$aws_env\[$txtrst\]\$ "
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment