Skip to content

Commit

Permalink
chore: replace flake.nix by devenv
Browse files Browse the repository at this point in the history
  • Loading branch information
glencoe committed Nov 27, 2024
1 parent 41ec49a commit 8c0bd9b
Show file tree
Hide file tree
Showing 7 changed files with 262 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_url "https://raw.githubusercontent.com/cachix/devenv/82c0147677e510b247d8b9165c54f73d32dfd899/direnvrc" "sha256-7u4iDd1nZpxL4tCzmPG0dQgC5V+/44Ba+tHkPob1v2k="

use devenv
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ simulation
simulation/*
node_modules
.mypy_cache
.pytest_cache
.venv
build/
package-lock.json

.coverage
Expand Down Expand Up @@ -247,3 +250,12 @@ Temporary Items
/presentation/presentation.html
/presentation/presentation.pdf
/vhdl93-bnf.html
# Devenv
.devenv*
devenv.local.nix

# direnv
.direnv

# pre-commit
.pre-commit-config.yaml
132 changes: 132 additions & 0 deletions devenv.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1732585607,
"owner": "cachix",
"repo": "devenv",
"rev": "a520f05c40ebecaf5e17064b27e28ba8e70c49fb",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1716977621,
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "4267e705586473d3e5c8d50299e71503f16a6fb6",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1731797254,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e8c38b73aeb218e27163376a2d617e61a2ad9b59",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1732238832,
"owner": "nixos",
"repo": "nixpkgs",
"rev": "8edf06bea5bcbee082df1b7369ff973b91618b8d",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1732021966,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "3308484d1a443fc5bc92012435d79e80458fe43c",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable",
"pre-commit-hooks": "pre-commit-hooks"
}
}
},
"root": "root",
"version": 7
}
85 changes: 85 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
pkgs,
lib,
config,
inputs,
...
}:

let
unstablePkgs = import inputs.nixpkgs-unstable { system = pkgs.stdenv.system; };
rosettaPkgs =
if unstablePkgs.stdenv.isDarwin && unstablePkgs.stdenv.isAarch64 then
unstablePkgs.pkgsx86_64Darwin
else
unstablePkgs;
pyp = unstablePkgs.python312Packages;
in
{

packages = [
pkgs.git
rosettaPkgs.ghdl
pkgs.gtkwave
pyp.python-lsp-server
pyp.pylsp-mypy
pyp.pylsp-rope
unstablePkgs.mypy
unstablePkgs.ruff

];

languages.python = {
enable = true;
package = unstablePkgs.python312;
uv.enable = true;
uv.package = unstablePkgs.uv;
uv.sync.enable = true;
uv.sync.allExtras = true;
};

tasks = {
"bash:link_uv_lock" = {
exec = "ln -s uvPython3.12.lock uv.lock";
before = ["devenv:enterShell"];
status = "[ -L uv.lock ]";
};
};

pre-commit.hooks = {
shellcheck.enable = true;
ripsecrets.enable = true; # don't commit secrets
ruff.enable = true; # lint and automatically fix simple problems/reformat
taplo.enable = true; # reformat toml
nixfmt-rfc-style.enable = true; # reformat nix
ruff-format.enable = true;
mypy = {
enable = false;
}; # check type annotations
end-of-file-fixer.enable = true;
commitizen.enable = true; # help adhering to commit style guidelines
check-toml.enable = true; # check toml syntax
check-case-conflicts.enable = true;
check-added-large-files.enable = true;
};

enterTest =
let
runCommandWithPython =
cmd:
(
version:
"UV_PROJECT_ENVIRONMENT=.venv_${version} uv run --no-env-file --isolated --noprogress --python ${version} ${cmd}"
);
runPytest = runCommandWithPython "pytest";
in
''
rm uv.lock
if [ -f
ln -s uvPython3.11.lock uv.lock
${runPytest "python3.11"}
rm uv.lock
ln -s uvPython3.12.lock uv.lock
uv run --python python3.12 pytest
'';
}
16 changes: 16 additions & 0 deletions devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
nixpkgs-unstable:
url: github:nixos/nixpkgs/nixpkgs-unstable
# If you're using non-OSS software, you can set allowUnfree to true.
# allowUnfree: true

# If you're willing to use a package that's vulnerable
# permittedInsecurePackages:
# - "openssl-1.1.1w"

# If you have more than one devenv you can merge them
#imports:
# - ./backend
15 changes: 13 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,31 @@ name = "elasticai.creator"
version = "0.59.2"
description = "Design, train and compile neural networks optimized specifically for FPGAs."
readme = "README.md"
repository = "https://github.com/es-ude/elastic-ai.creator"
author = ["Department Embedded Systems - University Duisburg Essen"]
license = "MIT"
authors = [
{name = "Intelligent Embedded Systems - University Duisburg Essen"},
]

maintainers = [
{name = "Lukas Einhaus", email="[email protected]"},
{name = "Julian Hoever", email="[email protected]"}, {name="Leo Buron", email="[email protected]"}
]

dependencies = [
"torch>=1.11",
"numpy>=1.23.0",
]
requires-python = ">=3.10"
keywords = ["fpga", "embedded", "hw accelerators", "neural networks", "embedded ai", "tinyml"]
repository = "https://github.com/es-ude/elastic-ai.creator"

[dependency-groups]
dev = [
"black>=24.10.0",
"mypy>=1.13.0",
"pylint>=3.3.1",
"pytest>=8.3.3",
"ruff>=0.8.0",
"semantic-release>=0.1.0",
]

Expand Down
1 change: 1 addition & 0 deletions uvPython3.12.lock

0 comments on commit 8c0bd9b

Please sign in to comment.