-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb2bad5
commit 3806e2b
Showing
43 changed files
with
766 additions
and
448 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
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
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,34 @@ | ||
Typically [packages](./packages.md) come prebuilt with binaries provided by [the official binary cache](https://cache.nixos.org). | ||
|
||
If you're modifying a package or using a package that's not built upstream, | ||
Nix will build it from source instead of downloading a binary. | ||
|
||
To prevent packages from being built more than once, there's seamless integration with | ||
binary caches using [Cachix](https://cachix.org). | ||
|
||
## Setup | ||
|
||
If you'd like to push binaries to your own cache, you'll need [to create one](https://app.cachix.org/cache). | ||
|
||
After that you'll need to set `cachix authtoken XXX` with either [a personal auth token](https://app.cachix.org/personal-auth-tokens) or a cache token (that you can create in cache settings). | ||
|
||
## devenv.nix | ||
|
||
To specify `pre-commit-hooks` as a cache to pull from and `mycache` to pull from and push to: | ||
|
||
```nix title="devenv.nix" | ||
{ | ||
cachix.pull = [ "pre-commit-hooks" ]; | ||
cachix.push = "mycache"; | ||
} | ||
``` | ||
|
||
# Pushing only in specific cases | ||
|
||
You'll likely not want every user to push to the cache. | ||
|
||
It's usually convenient to push [explicitly](./files-and-variables/#devenvlocalnix), for example as part of CI run: | ||
|
||
```shell-session | ||
$ echo '{ cachix.push = "mycache"; }' > devenv.local.nix | ||
``` |
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,55 @@ | ||
To ease testing of your environments, | ||
we provide a way to define the tests and to run them. | ||
|
||
## Writing devenv tests | ||
|
||
A simple test would look like: | ||
|
||
```nix title="devenv.nix" | ||
{ pkgs, ... }: { | ||
tests.basic = { | ||
nix = '' | ||
{ pkgs, ... }: { | ||
packages = [ pkgs.ncdu ]; | ||
} | ||
''; | ||
test = '' | ||
ncdu --version | grep "ncdu 2.2" | ||
''; | ||
}; | ||
} | ||
``` | ||
|
||
```shell-session | ||
$ devenv test | ||
✔ Gathering tests in 0.3s. | ||
• Found 1 test(s), running 1: | ||
• Testing basic ... | ||
• Running $ devenv ci | ||
• Running .test.sh. | ||
✔ Running basic in 16.7s. | ||
``` | ||
|
||
## Defining tests in a folder | ||
|
||
A simple test with a test script: | ||
|
||
```shell-session | ||
$ ls tests/mytest/ | ||
.test.sh devenv.nix devenv.yaml | ||
``` | ||
|
||
Define tests: | ||
|
||
```nix title="devenv.nix" | ||
{ config, ... }: { | ||
tests = config.lib.mkTests ./tests; | ||
} | ||
``` | ||
|
||
Run tests: | ||
|
||
```shell-session | ||
$ devenv test | ||
... | ||
``` |
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 |
---|---|---|
@@ -1,6 +1,3 @@ | ||
#!/bin/sh | ||
set -ex | ||
pkill clickhouse | ||
devenv up& | ||
set -xe | ||
timeout 20 bash -c 'until echo > /dev/tcp/localhost/9000; do sleep 0.5; done' | ||
clickhouse-client --query "SELECT 1" | ||
clickhouse-client --query "SELECT 1" |
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
services.clickhouse = { | ||
enable = true; | ||
config = '' | ||
http_port: 9000 | ||
# http_port: 8123 | ||
''; | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,10 +1,5 @@ | ||
#!/bin/sh | ||
set -ex | ||
|
||
devenv up & | ||
DEVENV_PID=$! | ||
trap "pkill -P $DEVENV_PID" EXIT | ||
|
||
timeout 20 bash -c 'until echo > /dev/tcp/localhost/9000; do sleep 0.5; done' | ||
|
||
mc admin info local | ||
mc admin info local |
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 |
---|---|---|
@@ -1,8 +1,3 @@ | ||
#!/bin/sh | ||
set -ex | ||
|
||
devenv up & | ||
DEVENV_PID=$! | ||
trap "pkill -P $DEVENV_PID" EXIT | ||
|
||
timeout 60 bash -c 'until MYSQL_PWD="" mysql -u root test_database < /dev/null; do sleep 0.5; done' | ||
timeout 60 bash -c 'until MYSQL_PWD="" mysql -u root test_database < /dev/null; do sleep 0.5; done' |
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
{ pkgs, ... }: | ||
|
||
{ | ||
packages = [ pkgs.rust-bin.stable.latest.default ]; | ||
packages = [ | ||
# from the rust-overlay | ||
pkgs.rust-bin.stable.latest.default | ||
|
||
services.blackfire.enable = true; | ||
# from subflake | ||
pkgs.hello2 | ||
]; | ||
} |
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,7 @@ | ||
{ | ||
outputs = { ... }: { | ||
overlays.default = self: super: { | ||
hello2 = self.hello; | ||
}; | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,6 +1,2 @@ | ||
#!/bin/sh | ||
set -ex | ||
|
||
devenv up & | ||
|
||
timeout 20 bash -c 'until psql -h /tmp -c "SELECT 1" mydb 2>/dev/null; do sleep 0.5; done' |
Oops, something went wrong.