2022-06-19 01:42:12 +00:00
|
|
|
# deno2nix
|
|
|
|
|
|
|
|
[Nix](https://nixos.org/) support for [Deno](https://deno.land)
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
- lockfile -> `./lock.json`
|
|
|
|
- import map -> `./import_map.json`
|
|
|
|
- entrypoint -> `./mod.ts`
|
|
|
|
|
|
|
|
### Update `lock.json` for caching
|
|
|
|
|
|
|
|
```bash
|
|
|
|
deno cache --import-map=./import_map.json --lock lock.json --lock-write ./mod.ts
|
|
|
|
```
|
|
|
|
|
|
|
|
### Setup for nix flake (example)
|
|
|
|
|
|
|
|
```nix
|
|
|
|
{
|
2022-06-19 01:46:24 +00:00
|
|
|
inputs.deno2nix.url = "github:SnO2WMaN/deno2nix";
|
2022-06-19 01:42:12 +00:00
|
|
|
inputs.devshell.url = "github:numtide/devshell";
|
2022-09-09 19:06:41 +00:00
|
|
|
|
2022-06-19 01:42:12 +00:00
|
|
|
outputs = {
|
2022-09-09 19:06:41 +00:00
|
|
|
self,
|
|
|
|
nixpkgs,
|
2022-06-19 01:42:12 +00:00
|
|
|
flake-utils,
|
|
|
|
...
|
2022-09-09 19:06:41 +00:00
|
|
|
} @ inputs:
|
2022-06-19 01:42:12 +00:00
|
|
|
flake-utils.lib.eachDefaultSystem (system: let
|
2022-09-09 19:06:41 +00:00
|
|
|
inherit (pkgs) deno2nix;
|
2022-06-19 01:42:12 +00:00
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
2022-09-09 19:06:41 +00:00
|
|
|
overlays = with inputs; [
|
2022-06-19 01:42:12 +00:00
|
|
|
devshell.overlay
|
|
|
|
deno2nix.overlay
|
|
|
|
];
|
|
|
|
};
|
|
|
|
in {
|
2022-09-09 19:06:41 +00:00
|
|
|
packages.executable = deno2nix.mkExecutable {
|
|
|
|
pname = "example-executable";
|
|
|
|
version = "0.1.2";
|
|
|
|
|
|
|
|
src = ./.;
|
2022-06-19 01:42:12 +00:00
|
|
|
lockfile = ./lock.json;
|
2022-09-09 19:06:41 +00:00
|
|
|
|
|
|
|
output = "example";
|
|
|
|
entrypoint = "./mod.ts";
|
|
|
|
importMap = "./import_map.json";
|
2022-06-19 01:42:12 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### `deno2nix.mkExecutable`
|
|
|
|
|
|
|
|
#### Args
|
|
|
|
|
|
|
|
```nix
|
2022-09-09 19:06:41 +00:00
|
|
|
{
|
|
|
|
pname,
|
|
|
|
version,
|
|
|
|
src,
|
|
|
|
lockfile,
|
|
|
|
output ? pname, # generate binary name
|
|
|
|
entrypoint,
|
|
|
|
importMap ? null, # ex. "./import_map.json" to $src/${importMap}
|
|
|
|
additionalDenoFlags ? "", # ex. "--allow-net"
|
2022-06-19 01:42:12 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Thanks
|
|
|
|
|
|
|
|
- [esselius/nix-deno](https://github.com/esselius/nix-deno)
|
|
|
|
- Original
|
|
|
|
- [brecert/nix-deno](https://github.com/brecert/nix-deno)
|
|
|
|
- Fork of [esselius/nix-deno](https://github.com/esselius/nix-deno)
|