Skip to content

Commit

Permalink
Remove Nix (#11)
Browse files Browse the repository at this point in the history
* Remove Nix

Feedback from Roger and others was to go "vanilla" python project.
Therefore remove Nix, Poetry and go back to published versions of
dependencies such as apsw and lief

* updated readme, added api and new tests
* updated readme to reflect removal of Nix
* added new API sql.py to execute sqlelf directly
* added some new tests for the new API
* reworked the cli.py to invoke the new API
* Addressing feedback from Mark
* format
  • Loading branch information
fzakaria authored Sep 22, 2023
1 parent 87f44d5 commit c251cf9
Show file tree
Hide file tree
Showing 25 changed files with 204 additions and 898 deletions.
1 change: 0 additions & 1 deletion .envrc

This file was deleted.

25 changes: 14 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
with:
name: fzakaria
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix develop --command make lint
- run: nix develop --command make test
- run: nix build --print-build-logs
- run: nix run . -- --help
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
- run: make lint
- run: make test
- run: sqlelf --help
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,13 @@ dist/
result
examples/**/exe
examples/**/*.so
venv/
temp/
# Unit test / coverage reports
.coverage
.tox
.coverage.*
.pytest_cache/
nosetests.xml
coverage.xml
htmlcov
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@ show: ## Show the current environment.
fmt: ## Format code using black & isort.
isort sqlelf/
black sqlelf/
nixpkgs-fmt .

.PHONY: lint
lint: ## Run pep8, black, mypy linters.
flake8 sqlelf/
black --check sqlelf/
# TODO(fzakaria): without pythonpath it picks up the wrong python
# and then does not find the venv for the imports
pyright --pythonpath $(shell which python)
nixpkgs-fmt --check .
pyright

.PHONY: test
test: ## Run pytest primarily.
Expand Down
25 changes: 8 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# sqlelf

![example workflow](https://github.com/fzakaria/sqlelf/actions/workflows/main.yml/badge.svg)
[![built with nix](https://builtwithnix.org/badge.svg)](https://builtwithnix.org)
![build workflow](https://github.com/fzakaria/sqlelf/actions/workflows/main.yml/badge.svg)

> Explore ELF objects through the power of SQL
Expand Down Expand Up @@ -67,23 +66,18 @@ erDiagram
```

## Installation
This repository can easily be installed, you simply need to have [Nix or NixOS](https://nixos.org) installed.

```console
nix run github:fzakaria/sqlelf /usr/bin/python3 -- \
python3 -m venv venv
source venv/bin/activate
pip install .
sqlelf /usr/bin/python3 -- \
--sql "select mnemonic, COUNT(*) from elf_instructions GROUP BY mnemonic ORDER BY 2 DESC LIMIT 3"

mov|223497
call|56209
jmp|48213
```

Note: I publish artifacts to [cachix](https://cachix.org/) that you can use to develop faster.

```console
> cachix use fzakaria
```

## Usage
```console
sqlelf --help
Expand All @@ -102,6 +96,7 @@ options:
```

Note: You may provide directories for `FILE`. Avoid giving too many binaries though since they must all be parsed at startup.

## Tour

You simply have to fire up `sqlelf` and give it a list of binaries or directories and start exploring ELF via SQL.
Expand Down Expand Up @@ -249,14 +244,10 @@ WHERE

## Development

You must have [Nix](https://nixos.org) installed for development.

This package uses [poetry2nix](https://github.com/nix-community/poetry2nix) to easily setup a development environment.
You may want to install the package in _editable mode_ as well to make development easier

```console
nix develop
$ sqlelf --help
usage: sqlelf [-h] [-s SQL] FILE [FILE ...]
> pip install --editable ".[dev]"
```

A helping `Makefile` is provided to run all the _linters_ and _formatters_.
Expand Down
107 changes: 0 additions & 107 deletions flake.lock

This file was deleted.

32 changes: 0 additions & 32 deletions flake.nix

This file was deleted.

5 changes: 0 additions & 5 deletions nix/derivation.nix

This file was deleted.

44 changes: 0 additions & 44 deletions nix/lief.nix

This file was deleted.

40 changes: 0 additions & 40 deletions nix/overlay.nix

This file was deleted.

Loading

0 comments on commit c251cf9

Please sign in to comment.