Skip to content

Commit

Permalink
cli
Browse files Browse the repository at this point in the history
  • Loading branch information
domenkozar committed Jul 31, 2023
1 parent 4d227ef commit c14b7bb
Show file tree
Hide file tree
Showing 17 changed files with 367 additions and 162 deletions.
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ set -euo pipefail
# External users should use `source_url` to load this file
source_env ./direnvrc

use devenv
use devenv
8 changes: 4 additions & 4 deletions .github/workflows/buildtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ jobs:
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: |
nix profile remove '.*'
nix profile install --accept-flake-config . "nixpkgs#gawk"
nix profile install --accept-flake-config .
- name: Disable package aliases
run: |
mkdir -p ~/.config/nixpkgs
echo '{ allowAliases = false; }' > ~/.config/nixpkgs/config.nix
- run: devenv shell devenv-test-example ${{ matrix.example }}
- run: devenv test ${{ matrix.example }}
direnv:
name: direnv (${{ join(matrix.os) }})
needs: build
Expand All @@ -92,15 +92,15 @@ jobs:
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: |
mv ./examples/simple/devenv.yaml ./examples/simple/devenv.yaml.orig
awk '
nix run nixpkgs#gawk -- '
{ print }
/^inputs:$/ {
print " devenv:";
print " url: path:../../src/modules";
}
' ./examples/simple/devenv.yaml.orig > ./examples/simple/devenv.yaml
nix profile remove '.*'
nix profile install . 'nixpkgs#direnv' nix profile install --accept-flake-config
nix profile install . 'nixpkgs#direnv'
mkdir -p ~/.config/direnv/
cat > ~/.config/direnv/direnv.toml << 'EOF'
[global]
Expand Down
41 changes: 1 addition & 40 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{ inputs, pkgs, lib, config, ... }:

{
env = {
DEVENV_NIX = inputs.nix.packages.${pkgs.stdenv.system}.nix;
};
env.DEVENV_NIX = inputs.nix.packages.${pkgs.stdenv.system}.nix;

packages = [
pkgs.cairo
Expand Down Expand Up @@ -82,43 +80,6 @@
popd
rm -rf "$tmp"
'';
scripts.devenv-test-all-examples.exec = ''
for dir in $(ls examples); do
devenv-test-example $dir
done
'';
scripts.devenv-test-example.exec = ''
# execute all trap_ function on exit
trap 'eval $(declare -F | grep -o "trap_[^ ]*" | tr "\n" ";")' EXIT
set -e
example="$PWD/examples/$1"
pushd $example
mv devenv.yaml devenv.yaml.orig
awk '
{ print }
/^inputs:$/ {
print " devenv:";
print " url: path:../../src/modules";
}
' devenv.yaml.orig > devenv.yaml
trap_restore_yaml() {
mv "$example/devenv.yaml.orig" "$example/devenv.yaml"
}
devenv ci
if [ -f .test.sh ]; then
trap_restore_local() {
rm "$example/devenv.local.nix"
rm -rf "$example/.devenv"
}
# coreutils-full provides timeout on darwin
echo "{ pkgs, ... }: { packages = [ pkgs.coreutils-full ]; }" > devenv.local.nix
devenv shell ./.test.sh
else
devenv shell ls
fi
popd
'';
scripts."devenv-generate-doc-options".exec = ''
set -e
options=$(nix build --impure --extra-experimental-features 'flakes nix-command' --show-trace --print-out-paths --no-link '.#devenv-docs-options')
Expand Down
6 changes: 1 addition & 5 deletions examples/clickhouse/.test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
#!/bin/sh
set -ex
pkill clickhouse
devenv up&
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"
Loading

0 comments on commit c14b7bb

Please sign in to comment.