diff --git a/templates/cpp/.editorconfig b/cpp/.editorconfig similarity index 100% rename from templates/cpp/.editorconfig rename to cpp/.editorconfig diff --git a/templates/lua/.envrc b/cpp/.envrc similarity index 100% rename from templates/lua/.envrc rename to cpp/.envrc diff --git a/cpp/.gitignore b/cpp/.gitignore new file mode 100644 index 0000000..d288872 --- /dev/null +++ b/cpp/.gitignore @@ -0,0 +1,288 @@ +# Created by https://www.toptal.com/developers/gitignore/api/vim,linux,macos,windows,clion,c++,c +# Edit at https://www.toptal.com/developers/gitignore?templates=vim,linux,macos,windows,clion,c++,c + +### C ### +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +### C++ ### +# Prerequisites + +# Compiled Object files +*.slo + +# Precompiled Headers + +# Compiled Dynamic libraries + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai + +# Executables + +### CLion ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### CLion Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/vim,linux,macos,windows,clion,c++,c + +# Nix +.direnv +result diff --git a/templates/cpp/CMakeLists.txt b/cpp/CMakeLists.txt similarity index 100% rename from templates/cpp/CMakeLists.txt rename to cpp/CMakeLists.txt diff --git a/templates/cpp/LICENSE b/cpp/LICENSE similarity index 100% rename from templates/cpp/LICENSE rename to cpp/LICENSE diff --git a/templates/cpp/README.md b/cpp/README.md similarity index 100% rename from templates/cpp/README.md rename to cpp/README.md diff --git a/templates/cpp/cmake/BuildHelpers.cmake b/cpp/cmake/BuildHelpers.cmake similarity index 100% rename from templates/cpp/cmake/BuildHelpers.cmake rename to cpp/cmake/BuildHelpers.cmake diff --git a/templates/cpp/cmake/Config.cmake.in b/cpp/cmake/Config.cmake.in similarity index 100% rename from templates/cpp/cmake/Config.cmake.in rename to cpp/cmake/Config.cmake.in diff --git a/templates/cpp/default.nix b/cpp/default.nix similarity index 100% rename from templates/cpp/default.nix rename to cpp/default.nix diff --git a/templates/cpp/flake.nix b/cpp/flake.nix similarity index 100% rename from templates/cpp/flake.nix rename to cpp/flake.nix diff --git a/templates/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt similarity index 100% rename from templates/cpp/src/CMakeLists.txt rename to cpp/src/CMakeLists.txt diff --git a/templates/cpp/src/simple.cc b/cpp/src/simple.cc similarity index 100% rename from templates/cpp/src/simple.cc rename to cpp/src/simple.cc diff --git a/templates/cpp/src/simple.h b/cpp/src/simple.h similarity index 100% rename from templates/cpp/src/simple.h rename to cpp/src/simple.h diff --git a/templates/cpp/src/simple_test.cc b/cpp/src/simple_test.cc similarity index 100% rename from templates/cpp/src/simple_test.cc rename to cpp/src/simple_test.cc diff --git a/templates/cpp/src/what_time.cc b/cpp/src/what_time.cc similarity index 100% rename from templates/cpp/src/what_time.cc rename to cpp/src/what_time.cc diff --git a/flake.nix b/flake.nix index 8e9a98f..31e6035 100644 --- a/flake.nix +++ b/flake.nix @@ -4,48 +4,26 @@ outputs = { self, nixpkgs, ... }@inputs: { templates = { cpp = { - path = ./templates/cpp; + path = ./cpp; description = "A nix based c++ development project skeleton with CMake"; }; - js-webapp = { - path = ./templates/js-webapp; - description = '' - Template for creating repo of webapp development with Javascript - and Typescript - ''; - }; - - pybind11 = { - path = ./templates/pybind11; - description = '' - Template for creating initial skeleton for a pybind11 project - ''; - }; - - maturin = { - path = ./templates/maturin; - description = '' - Minimal starting project for nix-based maturin package development - ''; - }; - python = { - path = ./templates/python; + path = ./python; description = '' Minimal starting project for nix-based python project development ''; }; rust = { - path = ./templates/rusr; + path = ./rust; description = '' Minimal starting project for nix-based rust project development ''; }; lua = { - path = ./templates/lua; + path = ./lua; description = '' Minimal starting project for nix-based lua project development ''; diff --git a/templates/js-webapp/.editorconfig b/lua/.editorconfig similarity index 100% rename from templates/js-webapp/.editorconfig rename to lua/.editorconfig diff --git a/templates/maturin/.envrc b/lua/.envrc similarity index 100% rename from templates/maturin/.envrc rename to lua/.envrc diff --git a/lua/.gitignore b/lua/.gitignore new file mode 100644 index 0000000..4dad6d5 --- /dev/null +++ b/lua/.gitignore @@ -0,0 +1,259 @@ +# Created by https://www.toptal.com/developers/gitignore/api/lua,vim,linux,macos,windows,jetbrains +# Edit at https://www.toptal.com/developers/gitignore?templates=lua,vim,linux,macos,windows,jetbrains + +### JetBrains ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### JetBrains Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### Lua ### +# Compiled Lua sources +luac.out + +# luarocks build files +*.src.rock +*.zip +*.tar.gz + +# Object files +*.o +*.os +*.ko +*.obj +*.elf + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo +*.def +*.exp + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/lua,vim,linux,macos,windows,jetbrains + + +# Nix +.direnv +result diff --git a/templates/lua/.luarc.json b/lua/.luarc.json similarity index 100% rename from templates/lua/.luarc.json rename to lua/.luarc.json diff --git a/templates/lua/flake.nix b/lua/flake.nix similarity index 100% rename from templates/lua/flake.nix rename to lua/flake.nix diff --git a/templates/lua/nix/development.nix b/lua/nix/development.nix similarity index 100% rename from templates/lua/nix/development.nix rename to lua/nix/development.nix diff --git a/templates/lua/stylua.toml b/lua/stylua.toml similarity index 100% rename from templates/lua/stylua.toml rename to lua/stylua.toml diff --git a/templates/lua/.editorconfig b/python/.editorconfig similarity index 100% rename from templates/lua/.editorconfig rename to python/.editorconfig diff --git a/templates/rust/.envrc b/python/.envrc similarity index 100% rename from templates/rust/.envrc rename to python/.envrc diff --git a/python/.gitignore b/python/.gitignore new file mode 100644 index 0000000..68b7edd --- /dev/null +++ b/python/.gitignore @@ -0,0 +1,388 @@ +# Created by https://www.toptal.com/developers/gitignore/api/python,pycharm,vim,linux,macos,windows +# Edit at https://www.toptal.com/developers/gitignore?templates=python,pycharm,vim,linux,macos,windows + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### PyCharm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### Python Patch ### +# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration +poetry.toml + +# ruff +.ruff_cache/ + +# LSP config files +pyrightconfig.json + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/python,pycharm,vim,linux,macos,windows + + +# Nix +.direnv +result diff --git a/templates/python/flake.nix b/python/flake.nix similarity index 92% rename from templates/python/flake.nix rename to python/flake.nix index 6750859..3d0af93 100644 --- a/templates/python/flake.nix +++ b/python/flake.nix @@ -16,7 +16,7 @@ imports = [ ./nix/development.nix ]; perSystem = { system, config, pkgs-dev, ... }: { - formatter = pkgs-dev.nixfmt-classic; + formatter = pkgs-dev.nixpkgs-fmt; }; }; } diff --git a/templates/python/hello/__init__.py b/python/hello/__init__.py similarity index 100% rename from templates/python/hello/__init__.py rename to python/hello/__init__.py diff --git a/python/hello/app.py b/python/hello/app.py new file mode 100644 index 0000000..cc81bbf --- /dev/null +++ b/python/hello/app.py @@ -0,0 +1,2 @@ +if __name__ == "__main__": + print(f"Hello!, 123") diff --git a/templates/python/nix/development.nix b/python/nix/development.nix similarity index 100% rename from templates/python/nix/development.nix rename to python/nix/development.nix diff --git a/templates/maturin/.editorconfig b/rust/.editorconfig similarity index 100% rename from templates/maturin/.editorconfig rename to rust/.editorconfig diff --git a/rust/.envrc b/rust/.envrc new file mode 100644 index 0000000..0c1d972 --- /dev/null +++ b/rust/.envrc @@ -0,0 +1,28 @@ +# vi: ft=bash +# shellcheck shell=bash + +use flake; + +# If .env missing; restore from .env.example and validate +# See https://github.com/direnv/direnv/wiki/.envrc-Boilerplate + +if [[ -f .env.sample ]]; then + if ! command -v createnv > /dev/null; then + echo 'WARN|https://github.com/cuducos/createnv' + fi +fi + +if [[ -f .env.example ]]; then + if ! command -v createnv --source .env.example > /dev/null; then + echo 'WARN|https://github.com/cuducos/createnv' + elif [[ ! -f .env ]]; then + createnv --use-default --overwrite \ + || echo 'ERROR|https://github.com/cuducos/createnv' + if command dotenv-linter --version >&/dev/null; then + dotenv-linter .env || echo 'ERROR|https://dotenv-linter.github.io' + fi + fi +fi + +export LSP_AUTOSTART=1 +dotenv_if_exists || direnv status # https://direnv.net/man/direnv-stdlib.1.html diff --git a/rust/.gitignore b/rust/.gitignore new file mode 100644 index 0000000..f5731bd --- /dev/null +++ b/rust/.gitignore @@ -0,0 +1,232 @@ +# Created by https://www.toptal.com/developers/gitignore/api/vim,linux,macos,pycharm,windows,rust +# Edit at https://www.toptal.com/developers/gitignore?templates=vim,linux,macos,pycharm,windows,rust + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### PyCharm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### Rust ### +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/vim,linux,macos,pycharm,windows,rust + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# Nix +.direnv +result diff --git a/templates/rust/flake.nix b/rust/flake.nix similarity index 100% rename from templates/rust/flake.nix rename to rust/flake.nix diff --git a/templates/rust/nix/development.nix b/rust/nix/development.nix similarity index 100% rename from templates/rust/nix/development.nix rename to rust/nix/development.nix diff --git a/templates/rust/toolchain.toml b/rust/toolchain.toml similarity index 100% rename from templates/rust/toolchain.toml rename to rust/toolchain.toml diff --git a/templates/cpp/.gitignore b/templates/cpp/.gitignore deleted file mode 100644 index 69b8c94..0000000 --- a/templates/cpp/.gitignore +++ /dev/null @@ -1,45 +0,0 @@ -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app - -# Build -build - -# Nix -result - -# Vscode -.vscode/ - -# Env -.direnv -.envrc \ No newline at end of file diff --git a/templates/js-webapp/.gitignore b/templates/js-webapp/.gitignore deleted file mode 100644 index 462aa90..0000000 --- a/templates/js-webapp/.gitignore +++ /dev/null @@ -1,94 +0,0 @@ -/.direnv/ -.envrc - -# See http://help.github.com/ignore-files/ for more about ignoring files. - -# compiled output -/dist -/tmp -/out-tsc - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# IDEs and editors -.idea -.project -.classpath -.c9/ -*.launch -.settings/ -*.sublime-workspace - -# IDE - VSCode -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json - -# misc -.sass-cache -connect.lock -typings - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* - - -# Dependency directories -node_modules/ -jspm_packages/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env - -# next.js build output -.next - -# Lerna -lerna-debug.log - -# System Files -.DS_Store -Thumbs.db diff --git a/templates/js-webapp/flake.nix b/templates/js-webapp/flake.nix deleted file mode 100644 index 09fe32d..0000000 --- a/templates/js-webapp/flake.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ - description = "An awesome javascript/typescript web application"; - - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; - utils.url = "github:numtide/flake-utils"; - devshell.url = "github:numtide/devshell"; - }; - - outputs = { self, nixpkgs, utils, devshell, ... }@inputs: - utils.lib.eachDefaultSystem (system: { - devShell = - let - pkgs = import nixpkgs { - inherit system; - - overlays = [ devshell.overlays.default ]; - }; - in - pkgs.devshell.mkShell { - name = "js-webapp-basics"; - - commands = with pkgs; [ - { name = "yarn"; package = yarn; } - { name = "node"; package = nodejs; } - { name = "create-react-app"; package = nodePackages.create-react-app; } - ]; - }; - }); -} diff --git a/templates/lua/.gitignore b/templates/lua/.gitignore deleted file mode 100644 index 4c2e4ec..0000000 --- a/templates/lua/.gitignore +++ /dev/null @@ -1,115 +0,0 @@ -# Created by https://www.toptal.com/developers/gitignore/api/lua,linux,macos,vim -# Edit at https://www.toptal.com/developers/gitignore?templates=lua,linux,macos,vim - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### Lua ### -# Compiled Lua sources -luac.out - -# luarocks build files -*.src.rock -*.zip -*.tar.gz - -# Object files -*.o -*.os -*.ko -*.obj -*.elf - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo -*.def -*.exp - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex - - -### macOS ### -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### macOS Patch ### -# iCloud generated files -*.icloud - -### Vim ### -# Swap -[._]*.s[a-v][a-z] -!*.svg # comment out if you don't need vector files -[._]*.sw[a-p] -[._]s[a-rt-v][a-z] -[._]ss[a-gi-z] -[._]sw[a-p] - -# Session -Session.vim -Sessionx.vim - -# Temporary -.netrwhist -# Auto-generated tag files -tags -# Persistent undo -[._]*.un~ - -# End of https://www.toptal.com/developers/gitignore/api/lua,linux,macos,vim diff --git a/templates/maturin/README.md b/templates/maturin/README.md deleted file mode 100644 index ffa90af..0000000 --- a/templates/maturin/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# Maturin Basics Flake Template - -## How to Use? - -1. Init your project with this template - - ```console - $ nix flake init --template "github:nixvital/flake-templates#maturin-basics" - ``` - - -2. Get into the devshell by - - ```console - $ nix develop . - ``` - -3. Now, use `maturin` to initialize your project, and choose `pyo3`. - - ```console - $ maturin init - ``` - -4. Write code! - -## How to test the resulting python package - -If you are using `virtualenv` or `conda`, `maturin develop` is probably the way to go. However, it does not work for this nix-based development environment (let me know if you have a better idea to get `maturin develop` working!) - -For now, I provided the packaging of the resulting python package [in the template](./nix/pkgs/self/default.nix). - -You will need to adapt it to your project by - -1. Update the name and version of package -2. The hash for the `cargoDeps` will also need to be updated - - **Note**: I usually just build it once and let it complain and show the true hash -3. Add your dependencies. - -To test the package in a devshell, run `nix develop .#test`. diff --git a/templates/maturin/flake.nix b/templates/maturin/flake.nix deleted file mode 100644 index 3c65a48..0000000 --- a/templates/maturin/flake.nix +++ /dev/null @@ -1,83 +0,0 @@ -# This is based on viper's article https://ayats.org/blog/nix-rustup - -{ - description = "Minimal starting project for nix-based maturin package development"; - - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; - utils.url = "github:numtide/flake-utils"; - devshell.url = "github:numtide/devshell"; - rust-overlay.url = "github:oxalica/rust-overlay"; - }; - - outputs = { self, nixpkgs, utils, devshell, rust-overlay, ... }@inputs: { - overlays.default = final: prev: { - pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ - (py-final: py-prev: { - maturin-basics = py-final.callPackage ./nix/pkgs/self { }; - }) - ]; - }; - } // utils.lib.eachDefaultSystem (system: { - # The main development environment - devShells.default = - let - pkgs = import nixpkgs { - inherit system; - - overlays = [ - devshell.overlays.default - rust-overlay.overlays.default - ]; - }; - - toolchain = pkgs.rust-bin.fromRustupToolchainFile ./toolchain.toml; - - pythonEnv = pkgs.python3.withPackages (ps: with ps; [ - numpy - ]); - - in - pkgs.devshell.mkShell { - name = "maturin-basics"; - - commands = with pkgs; [ - { name = "maturin"; package = maturin; } - { name = "python"; package = pythonEnv; } - ]; - - packages = [ - toolchain - pkgs.rust-analyzer-unwrapped - ]; - - env = [ - { - name = "RUST_SRC_PATH"; - value = "${toolchain}/lib/rustlib/src/rust/library"; - } - ]; - }; - - # The development environment for testing the resulting python package. - devShells.test = - let - pkgs = import nixpkgs { - inherit system; - overlays = [ devshell.overlays.default self.overlays.default ]; - }; - in - pkgs.devshell.mkShell { - name = "maturin-basics-test"; - - commands = with pkgs; [ - { - name = "python"; - package = pkgs.python3.withPackages (ps: with ps; [ - maturin-basics - ]); - } - ]; - }; - }); -} diff --git a/templates/maturin/nix/pkgs/self/default.nix b/templates/maturin/nix/pkgs/self/default.nix deleted file mode 100644 index 59ecd4e..0000000 --- a/templates/maturin/nix/pkgs/self/default.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ - stdenv, - lib, - buildPythonPackage, - fetchFromGitHub, - pytestCheckHook, - pythonOlder, - rustPlatform, - numpy -}: - -buildPythonPackage rec { - pname = "maturin-basics"; - version = "0.1.0"; - format = "pyproject"; - - disabled = pythonOlder "3.7"; - - src = ../../..; - - cargoDeps = rustPlatform.fetchCargoTarball { - inherit src; - name = "${pname}-${version}"; - hash = "sha256-tMd3EH3ruSGZkKLA7Lac0uOFcuZcYd+dsIsP1xaEisc="; - }; - - nativeBuildInputs = with rustPlatform; [ - cargoSetupHook - maturinBuildHook - ]; - - propagatedBuildInputs = [ - numpy - ]; - - pythonImportsCheck = [ "maturin_basics" ]; -} diff --git a/templates/maturin/toolchain.toml b/templates/maturin/toolchain.toml deleted file mode 100644 index f19769d..0000000 --- a/templates/maturin/toolchain.toml +++ /dev/null @@ -1,4 +0,0 @@ -[toolchain] -channel = "nightly" -components = [ "rustfmt", "rust-src" ] -profile = "minimal" diff --git a/templates/pybind11/.editorconfig b/templates/pybind11/.editorconfig deleted file mode 100644 index 65b9f8f..0000000 --- a/templates/pybind11/.editorconfig +++ /dev/null @@ -1,28 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true -indent_style = space -indent_size = 2 -max_line_length = 120 - -[*.md] -trim_trailing_whitespace = false - -[{makefile,Makefile}] -indent_style = tab -tab_width = 4 - -[Makefile.*] -indent_style = tab -tab_width = 4 - -[*.{tab,tsv}] -indent_style = tab -tab_width = 1 - -[*.py] -indent_size = 4 diff --git a/templates/pybind11/.gitignore b/templates/pybind11/.gitignore deleted file mode 100644 index 69b8c94..0000000 --- a/templates/pybind11/.gitignore +++ /dev/null @@ -1,45 +0,0 @@ -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app - -# Build -build - -# Nix -result - -# Vscode -.vscode/ - -# Env -.direnv -.envrc \ No newline at end of file diff --git a/templates/pybind11/CMakeLists.txt b/templates/pybind11/CMakeLists.txt deleted file mode 100644 index 6f2e55e..0000000 --- a/templates/pybind11/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -cmake_minimum_required(VERSION 3.17) - -project( - starterpp - VERSION 1.0.0 - LANGUAGES C CXX) - -set(CMAKE_CXX_STANDARD 23) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") -set(CMAKE_POSITION_INDEPENDENT_CODE ON) -set(CMAKE_CXX_VISIBILITY_PRESET hidden) - -# By default build the release version with O3 -if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) -endif() -set(CMAKE_CXX_FLAGS_RELEASE "-O3") - -message(STATUS "Using compiler ${CMAKE_CXX_COMPILER_ID} ...") - -include(CMakeDependentOption) # This is a really useful scripts that creates options that depends on other options. It can even be used with generator expressions ! -include(GNUInstallDirs) # This will define the default values for installation directories (all platforms even if named GNU) -include(InstallRequiredSystemLibraries) # Tell CMake that the `install` target needs to install required system libraries (eg: Windows SDK) -include(CMakePackageConfigHelpers) # Helper to create relocatable packages - -# +----------------------------------------+ -# | Options | -# +----------------------------------------+ - -option(STARTERPP_ENABLE_TEST "Should ${PROJECT_NAME} build the unit tests" ON) - -# +----------------------------------------+ -# | Dependencies | -# +----------------------------------------+ - -if(STARTERPP_ENABLE_TEST) - include(GoogleTest) - find_package(GTest REQUIRED) - enable_testing() -endif() - -find_package(Python3 COMPONENTS Interpreter Development.Module REQUIRED) -find_package(pybind11 CONFIG REQUIRED) -find_package(spdlog REQUIRED) - -############################################################# -# Targets # -############################################################# - -include_directories(${PROJECT_SOURCE_DIR}/src) -pybind11_add_module(starterpp src/starterpp.cc) diff --git a/templates/pybind11/flake.nix b/templates/pybind11/flake.nix deleted file mode 100644 index 9340fbf..0000000 --- a/templates/pybind11/flake.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ - description = "Starter skeleton for a pybind11 project"; - - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05"; - - utils.url = "github:numtide/flake-utils"; - }; - - outputs = { self, nixpkgs, utils, ... }@inputs: { - overlays = { - # This placeholder is for adding packages for development overlay. - dev = final: prev: {}; - - # The default overlay adds the resulting pybind11 package. - default = final: prev: { - pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ - (py-final: py-prev: { - starterpp = py-final.callPackage ./nix/default.nix {}; - }) - ]; - }; - }; - } // utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system: let - pkgs-dev = import nixpkgs { - inherit system; - overlays = [ self.overlays.dev ]; - }; - - pkgs = import nixpkgs { - inherit system; - overlays = [ self.overlays.default ]; - }; - - in { - devShells.default = pkgs-dev.callPackage ./nix/dev-shell.nix { - stdenv = pkgs-dev.clang16Stdenv; - clang-tools = pkgs-dev.clang-tools_16; - }; - - # Normally you do not need this playground dev shell. Put it here just for - # testing purpose so that we can explicitly test the resulting package. - devShells.playground = pkgs.mkShell { - packages = [ - (pkgs.python3.withPackages (pyPkgs: with pyPkgs; [ - starterpp - ])) - ]; - }; - - packages.default = pkgs.python3Packages.starterpp; - }); -} diff --git a/templates/pybind11/nix/default.nix b/templates/pybind11/nix/default.nix deleted file mode 100644 index b18394a..0000000 --- a/templates/pybind11/nix/default.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ lib -, buildPythonPackage -, pythonOlder -, cmake -, pybind11 -, spdlog -, numpy -}: - -buildPythonPackage rec { - pname = "starterpp"; - version = "1.0.0"; - format = "setuptools"; - - disabled = pythonOlder "3.8"; - - src = ../.; - - propagatedBuildInputs = [ - numpy - ]; - - buildInputs = [ - pybind11 - spdlog - ]; - - nativeBuildInputs = [ - cmake - ]; - - dontUseCmakeConfigure = true; - - pythonImportCheck = [ "starterpp" ]; - - meta = with lib; { - description = '' - An example nix powered pybind11 starter skeleton - ''; - homepage = "https://github.com/nixvital/flake-templates/tree/main/templates/pybind11-starter-kit"; - license = licenses.mit; - maintainers = with maintainers; [ breakds ]; - }; -} diff --git a/templates/pybind11/nix/dev-shell.nix b/templates/pybind11/nix/dev-shell.nix deleted file mode 100644 index 0a0ca1a..0000000 --- a/templates/pybind11/nix/dev-shell.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ mkShell -, stdenv -, clang-tools -, python3 -, cmake -, cmakeCurses -, gtest -, spdlog -}: - -let pythonEnv = python3.withPackages (pyPkgs: with pyPkgs; [ - numpy - pybind11 - ]); - - mkClangShell = mkShell.override { - # Using clang 16 for being a little bit cutting edge. Just use the normal - # stdenv if you do not need this. - stdenv = stdenv; - }; - -in mkClangShell rec { - name = "my-pybind11-proj"; - - packages = [ - # C++ Toolchain - cmake - cmakeCurses - - # Python environment - pythonEnv - - # Development Tools - clang-tools - - # Other dependencies - spdlog - gtest - ]; - - shellHook = '' - export PS1="$(echo -e '\uf1c0') {\[$(tput sgr0)\]\[\033[38;5;228m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]} (${name}) \\$ \[$(tput sgr0)\]" - ''; -} diff --git a/templates/pybind11/setup.py b/templates/pybind11/setup.py deleted file mode 100644 index c07bc87..0000000 --- a/templates/pybind11/setup.py +++ /dev/null @@ -1,93 +0,0 @@ -import os -import re -import subprocess -import sys -from pathlib import Path - -from setuptools import Extension, setup -from setuptools.command.build_ext import build_ext - -# Convert distutils Windows platform specifiers to CMake -A arguments -PLAT_TO_CMAKE = { - "win32": "Win32", - "win-amd64": "x64", - "win-arm32": "ARM", - "win-arm64": "ARM64", -} - - -# A CMakeExtension needs a sourcedir instead of a file list. -# The name must be the _single_ output extension from the CMake build. -# If you need multiple extensions, see scikit-build. -class CMakeExtension(Extension): - def __init__(self, name: str, sourcedir: str = "") -> None: - super().__init__(name, sources=[]) - self.sourcedir = os.fspath(Path(sourcedir).resolve()) - - -class CMakeBuild(build_ext): - def get_cmake_args(self, ext: CMakeExtension): - # Must be in this form due to bug in .resolve() only fixed in Python 3.10+ - ext_fullpath = Path.cwd() / self.get_ext_fullpath(ext.name) # type: ignore[no-untyped-call] - extdir = ext_fullpath.parent.resolve() - - cmake_args = [ - f"-DSTARTERPP_ENABLE_TEST=OFF", - f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}{os.sep}", - f"-DCMAKE_BUILD_TYPE=Release", # not used on MSVC, but no harm - ] - - if "CMAKE_ARGS" in os.environ: - cmake_args += [item for item in os.environ["CMAKE_ARGS"].split(" ") if item] - - if sys.platform.startswith("darwin"): - # Cross-compile support for macOS - respect ARCHFLAGS if set - archs = re.findall(r"-arch (\S+)", os.environ.get("ARCHFLAGS", "")) - if archs: - cmake_args += ["-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))] - - return cmake_args - - def get_build_args(self): - build_args = [] - - # Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level - # across all generators. - if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ: - # self.parallel is a Python 3 only way to set parallel jobs by hand - # using -j in the build_ext call, not supported by pip or PyPA-build. - if hasattr(self, "parallel") and self.parallel: - # CMake 3.12+ only. - build_args += [f"-j{self.parallel}"] - return build_args - - def build_extension(self, ext: CMakeExtension) -> None: - build_temp = Path(self.build_temp) / ext.name - if not build_temp.exists(): - build_temp.mkdir(parents=True) - - subprocess.run( - ["cmake", ext.sourcedir] + self.get_cmake_args(ext), cwd=build_temp, check=True - ) - subprocess.run( - ["cmake", "--build", "."] + self.get_build_args(), cwd=build_temp, check=True - ) - - -# The information here can also be placed in setup.cfg - better separation of -# logic and declaration, and simpler if you include description/version in a file. -setup( - name="starterpp", - version="1.0.0", - author="Break Yang", - author_email="breakds@gmail.com", - description="An example nix powered pybind11 starter skeleton", - long_description="An example nix powered pybind11 starter skeleton", - # Here ``sourcedir`` is supposed to contain the top-level CMakeLists.txt. In - # this case since the CMakeLists.txt is at the same directory of setup.py, - # we just specify "" as the relative source directory. - ext_modules=[CMakeExtension("starterpp", sourcedir="")], - cmdclass={"build_ext": CMakeBuild}, - zip_safe=False, - python_requires=">=3.8", -) diff --git a/templates/pybind11/src/starterpp.cc b/templates/pybind11/src/starterpp.cc deleted file mode 100644 index 74dea2a..0000000 --- a/templates/pybind11/src/starterpp.cc +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include - -namespace py = pybind11; - -int CountUniqueIntegers(py::array_t input_array) { - py::buffer_info buf_info = input_array.request(); - int *ptr = static_cast(buf_info.ptr); - int length = buf_info.size; - - std::unordered_set unique_set(ptr, ptr + length); - return unique_set.size(); -} - -PYBIND11_MODULE(starterpp, m) { - m.def("count_unique_integers", &CountUniqueIntegers, "Count unique integers in a numpy array", - py::arg("input_array").noconvert()); -} diff --git a/templates/python/.editorconfig b/templates/python/.editorconfig deleted file mode 100644 index 65b9f8f..0000000 --- a/templates/python/.editorconfig +++ /dev/null @@ -1,28 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true -indent_style = space -indent_size = 2 -max_line_length = 120 - -[*.md] -trim_trailing_whitespace = false - -[{makefile,Makefile}] -indent_style = tab -tab_width = 4 - -[Makefile.*] -indent_style = tab -tab_width = 4 - -[*.{tab,tsv}] -indent_style = tab -tab_width = 1 - -[*.py] -indent_size = 4 diff --git a/templates/python/.gitignore b/templates/python/.gitignore deleted file mode 100644 index 90b8e8b..0000000 --- a/templates/python/.gitignore +++ /dev/null @@ -1,165 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ - - -result -.direnv -.envrc diff --git a/templates/python/hello/app.py b/templates/python/hello/app.py deleted file mode 100644 index 776af98..0000000 --- a/templates/python/hello/app.py +++ /dev/null @@ -1,5 +0,0 @@ -import numpy as np - -if __name__ == "__main__": - a = np.array([1, 2, 3]) - print(f"Hello!, the mean is {a.mean()}") diff --git a/templates/rust/.editorconfig b/templates/rust/.editorconfig deleted file mode 100644 index 65b9f8f..0000000 --- a/templates/rust/.editorconfig +++ /dev/null @@ -1,28 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true -indent_style = space -indent_size = 2 -max_line_length = 120 - -[*.md] -trim_trailing_whitespace = false - -[{makefile,Makefile}] -indent_style = tab -tab_width = 4 - -[Makefile.*] -indent_style = tab -tab_width = 4 - -[*.{tab,tsv}] -indent_style = tab -tab_width = 1 - -[*.py] -indent_size = 4