Skip to content

Commit

Permalink
template example from "Getting Started" documentation
Browse files Browse the repository at this point in the history
A working example project put together from https://numtide.github.io/devshell/getting_started.html
  • Loading branch information
peterbecich committed Sep 2, 2023
1 parent c80beef commit bcc2b24
Show file tree
Hide file tree
Showing 11 changed files with 1,110 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
/dist

# direnv
/.direnv
/.direnv
2 changes: 2 additions & 0 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ cd project/
nix develop # or `direnv allow` if you want to use direnv
```

Find `templates/gettingStartedExample` in this repository for a working example of the additional configuration below: `env`, `packages`, and `serviceGroups`.

## Adding environment variables

Environment variables that are specific to the project can be added with the
Expand Down
12 changes: 12 additions & 0 deletions templates/gettingStartedExample/.envrc
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
4 changes: 4 additions & 0 deletions templates/gettingStartedExample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.direnv/
/pgdata/*
!/pgdata/postgresql.conf
!/pgdata/PG_VERSION
30 changes: 30 additions & 0 deletions templates/gettingStartedExample/devshell.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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",
]

[serviceGroups.database]
description = "Runs a database in the backgroup"
[serviceGroups.database.services.postgres]
command = "postgres -D ./pgdata"
[serviceGroups.database.services.memcached]
command = "memcached"
110 changes: 110 additions & 0 deletions templates/gettingStartedExample/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions templates/gettingStartedExample/flake.nix
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) ];
};
});
}
1 change: 1 addition & 0 deletions templates/gettingStartedExample/pgdata/PG_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
15
Loading

0 comments on commit bcc2b24

Please sign in to comment.