mirror of
https://github.com/quantum5/win2xcur.git
synced 2025-04-24 10:11:57 -04:00
nix flakes support
- support nix build - add dev env with direnv hook - update readme
This commit is contained in:
parent
c52992f2b1
commit
eeb7d900a4
2
.envrc
Normal file
2
.envrc
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# use https://github.com/nix-community/nix-direnv
|
||||||
|
use_flake ".#python311.dev_env"
|
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -143,3 +143,10 @@ cython_debug/
|
||||||
# For testing
|
# For testing
|
||||||
input/
|
input/
|
||||||
output/
|
output/
|
||||||
|
|
||||||
|
# nix build
|
||||||
|
result
|
||||||
|
.direnv
|
||||||
|
|
||||||
|
# vs code
|
||||||
|
.vscode
|
||||||
|
|
|
@ -22,6 +22,10 @@ To install from GitHub:
|
||||||
|
|
||||||
pip install -e git+https://github.com/quantum5/win2xcur.git
|
pip install -e git+https://github.com/quantum5/win2xcur.git
|
||||||
|
|
||||||
|
To install from nix flakes:
|
||||||
|
|
||||||
|
nix profile install "github:quantum5/win2xcur#python311.bin"
|
||||||
|
|
||||||
## Usage: `win2xcur`
|
## Usage: `win2xcur`
|
||||||
|
|
||||||
For example, if you want to convert [the sample cursor](sample/crosshair.cur)
|
For example, if you want to convert [the sample cursor](sample/crosshair.cur)
|
||||||
|
@ -52,3 +56,6 @@ are using unconventional distros (e.g. Alpine) and are getting errors related
|
||||||
to `wand`, please see the [Wand documentation on installation][wand-install].
|
to `wand`, please see the [Wand documentation on installation][wand-install].
|
||||||
|
|
||||||
[wand-install]: https://docs.wand-py.org/en/0.6.7/guide/install.html
|
[wand-install]: https://docs.wand-py.org/en/0.6.7/guide/install.html
|
||||||
|
|
||||||
|
Nix installation will not interfere with your local python, try this
|
||||||
|
option if you have dependencies or python version conflicts.
|
||||||
|
|
63
build_pkg/default.nix
Normal file
63
build_pkg/default.nix
Normal file
|
@ -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;}
|
15
build_pkg/deps/default.nix
Normal file
15
build_pkg/deps/default.nix
Normal file
|
@ -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;
|
||||||
|
}
|
13
build_pkg/filter.nix
Normal file
13
build_pkg/filter.nix
Normal file
|
@ -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")
|
||||||
|
];
|
||||||
|
}
|
76
flake.lock
Normal file
76
flake.lock
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"makes": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1718642562,
|
||||||
|
"narHash": "sha256-Zma+WJHFOOId/i/jrNamYxz7LTX2wPnnoTarlTop0Ws=",
|
||||||
|
"owner": "fluidattacks",
|
||||||
|
"repo": "makes",
|
||||||
|
"rev": "dcb3432e36a87b38e89530e6ca10d3dfa80c36ad",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "fluidattacks",
|
||||||
|
"repo": "makes",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nix_filter": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1710156097,
|
||||||
|
"narHash": "sha256-1Wvk8UP7PXdf8bCCaEoMnOT1qe5/Duqgj+rL8sRQsSM=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "nix-filter",
|
||||||
|
"rev": "3342559a24e85fc164b295c3444e8a139924675b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "nix-filter",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1667092106,
|
||||||
|
"narHash": "sha256-ZQwHNd/RemupaV52ePNNv4Kp+LHzPjssEAumLijum4E=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"rev": "2c15a4c90737d33309daf869bae0daaa35eeb264",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1719080280,
|
||||||
|
"narHash": "sha256-BBIherhYksOLQjlqh72/SvKLvdHgDyySaQD6rEm+n8Y=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "74d8dda4f86d6328a713575310ff7883547412c0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"makes": "makes",
|
||||||
|
"nix_filter": "nix_filter",
|
||||||
|
"nixpkgs": "nixpkgs_2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
43
flake.nix
Normal file
43
flake.nix
Normal file
|
@ -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;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue