-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
8,113 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
use flake | ||
nix build --out-link $(direnv_layout_dir)/devEnv .#devEnv | ||
ls -t .direnv | grep -P '^flake-profile-.*-link$' | tail --lines=+5 | xargs --no-run-if-empty -I{} rm "$(direnv_layout_dir)/{}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: builder | ||
on: [push, pull_request] | ||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Nix Setup | ||
run: | | ||
set -x | ||
sudo mkdir /nix | ||
sudo chown $USER /nix | ||
mkdir -p $HOME/.config/nix | ||
echo 'experimental-features = nix-command flakes' > $HOME/.config/nix/nix.conf | ||
- name: Cache Nix DevEnv | ||
uses: actions/cache@v4 | ||
env: | ||
cache-name: cache-nix-dev-env | ||
with: | ||
path: | | ||
/nix | ||
/home/runner/.bash_profile | ||
/home/runner/.nix-profile | ||
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/flake.nix', '**/flake.lock') }} | ||
|
||
- name: Build | ||
run: | | ||
[ -f /home/runner/.nix-profile/etc/profile.d/nix.sh ] || sh <(curl -L https://nixos.org/nix/install) --no-daemon | ||
. /home/runner/.nix-profile/etc/profile.d/nix.sh | ||
eval "$(nix print-dev-env)" | ||
parallel --line-buffer --ctagstring "{}>\033[0m" scripts/{} ::: \ | ||
check-nix-pkg.sh \ | ||
check-npm-deps-hash.sh \ | ||
check-npm.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/.direnv | ||
/dist | ||
/coverage | ||
/node_modules | ||
tsconfig.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/.direnv | ||
/node_modules | ||
/dist | ||
package-lock.json | ||
/.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# First-time dev env set up | ||
|
||
## Shell | ||
|
||
1. Install the nix package manager: | ||
https://nixos.org/manual/nix/stable/installation/installation.html | ||
|
||
2. Install direnv: https://direnv.net/ | ||
|
||
Once you enter this directory in your shell, the NodeJS tooling should be | ||
automatically set up. You can verify this with: | ||
|
||
```bash | ||
# This should match the version specified in `rust-toolchain.toml` | ||
npm --version | ||
``` | ||
|
||
## Editor | ||
|
||
You must follow the "Shell" instructions above to make sure the `.direnv` | ||
folder is populated. After that all the needed tooling will be in the `PATH`. | ||
|
||
### VSCode | ||
|
||
Install the [direnv vscode extension](https://github.com/direnv/direnv-vscode). | ||
|
||
# Building & Testing | ||
|
||
```bash | ||
# Building: | ||
# This will build TypeScript srouces from `src/*.ts` and place the resulting files into the `dist` folder | ||
npm run build | ||
# Same as `build`, but will watch changes in the `src` folder and continuously update the `dist` folder. | ||
npm run build-watch | ||
|
||
# Testing: | ||
# This runs all tests once | ||
npm run test | ||
# This runs tests continuously every time sources in the `src` folder change | ||
npm run test-watch | ||
|
||
# Formatting: | ||
npm run fmt | ||
``` | ||
|
||
# Debugging | ||
|
||
1. Use the `Debug: JavaScript Debug Terminal` action and VSCode will open a new terminal. | ||
2. Now set a breakpoint somewhere in your code. | ||
3. Run tests with `npm run test` and VSCode will break at the given breakpoint. | ||
|
||
## Updating dependencies | ||
|
||
Update the version of NodeJS: | ||
|
||
```bash | ||
nix flake update | ||
``` | ||
|
||
Update the version of JavaScript dependencies: | ||
|
||
```bash | ||
npm update | ||
``` | ||
|
||
Finally, update the dependencies hash: | ||
|
||
```bash | ||
scripts/update-npm-deps-hash.sh | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# nixjs-rt [![builder](https://github.com/urbas/nixjs-rt/actions/workflows/build.yml/badge.svg)](https://github.com/urbas/nixjs-rt/actions/workflows/build.yml) | ||
|
||
Nix JavaScript Run-time, an implementation of nix language semantics in TypeScript. | ||
|
||
This library is intended for use in transpiling the Nix language to JavaScript. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
description = "A library that implements Nix language semantics in JS."; | ||
|
||
inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable"; | ||
|
||
outputs = { self, nixpkgs }: | ||
let | ||
forAllSystems = f: nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ] (system: f { pkgs = import nixpkgs { inherit system; }; }); | ||
|
||
devPkgs = pkgs: with pkgs; [ | ||
nodejs | ||
parallel | ||
prefetch-npm-deps | ||
]; | ||
|
||
in | ||
{ | ||
packages = forAllSystems ({ pkgs }: with pkgs; { | ||
default = import ./pkg.nix { inherit pkgs self; }; | ||
|
||
devEnv = buildEnv { | ||
name = "devEnv"; | ||
paths = devPkgs pkgs; | ||
}; | ||
}); | ||
|
||
devShells = forAllSystems ({ pkgs }: with pkgs; { | ||
default = stdenv.mkDerivation { | ||
name = "nixjs-rt"; | ||
buildInputs = devPkgs pkgs; | ||
}; | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"preset": "ts-jest", | ||
"testEnvironment": "node", | ||
"modulePathIgnorePatterns": ["dist"] | ||
} |
Oops, something went wrong.