Skip to content

Commit

Permalink
Automatically load node modules in devshell
Browse files Browse the repository at this point in the history
  • Loading branch information
robbevp committed Nov 25, 2023
1 parent 032f4fd commit 25ed4cf
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,43 @@
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; overlays = [ devshell.overlays.default ]; };
in
{
packages = rec {
default = accentor-web;
accentor-web = pkgs.mkYarnPackage rec {
pname = "accentor-web";
version = "0.32.0";
web-package = pkgs.mkYarnPackage {
pname = "accentor-web";
version = "0.32.0";

src = pkgs.lib.cleanSourceWith { filter = name: type: !(builtins.elem name [ ".github" "flake.lock" "flake.nix" ]); src = ./.; name = "source"; };
packageJSON = ./package.json;
yarnLock = ./yarn.lock;
yarnNix = ./yarn.nix;
src = pkgs.lib.cleanSourceWith { filter = name: type: !(builtins.elem name [ ".github" "flake.lock" "flake.nix" ]); src = ./.; name = "source"; };
packageJSON = ./package.json;
yarnLock = ./yarn.lock;
yarnNix = ./yarn.nix;

# Otherwise this tries to write to read-only paths, and caching is unnecessary anyway.
SKIP_CACHE = "true";
buildPhase = ''
cp deps/accentor/postcss.config.js .
yarn run build
'';
# Otherwise this tries to write to read-only paths, and caching is unnecessary anyway.
SKIP_CACHE = "true";
buildPhase = ''
cp deps/accentor/postcss.config.js .
yarn run build
'';

installPhase = ''
cp -r deps/accentor/dist $out
rm $out/**/*.map
'';
installPhase = ''
cp -r deps/accentor/dist $out
rm $out/**/*.map
'';

distPhase = "true";
};
distPhase = "true";
};
in
{
packages = {
default = web-package;
accentor-web = web-package;
};

devShells = rec {
default = accentor-web;
accentor-web = pkgs.devshell.mkShell {
name = "Accentor Web";
devshell.startup.link-node-modules.text = ''
ln -sf ${web-package.deps}/node_modules $PRJ_ROOT/node_modules
'';
packages = with pkgs; [
nixpkgs-fmt
yarn2nix
Expand Down

0 comments on commit 25ed4cf

Please sign in to comment.