Skip to content

Nix overlay wrapping the Gambit Scheme compiler toolchain (build Gambit applications with Nix)

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

omarjatoi/gambit-nix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gambit-nix

Nix build system for Gambit Scheme with an overlay that wraps the Gambit compiler toolchain.

Features

  • Nix Overlay: Integration into existing Nix projects via a single overlay.
  • R7RS Support: First-class support for R7RS library definitions (.sld files using define-library).
  • Cached Compilation: Libraries are compiled to C and object files once and reused across application builds.
  • Static Linking: Applications are statically linked with their dependencies.
  • Development Shell: Pre-configured gsi REPL with access to your project's dependencies.

Usage

Add gambit-nix to your flake.nix inputs and apply the overlay:

inputs.gambit-nix.url = "github:omarjatoi/gambit-nix";

# inside outputs:
pkgs = import nixpkgs {
  inherit system;
  overlays = [ gambit-nix.overlays.default ];
};

Libraries

Libraries must use R7RS define-library in .sld files. The build compiles each .sld to C and object files for static linking, and installs the sources for downstream import resolution.

my-lib = pkgs.gambit-overlay.buildGambitLibrary {
  name = "my-lib";
  src = ./lib; # Directory containing .sld files
};

Applications

my-app = pkgs.gambit-overlay.buildGambitApp {
  name = "my-app";
  src = ./src;
  main = "main.scm";  # Entry point (default: main.scm)
  dependencies = [ my-lib ];
};

The app build compiles only the application source. Pre-compiled dependency objects are linked directly from the Nix store without recompilation.

Dependencies

The dependencies list accepts both derivations and flake inputs. Flake inputs are automatically resolved to packages.${system}.default.

Flake dependency (has its own buildGambitLibrary):

inputs.some-lib.url = "github:user/repo";

# inside buildGambitApp or buildGambitLibrary:
dependencies = [ inputs.some-lib ];

Non-Nix Gambit library (raw .sld source):

inputs.some-lib-src.url = "github:user/repo";

# inside outputs:
some-lib = pkgs.gambit-overlay.buildGambitLibrary {
  name = "some-lib";
  src = inputs.some-lib-src;
};

# then use in dependencies:
dependencies = [ some-lib ];

Development Shell

devShells.default = pkgs.gambit-overlay.gambitDevShell {
  dependencies = [ my-lib ];
};

Inside the shell, gsi and gsc are wrapped with the correct search paths:

$ gsi
> (import (my-lib))
> (my-function ...)

Templates

Flake templates to quickly scaffold new Gambit projects:

# New application project
nix flake init -t github:omarjatoi/gambit-nix#app

# New library project
nix flake init -t github:omarjatoi/gambit-nix#library

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Nix overlay wrapping the Gambit Scheme compiler toolchain (build Gambit applications with Nix)

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published