-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Haunt for Scheme as a provider (#1198)
* draft * register provider * simplification * fix registration * incorporate feedback * start command quirk * lint fix * add scheme snapshot test --------- Co-authored-by: Jake Runzer <[email protected]>
- Loading branch information
1 parent
2015b25
commit 6b61023
Showing
9 changed files
with
123 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
title: Scheme | ||
--- | ||
|
||
# {% $markdoc.frontmatter.title %} | ||
|
||
Scheme via [Haunt](https://dthompson.us/projects/haunt.html) is detected is there is a `haunt.scm` file found. | ||
|
||
## Setup | ||
|
||
Installs the basic dependencies | ||
|
||
## Build | ||
|
||
Build the project based on your `haunt.scm`. | ||
|
||
## Start | ||
|
||
Haunt wasn't made for this, so our entrypoint is actually a Guile script. | ||
Make sure it is in the root directory with your `haunt.scm`. | ||
Note: This is only necessary in production. You can use the `haunt` command normally in dev. | ||
|
||
```scheme | ||
;; init.scm | ||
(system "haunt serve") | ||
``` |
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,14 @@ | ||
(use-modules (haunt asset) | ||
(haunt builder blog) | ||
(haunt builder assets) | ||
(haunt reader commonmark) | ||
(haunt site)) | ||
|
||
(site #:title "Built with Guile" | ||
#:domain "example.com" | ||
#:default-metadata | ||
'((author . "John Doe") | ||
(email . "[email protected]")) | ||
#:readers (list) | ||
#:builders (list) | ||
) |
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 @@ | ||
(display "Hello from Scheme!") |
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
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,36 @@ | ||
use super::Provider; | ||
use crate::nixpacks::{ | ||
app::App, | ||
environment::Environment, | ||
nix::pkg::Pkg, | ||
plan::{ | ||
phase::{Phase, StartPhase}, | ||
BuildPlan, | ||
}, | ||
}; | ||
use anyhow::Result; | ||
|
||
pub struct HauntProvider {} | ||
|
||
impl Provider for HauntProvider { | ||
fn name(&self) -> &str { | ||
"scheme" | ||
} | ||
|
||
fn detect(&self, app: &App, _env: &Environment) -> Result<bool> { | ||
Ok(app.includes_file("haunt.scm")) | ||
} | ||
|
||
fn get_build_plan(&self, _app: &App, _env: &Environment) -> Result<Option<BuildPlan>> { | ||
let setup = Phase::setup(Some(vec![Pkg::new("haunt"), Pkg::new("guile")])); | ||
let mut build = Phase::build(Some("haunt build".to_string())); | ||
build.depends_on_phase("setup"); | ||
// In production, init.scm should run "haunt serve" | ||
// However, "haunt serve" doesn't terminate on its own, which the tests depend on | ||
// So for the example, init.scm simply logs to the console | ||
let start = StartPhase::new("guile init.scm --auto-compile".to_string()); | ||
|
||
let plan = BuildPlan::new(&vec![setup, build], Some(start)); | ||
Ok(Some(plan)) | ||
} | ||
} |
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,35 @@ | ||
--- | ||
source: tests/generate_plan_tests.rs | ||
expression: plan | ||
--- | ||
{ | ||
"providers": [], | ||
"buildImage": "[build_image]", | ||
"variables": { | ||
"NIXPACKS_METADATA": "scheme" | ||
}, | ||
"phases": { | ||
"build": { | ||
"name": "build", | ||
"dependsOn": [ | ||
"install", | ||
"setup" | ||
], | ||
"cmds": [ | ||
"haunt build" | ||
] | ||
}, | ||
"setup": { | ||
"name": "setup", | ||
"nixPkgs": [ | ||
"haunt", | ||
"guile" | ||
], | ||
"nixOverlays": [], | ||
"nixpkgsArchive": "[archive]" | ||
} | ||
}, | ||
"start": { | ||
"cmd": "guile init.scm --auto-compile" | ||
} | ||
} |