Skip to content

Commit

Permalink
nix: Run yarn with nodejs_12.x and fix tool deps in the shell
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Jun 8, 2021
1 parent aa8a1f4 commit b3f9382
Show file tree
Hide file tree
Showing 7 changed files with 2,570 additions and 2,516 deletions.
5 changes: 1 addition & 4 deletions default.nix
@@ -1,4 +1 @@
{
}:

let pkgs = import ./nix/pkgs.nix {}; in pkgs.packages
(import ./nix/pkgs.nix {}).packages
6 changes: 5 additions & 1 deletion nix/multisig-coordination-server.nix
Expand Up @@ -17,6 +17,8 @@ let
buildInputs = [ yarn nodejs ];
src = ( ./.. + srcDir);
buildCommand = ''
node --version
yarn --version
mkdir -p $out
cp -r $src/. $out/
cd $out
Expand All @@ -25,7 +27,8 @@ let
'';
};

in stdenv.mkDerivation {
in stdenv.mkDerivation rec {
name = "${pname}-${version}";
pname = packageJSON.name;
version = packageJSON.version;
inherit src;
Expand All @@ -49,4 +52,5 @@ in stdenv.mkDerivation {
EOF
chmod +x $out/bin/${packageJSON.name}
'';
passthru = { inherit nodejs yarn src; };
}
2 changes: 1 addition & 1 deletion nix/packages.nix
@@ -1,10 +1,10 @@
{ lib, pkgs }:

let
#nodePackages = pkgs.callPackage ./node-packages {};
packages = self: {
sources = import ./sources.nix;
nodejs = pkgs.nodejs-12_x;
yarn = pkgs.yarn.override { nodejs = self.nodejs; };
nix-inclusive = pkgs.callPackage "${self.sources.nix-inclusive}/inclusive.nix" {};
inherit (self.yarn-static.passthru) offlinecache;
multisig-coordination-server = self.callPackage ./multisig-coordination-server.nix {};
Expand Down
2 changes: 2 additions & 0 deletions nix/pkgs.nix
Expand Up @@ -4,6 +4,8 @@ let
iohkNix = import sources.iohk-nix {};
overlay = self: super: {
packages = self.callPackages ./packages.nix { };
iohkNix = import sources.iohk-nix {};
yarn2nix = self.yarn2nix-moretea.yarn2nix;
};
in
import iohkNix.nixpkgs { overlays = [ overlay ]; config = {}; }
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -56,7 +56,7 @@
"eslint-import-resolver-typescript": "2.0.0",
"eslint-plugin-filenames": "1.3.2",
"eslint-plugin-import": "2.19.1",
"eslint-plugin-jsdoc": "35.1.2",
"eslint-plugin-jsdoc": "35.1.3",
"eslint-plugin-prettier": "3.1.1",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-sonarjs": "0.5.0",
Expand Down
75 changes: 28 additions & 47 deletions shell.nix
@@ -1,64 +1,45 @@
# This file is used by nix-shell.
# It just takes the shell attribute from default.nix.
{ config ? {}
, sourcesOverride ? {}
, pkgs ? import ./nix/pkgs.nix {}
, sources ? import ./nix/sources.nix
, iohkNix ? import sources.iohk-nix {}
, yarn2nix ? pkgs.yarn2nix-moretea.yarn2nix
}:
# This file is used by nix-shell to provide a dev environment.
{ pkgs ? import ./nix/pkgs.nix {} }:

with pkgs;

let
# FIXME: make a Typescript shell
# This provides a development environment that can be used with nix-shell
shell = pkgs.mkShell {
name = "yarn-dev-shell";
bannerScript = writeShellScriptBin "banner" ''
echo "TS Dev - Nix" \
| ${figlet}/bin/figlet -f small -l \
| ${lolcat}/bin/lolcat
'';

helpScript = writeShellScriptBin "shell-help" ''
echo "Commands:
* yarn install - install dependencies locally
* npx run tsc - run typescript compiler
* niv update <package> - update nix dependencies
* shell-help - show this message
"
'';

shell = packages.multisig-coordination-server.overrideAttrs (old: {
name = "${old.pname}-shell";
src = null;

# These programs will be available inside the nix-shell.
buildInputs = [
buildInputs = old.buildInputs ++ [
yarn2nix # Generate nix expressions from a yarn.lock file
nix # Purely Functional Package Manager
iohkNix.niv # Dependency management for Nix projects
nodejs # Event-driven I/O framework for the V8 JavaScript engine
pkgconfig # Allows packages to find out information about other packages
tmux # Terminal multiplexer
nodePackages.typescript
git # Distributed version control system
yarn # Dependency management for javascript
bannerScript # Bling
helpScript # Info
];

shellHook = ''
echo "Typescript Dev Tools" \
| ${figlet}/bin/figlet -f banner -c \
| ${lolcat}/bin/lolcat
echo "NOTE: you may need to export GITHUB_TOKEN if you hit rate limits with niv"
echo "Commands:
* niv update <package> - update package
"
banner
shell-help
'';
};

devops = pkgs.stdenv.mkDerivation {
name = "devops-shell";
buildInputs = [
iohkNix.niv # Dependency management for Nix projects
];
shellHook = ''
echo "DevOps Tools" \
| ${figlet}/bin/figlet -f banner -c \
| ${lolcat}/bin/lolcat
echo "NOTE: you may need to export GITHUB_TOKEN if you hit rate limits with niv"
echo "Commands:
* niv update <package> - update package
"
'';
};
});

in

shell // { inherit devops; }
shell

0 comments on commit b3f9382

Please sign in to comment.