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

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gambit-nix

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

Features

  • Nix Overlay: Easy integration into existing Nix projects.
  • R7RS Support: First-class support for R7RS library definitions (define-library).
  • Cached Compilation: Libraries are compiled to C/Object files once and reused across applications.
  • Static Linking: Applications are statically linked with their dependencies for easy distribution.
  • Development Shell: Provides a pre-configured gsi REPL with access to your project's dependencies.

Usage

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

Applications

Define your application derivation and list your libraries in dependencies.

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

Libraries

Define your library derivation. Source files (.sld, .scm) are installed to the search path and compiled to object files.

{
  # ...
  outputs = { self, nixpkgs, gambit-nix, ... }: {
    # ...
    my-lib = pkgs.gambit-overlay.buildGambitLibrary {
      name = "my-lib";
      src = ./lib; # Directory containing .sld files
    };
  };
}

Git Dependencies

You can include libraries from Git repositories by adding them to your flake.nix inputs.

  • Library is a Nix Flake

    inputs.gambit-library-flake.url = "github:user/repo";
    
    # ... inside buildGambitApp ...
    dependencies = [ inputs.gambit-library-flake.packages.${system}.default ];
  • Non-nix Gambit Library

    inputs.gambit-library-src.url = "github:user/repo";
    
    # ... inside outputs ...
    remote-lib = pkgs.gambit-overlay.buildGambitLibrary {
      name = "remote-lib";
      src = inputs.gambit-library-src;
    };

Development Shell

Get a shell with gsi and gsc configured to find your dependencies.

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

Inside the shell:

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

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