Skip to content

Commit

Permalink
Merge pull request #1005 from cachix/rust-rewrite
Browse files Browse the repository at this point in the history
Rust rewrite
  • Loading branch information
domenkozar authored Mar 20, 2024
2 parents 169d2cb + 2edb077 commit 39c4b52
Show file tree
Hide file tree
Showing 184 changed files with 6,185 additions and 2,570 deletions.
4 changes: 2 additions & 2 deletions .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"customizations": {
"vscode": {
"extensions": [
"bbenoist.Nix"
"jnoortheen.nix-ide"
]
}
},
"image": "ghcr.io/cachix/devenv:latest",
"overrideCommand": false,
"updateContentCommand": "devenv ci"
"updateContentCommand": "devenv test"
}
4 changes: 2 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
set -euo pipefail

# Use our own last built devenv/nix in CLI
devenv_bin=$(nix build --print-out-paths --accept-flake-config)
PATH_add "$devenv_bin/bin"
nix build --print-out-paths --accept-flake-config || echo "nix build failed, using previous build"
PATH_add "result/bin"

# External users should use `source_url` to load this file
source_env ./direnvrc
Expand Down
84 changes: 48 additions & 36 deletions .github/workflows/buildtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [[ubuntu-latest], [macos-latest], [self-hosted, macOS], [self-hosted, linux, ARM64]]
os: [[self-hosted, linux, X64], [macos-latest], [self-hosted, macOS], [self-hosted, linux, ARM64]]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -25,37 +25,57 @@ jobs:
with:
name: devenv
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: |
nix profile remove '.*'
nix profile install --accept-flake-config .
- name: Run tests
- id: build
run: |
devenv ci
devenv shell devenv-run-tests
devenv search ncdu | grep "pkgs\.ncdu"
bin=$(nix build --print-out-paths)
echo "bin=$bin" >> $GITHUB_OUTPUT
- name: Run tests
run: ./result/bin/devenv test
tests:
needs: build
strategy:
fail-fast: false
matrix:
os: [[self-hosted, linux, X64], [macos-latest], [self-hosted, macOS], [self-hosted, linux, ARM64]]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v14
with:
name: devenv
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: |
nix build
export PATH=$PWD/result/bin:$PATH
devenv shell devenv-test-cli
devenv-run-tests tests
pin:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
uses: ./.github/workflows/pin.yml
secrets: inherit
generate-examples:
runs-on: ubuntu-latest
runs-on: [self-hosted, linux, X64]
outputs:
examples: ${{ steps.set-examples.outputs.examples }}
steps:
- name: Checkout base repo
uses: actions/checkout@v4
- id: set-examples
run: |
json=$(tree -J -L 1 examples | jq -c '[.[0].contents[] | .name]')
json=$(nix shell nixpkgs#tree -c tree -J -L 1 examples | nix shell nixpkgs#jq -c jq -c '[.[0].contents[] | .name]')
echo "examples=$json" >> $GITHUB_OUTPUT
examples:
name: ${{ matrix.example }} (${{ join(matrix.os) }})
needs: [generate-examples]
needs: [generate-examples, build]
strategy:
fail-fast: false
matrix:
os: [[ubuntu-latest], [macos-latest], [self-hosted, macOS], [self-hosted, linux, ARM64]]
os: [[self-hosted, linux, X64], [macos-latest], [self-hosted, macOS], [self-hosted, linux, ARM64]]
example: ${{ fromJSON(needs.generate-examples.outputs.examples) }}
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -70,15 +90,11 @@ jobs:
name: devenv
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: |
nix profile remove '.*'
nix profile install --accept-flake-config . "nixpkgs#gawk"
- name: Disable package aliases
run: |
mkdir -p ~/.config/nixpkgs
echo '{ allowAliases = false; }' > ~/.config/nixpkgs/config.nix
- run: devenv shell devenv-test-example ${{ matrix.example }}
nix build
PATH=$PWD/result/bin:$PATH devenv-run-tests --only ${{ matrix.example }} examples
direnv:
name: direnv (${{ join(matrix.os) }})
needs: build
strategy:
fail-fast: false
matrix:
Expand All @@ -94,25 +110,23 @@ jobs:
name: devenv
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: |
mv ./examples/simple/devenv.yaml ./examples/simple/devenv.yaml.orig
awk '
{ 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'
mkdir -p ~/.config/direnv/
cat > ~/.config/direnv/direnv.toml << 'EOF'
[global]
strict_env = true
EOF
direnv allow ./examples/simple
direnv exec ./examples/simple true
devenv_dir=$PWD
export PATH=$PWD/result/bin:$PATH
nix build
tmp="$(mktemp -d)"
pushd "$tmp"
nix shell nixpkgs#direnv -c devenv --override-input devenv path:$devenv_dir?dir=src/modules init
popd
fish-zsh:
name: zsh/fish (${{ join(matrix.os) }})
needs: build
strategy:
fail-fast: false
matrix:
Expand All @@ -127,9 +141,7 @@ jobs:
with:
name: devenv
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build
- run: |
nix profile remove '.*'
nix profile install --accept-flake-config .
- run: |
nix shell nixpkgs#zsh -c zsh -c "$(which devenv) version"
nix shell nixpkgs#fish -c fish -c "$(which devenv) version"
nix shell nixpkgs#zsh -c zsh -c "./result/bin/devenv version"
nix shell nixpkgs#fish -c fish -c "./result/bin/devenv version"
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Nix & devenv
result
.env
.env.*
.devenv*
.direnv*
/.cache
/.pre-commit-config.yaml
/bin
/include
/lib
pyvenv.cfg
/.direnv
/.venv

# examples
examples/rust/app/target

# Rust
target
Loading

0 comments on commit 39c4b52

Please sign in to comment.