-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Getting started example project (#274)
* fix `nix develop` shell in template #272 * template example from "Getting Started" documentation A working example project put together from https://numtide.github.io/devshell/getting_started.html
- Loading branch information
1 parent
f6aec2e
commit 6b52efc
Showing
10 changed files
with
421 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
/dist | ||
|
||
# direnv | ||
/.direnv | ||
/.direnv |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,12 @@ | ||
#!/usr/bin/env bash | ||
# ^ added for shellcheck and file-type detection | ||
|
||
# Watch & reload direnv on change | ||
watch_file devshell.toml | ||
|
||
if [[ $(type -t use_flake) != function ]]; then | ||
echo "ERROR: use_flake function missing." | ||
echo "Please update direnv to v2.30.0 or later." | ||
exit 1 | ||
fi | ||
use flake |
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,3 @@ | ||
/.direnv/ | ||
/pgdata/* | ||
/.data/ |
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,39 @@ | ||
# https://numtide.github.io/devshell | ||
# https://numtide.github.io/devshell/getting_started.html | ||
[[commands]] | ||
package = "hello" | ||
|
||
[[commands]] | ||
package = "go" | ||
|
||
[[commands]] | ||
package = "nodejs_20" | ||
|
||
[[commands]] | ||
package = "python311" | ||
|
||
[[env]] | ||
name = "GO111MODULE" | ||
value = "on" | ||
|
||
[devshell] | ||
packages = [ | ||
"postgresql_15", | ||
"memcached", | ||
] | ||
|
||
[[commands]] | ||
name = "initPostgres" | ||
help = "Initialize the Postgres database" | ||
command = """\ | ||
initdb pgdata; \ | ||
chmod -R 700 pgdata; \ | ||
echo -e "Use the devshell command 'database:start'" | ||
""" | ||
|
||
[serviceGroups.database] | ||
description = "Runs a database in the background" | ||
[serviceGroups.database.services.postgres] | ||
command = "postgres -D ./pgdata" | ||
[serviceGroups.database.services.memcached] | ||
command = "memcached" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,21 @@ | ||
{ | ||
description = "getting started example"; | ||
|
||
inputs.devshell.url = "github:numtide/devshell"; | ||
inputs.flake-utils.url = "github:numtide/flake-utils"; | ||
|
||
outputs = { self, flake-utils, devshell, nixpkgs }: | ||
flake-utils.lib.eachDefaultSystem (system: { | ||
devShell = | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
|
||
overlays = [ devshell.overlays.default ]; | ||
}; | ||
in | ||
pkgs.devshell.mkShell { | ||
imports = [ (pkgs.devshell.importTOML ./devshell.toml) ]; | ||
}; | ||
}); | ||
} |
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,10 @@ | ||
|
||
[Getting Started](https://numtide.github.io/devshell/getting_started.html) | ||
|
||
This example will run Postgres and Memcached natively on your machine. | ||
|
||
You may have to be a member of the `postgres` group to allow Postgres to start. Otherwise, Postgres may be unable to create its lockfile. | ||
|
||
First create the Postgres database with the devshell command `initPostgres`. This is defined in the TOML. It uses Postgres command `initdb`. | ||
|
||
Then the devshell command `database:start`. |
Oops, something went wrong.