-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nix development support #19
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# use https://github.com/nix-community/nix-direnv | ||
use_flake ".#python311.dev_env" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,3 +143,10 @@ cython_debug/ | |
# For testing | ||
input/ | ||
output/ | ||
|
||
# nix build | ||
result | ||
.direnv | ||
|
||
# vs code | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
makesLib, | ||
nixpkgs, | ||
python_version, | ||
src, | ||
}: let | ||
deps = import ./deps { | ||
inherit nixpkgs python_version; | ||
}; | ||
|
||
# Define the package requirements | ||
build_required_deps = python_pkgs: { | ||
runtime_deps = with python_pkgs; [ | ||
numpy | ||
wand | ||
]; | ||
build_deps = with python_pkgs; [flit-core]; | ||
test_deps = with python_pkgs; [ | ||
mypy | ||
pytest | ||
pylint | ||
]; | ||
}; | ||
|
||
# The pkg builder | ||
bundle_builder = lib: pkgDeps: | ||
makesLib.makePythonPyprojectPackage { | ||
inherit (lib) buildEnv buildPythonPackage; | ||
inherit pkgDeps src; | ||
}; | ||
|
||
# Abstract builder to allow an alternative to override dependencies | ||
build_bundle = builder: | ||
# builder: Deps -> (PythonPkgs -> PkgDeps) -> (Deps -> PkgDeps -> Bundle) -> Bundle | ||
# Deps: are the default project dependencies | ||
# PythonPkgs -> PkgDeps: is the required dependencies builder | ||
# Deps -> PkgDeps -> Bundle: is the bundle builder | ||
builder deps build_required_deps bundle_builder; | ||
|
||
# Concrete bundle that uses python pkgs from the default | ||
# i.e. the python nixpkg from the flake | ||
bundle = build_bundle (default: required_deps: builder: builder default.lib (required_deps default.python_pkgs)); | ||
|
||
# Develompent environment | ||
dev_env = let | ||
template = makesLib.makePythonVscodeSettings { | ||
env = bundle.env.dev; | ||
bins = [ ]; | ||
name = "win2xcur-env-dev-template"; | ||
}; | ||
hook = makesLib.makeScript { | ||
name = "win2xcur-env-dev"; | ||
entrypoint = "${template}/template"; | ||
}; | ||
in nixpkgs.mkShell { | ||
packages = [bundle.env.dev]; | ||
shellHook = "${hook}/bin/dev"; | ||
}; | ||
|
||
# Executable application derivation | ||
bin = deps.lib.toPythonApplication bundle.pkg; | ||
in | ||
bundle // {inherit build_bundle dev_env bin;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
nixpkgs, | ||
python_version, | ||
}: let | ||
# Define required nixpkgs python builders | ||
lib = { | ||
buildEnv = nixpkgs."${python_version}".buildEnv.override; | ||
inherit (nixpkgs."${python_version}".pkgs) buildPythonPackage toPythonApplication; | ||
inherit (nixpkgs.python3Packages) fetchPypi; | ||
}; | ||
# Define the nixpkgs python packages overrides | ||
python_pkgs = nixpkgs."${python_version}Packages"; | ||
in { | ||
inherit lib python_pkgs; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
let | ||
metadata = (builtins.fromTOML (builtins.readFile ../pyproject.toml)).project; | ||
in | ||
path_filter: src: | ||
path_filter { | ||
root = src; | ||
include = [ | ||
"mypy.ini" | ||
"pyproject.toml" | ||
(path_filter.inDirectory metadata.name) | ||
(path_filter.inDirectory "tests") | ||
]; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
description = "win2xcur is a tool to convert Windows .cur and .ani cursors to Xcursor format."; | ||
inputs = { | ||
makes.url = "github:fluidattacks/makes"; | ||
nixpkgs.url = "github:nixos/nixpkgs"; | ||
nix_filter.url = "github:numtide/nix-filter"; | ||
}; | ||
outputs = { | ||
self, | ||
nixpkgs, | ||
nix_filter, | ||
makes, | ||
}: let | ||
path_filter = nix_filter.outputs.lib; | ||
src = import ./build_pkg/filter.nix path_filter self; | ||
out = system: python_version: let | ||
makesLib = makes.lib."${system}"; | ||
pkgs = nixpkgs.legacyPackages."${system}"; | ||
in | ||
import ./build_pkg { | ||
inherit src python_version makesLib; | ||
nixpkgs = pkgs; | ||
}; | ||
supported = ["python39" "python310" "python311"]; | ||
python_outs = system: | ||
(builtins.listToAttrs (map (name: { | ||
inherit name; | ||
value = out system name; | ||
}) | ||
supported)) | ||
// {build_with_python = out system; nixpkgs = nixpkgs.legacyPackages."${system}";}; | ||
systems = [ | ||
"aarch64-darwin" | ||
"aarch64-linux" | ||
"x86_64-darwin" | ||
"x86_64-linux" | ||
]; | ||
forAllSystems = nixpkgs.lib.genAttrs systems; | ||
in { | ||
packages = forAllSystems python_outs; | ||
defaultPackage = self.packages; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[project] | ||
name = "win2xcur" | ||
authors = [ | ||
{name = "quantum", email = "[email protected]"}, | ||
] | ||
classifiers = [ | ||
"Development Status :: 3 - Alpha", | ||
"Environment :: Win32 (MS Windows)", | ||
"Environment :: X11 Applications", | ||
"Intended Audience :: End Users/Desktop", | ||
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", | ||
"Operating System :: Microsoft :: Windows", | ||
"Operating System :: POSIX :: Linux", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Topic :: Desktop Environment", | ||
] | ||
requires-python = ">=3.9" | ||
dependencies = [ | ||
"numpy >=1.2.12, <2.0.0", | ||
"Wand >=0.6.13, <1.0.0", | ||
] | ||
description = "win2xcur is a tool to convert Windows .cur and .ani cursors to Xcursor format." | ||
dynamic = ["version"] | ||
|
||
[project.scripts] | ||
win2xcur = 'win2xcur.main.win2xcur:main' | ||
x2wincur = 'win2xcur.main.x2wincur:main' | ||
|
||
[build-system] | ||
requires = ["flit_core >=3.2,<4"] | ||
build-backend = "flit_core.buildapi" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def test_placeholder() -> None: | ||
assert 1 == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "0.2.0" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a mere guess, I do not know which are the ranges of versions that the library requires.