Skip to content

Commit

Permalink
Merge pull request #32 from Second-Last/nixify
Browse files Browse the repository at this point in the history
Add Nix flakes and development setup instructions
  • Loading branch information
githwxi authored Jan 14, 2025
2 parents 4adeabf + 7e1e702 commit 49f0f20
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ srcgen2/BUILD/JS
srcgen2/xats2js/srcgen1/BUILD/JS
srcgen2/xats2py/srcgen1/BUILD/JS

result

###### end of [.gitignore] ######
30 changes: 30 additions & 0 deletions DEVELOP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
This document provides instructions on how to setup your environment to
develop/hack on ATS-Xanadu.

## Prerequisites

- The [`nix`](https://nixos.org/download/) package manager.

That's it! The hard job of setting up dependencies and configuring environment
variables are offloaded to Nix
([flakes](https://zero-to-nix.com/concepts/flakes/)), all while making sure
these changes are isolated for this project only and will not affect your
system.

## Steps

> [!WARNING]
> For advanced Make users: do **NOT** add `-j` flag to build in parallel. There
are still issues regarding the way compiler outputs are merged together.
The build is quick and shouldn't take more than 10 minutes to complete
even when building with one core.

1. Run `nix develop`. You will be dropped into a bash shell that contains all
the dependencies and environment variables configured for you.

The first run may take a while, because Nix needs to fetch dependencies.
Subsequent `nix develop` runs are much faster due to caching.

2. Run `make -f Makefile_overall`.

3. Now you have a working ATS3 compiler! Checkout the `PGROUND` for examples.
61 changes: 61 additions & 0 deletions flake.lock

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

31 changes: 31 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
description = "ATS-Xanadu";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { nixpkgs, flake-utils, self }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
devShells = {
default = with pkgs; mkShell {
buildInputs = [
ats2
boehmgc
bun
nodejs
];

shellHook = ''
export XATSHOME=$PWD
'';
};
};
}
);
}
2 changes: 2 additions & 0 deletions srcgen1/Makefile_patsopt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ PATSOPT=$(PATSHOME)/bin/patsopt
#
NIXATS2=nix-shell -p ats2 --run
#
ifndef IN_NIX_SHELL
PATSOPT=\
nix --extra-experimental-features nix-command --extra-experimental-features flakes run github:githwxi/ATS-Postiats\#patsopt --
endif
######
#
CFLAGS=
Expand Down
2 changes: 2 additions & 0 deletions srcgen1/xats2js/srcgen1/Makefile_patsopt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ PATSOPT=$(PATSHOME)/bin/patsopt
#
NIXATS2=nix-shell -p ats2 --run
#
ifndef IN_NIX_SHELL
PATSOPT=\
nix --extra-experimental-features nix-command --extra-experimental-features flakes run github:githwxi/ATS-Postiats\#patsopt --
endif
#
######
#
Expand Down
Binary file added srcgen1/xats2js/srcgen1/bin/xats2js
Binary file not shown.

0 comments on commit 49f0f20

Please sign in to comment.