Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Mar 12, 2024
1 parent 7ddf858 commit 7cef84a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nix/fixture/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion nix/npm-package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@
let
rootPackageJson = builtins.fromJSON (builtins.readFile "${rootPath}/package.json");
packageJson = builtins.fromJSON (builtins.readFile "${workspacePath}/package.json");

# Substract the root path to the workspacePath to get the relative path between them.
# Eg:
# rootPath = /home/username/project
# workspacePath = /home/username/project/workspace
# And produce
# npmWorkspace = ./workspace
rootPathSplit = pkgs.strings.splitString "/" rootPath;
workspacePathSplit = pkgs.strings.splitString "/" workspacePath;
npmWorkspace = pkgs.lib.lists.sublist ((builtins.length workspacePathSplit) - (builtins.length rootPathSplit)) (builtins.length workspacePathSplit) workspacePathSplit;

builtNodeModules = pkgs.buildNpmPackage {
pname = packageJson.name;
version = "0.0.0";
src = rootPath;
npmWorkspace = workspacePath;
inherit npmWorkspace;
npmDeps = pkgs.importNpmLock {
npmRoot = rootPath;
};
Expand Down

0 comments on commit 7cef84a

Please sign in to comment.