Happy path to run
blaggacao opened this issue · 4 comments
- I've set up
packages.nix
- I've even set up the override (though the help message was impressive, it wasn't immediately clear where to put it [
lib.load
]) - I've done the prefetching, as well
- I've run
nix-build --max-jobs auto --out-link ./node_modules ./package.nix
- Now, how do I run the CLI in the repo:
# where to put overrides
{
tree = js2nix.load ./yarn.lock {
overlays = [
(self: super: {
"bespoke@1.2.0-dev" = super."bespoke@1.2.0-dev".override (x: {
src = x.src.override {
# Let Nix to recognise the type of archive so it unpacks it appropriately
name = "5dd91d76ba088119836f60f514dc0a0b8b30e78d.tgz";
sha256 ="1g7davl86xvbbfwirjj66xfbavv9ld9250bbni84wlcj0jmhy7xm";
};
});
})
];
};
}
Now, how do I run the CLI in the repo:
Hi @blaggacao, thanks for the question.
Do you want to use your "bespoke@1.2.0-dev"
available as an executable? Then you would go with something like:
with import <nixpkgs> { };
let
js2nix = callPackage (builtins.fetchGit {
url = "ssh://git@github.com/canva-public/js2nix.git";
ref = "main";
}) { };
tree = js2nix.load ./yarn.lock {
overlays = [
(self: super: {
"bespoke@1.2.0-dev" = super."bespoke@1.2.0-dev".override (x: {
src = x.src.override {
# Let Nix to recognise the type of archive so it unpacks it appropriately
name = "5dd91d76ba088119836f60f514dc0a0b8b30e78d.tgz";
sha256 ="1g7davl86xvbbfwirjj66xfbavv9ld9250bbni84wlcj0jmhy7xm";
};
});
})
];
};
in mkShell {
passsthru.bespoke = tree."bespoke@1.2.0-dev";
buildInputs = [
tree."bespoke@1.2.0-dev"
];
}
Assuming you have your binary in your package.json
file declared like this:
{
...
"bin": {
"bespoke": "./lib/bin/bespoke.js"
}
...
}
then you would just do one of the standard nix-provided options:
λ nix-shell ./package.nix --run 'bespoke --help'
λ nix-build ./package.nix -A bespoke && ./result/bin/bespoke --help
λ nix-env -i -f ./package.nix -A bespoke && bespoke --help
I hope that helps :-)
Oh, no, actually I was referring to the current package marp-cli
, of which bespoke
is a dependency. I think I checked, but afair, the current pacakages is maybe out of scope for the generated derivations, here? (Since this is a dev tool)
Ok, no worries. I created a minimal example of how to use js2nix
to expose executables from NPM
- https://gist.github.com/olebedev/3df80f4206e79c764d4376cd89c67a3e.
Let me know if you have any further questions.
Ah! That's the trick, just make it a dependency got ya. Thx!