Skip to content

Instantly share code, notes, and snippets.

@StephenFluin
Created July 11, 2018 21:47
Show Gist options
  • Select an option

  • Save StephenFluin/0f06b4a575c7e08e556b78469e18e912 to your computer and use it in GitHub Desktop.

Select an option

Save StephenFluin/0f06b4a575c7e08e556b78469e18e912 to your computer and use it in GitHub Desktop.
Install Angular on a *nix system
# NVM
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install 10
# Yarn
curl -o- -L https://yarnpkg.com/install.sh | bash
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
yarn global add @angular/cli
@joriatyBen

joriatyBen commented Aug 25, 2020

Copy link
Copy Markdown

You could run it via nix-shell

with import <nixpkgs> {};
stdenv.mkDerivation rec {
  name = "ng";
  env = buildEnv { name = name; paths = buildInputs; };
  buildInputs = [
    nodejs-12_x
    yarn
    nodePackages."@angular/cli"
  ];
}

@sarisman84

Copy link
Copy Markdown

You could run it via nix-shell

with import <nixpkgs> {};
stdenv.mkDerivation rec {
  name = "ng";
  env = buildEnv { name = name; paths = buildInputs; };
  buildInputs = [
    nodejs-12_x
    yarn
    nodePackages."@angular/cli"
  ];
}

Not anymore, you cant

@joriatyBen

Copy link
Copy Markdown

your are right:

{
  description = "Angular something";

  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

  outputs = { self, nixpkgs }:
    let
      systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
      forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
    in {
      devShells = forAllSystems (pkgs: {
        default = pkgs.mkShell {
          packages = with pkgs; [
            nodejs_24
            yarn
            (writeShellScriptBin "ng" ''
              exec ${lib.getExe' nodejs_24 "npx"} --yes @angular/cli@22 "$@"
            '')
          ];
        };
      });
    };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment