Created
October 17, 2025 23:27
-
-
Save jakehamilton/3a7a7c95ef55d0b7984d096bfb067662 to your computer and use it in GitHub Desktop.
sample
This file contains hidden or 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 is managed by the `sample` command line program and contains project information | |
| ; such as dependencies. | |
| (project | |
| (base ".") | |
| (main "sample.lisp") | |
| (dependencies | |
| ((dependency | |
| (type :git) | |
| (source "git@...") | |
| (hash "sha256-...")) | |
| ))) |
This file contains hidden or 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
| # Managing dependencies is now done via a command line program, here called simply, `sample`. | |
| sample add github:nixos/nixpkgs | |
| sample add github:sample/core --as lib | |
| # Compilation is performed with the `compile` subcommand. | |
| sample compile | |
| # The compiled code can be used with the Nix command line program. | |
| nix eval -f ./sample.nix |
This file contains hidden or 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
| ; Import Lisp packages. | |
| (import lib) | |
| (import nilla) | |
| ; Import Lisp files in the current project. | |
| (import .helpers) | |
| ; Import raw artifacts which yield a path. | |
| (import :raw nixpkgs) | |
| (import :raw tidepool) | |
| ; Import Nix code. | |
| (import :foreign nixpkgs | |
| :as pkgs | |
| :with { | |
| :system "x86_64-linux" | |
| }) | |
| (define inputs | |
| { | |
| :nixpkgs nixpkgs | |
| :tidepool tidepool | |
| }) | |
| (nilla.create | |
| { | |
| ; A shorthand can be used when the variable and attribute name are the same: | |
| ; `(inherit inputs)` | |
| :inputs inputs | |
| }) |
This file contains hidden or 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
| # The above `sample.lisp` file would compile to something like the following Nix code. | |
| let | |
| # Dependencies are vendored when compiled. | |
| __import_lib__ = import ./_/lib; | |
| __import_nilla__ = import ./_/nilla; | |
| # Local Lisp code is bundled. | |
| helpers = { /* ... */ }; | |
| # Raw artifacts pull from metadata. | |
| inherit (import ./_/meta) | |
| nixpkgs | |
| tidepool; | |
| # Nix imports desugar. | |
| pkgs = import ./_/nixpkgs { | |
| system = "x86_64-linux"; | |
| }; | |
| # `define` bindings desugar. | |
| inputs = { | |
| nixpkgs = nixpkgs; | |
| tidepool = tidepool; | |
| }; | |
| in | |
| # The last expression in `sample.lisp` becomes the body. | |
| # Only one body can exist to keep compatibility with generated Nix code. | |
| nilla.create { | |
| inputs = inputs; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment