diff --git a/.gitignore b/.gitignore index 339dca50..31f9176f 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,6 @@ tcl # Ignore Jupyter Notebook related temp files .ipynb_checkpoints/ + +# Nix +/result* diff --git a/default.nix b/default.nix new file mode 100644 index 00000000..2cd9107f --- /dev/null +++ b/default.nix @@ -0,0 +1,3 @@ +(import (fetchTarball https://github.com/edolstra/flake-compat/archive/b4a34015c698c7793d592d66adbab377907a2be8.tar.gz) { + src = builtins.fetchGit ./.; +}).defaultNix diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..08d2b246 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1658380158, + "narHash": "sha256-DBunkegKWlxPZiOcw3/SNIFg93amkdGIy2g0y/jDpHg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a65b5b3f5504b8b89c196aba733bdf2b0bd13c16", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..aaddceaa --- /dev/null +++ b/flake.nix @@ -0,0 +1,25 @@ +{ + description = "Parse and compare all the package versions and all the ranges. From debian, npm, pypi, ruby and more. Process all the version range specs and expressions."; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + }; + + outputs = { self, nixpkgs }: ({ + overlays.default = import ./overlay.nix; + }) // ( + let + supportedSystems = [ "aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux" ]; + forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system); + nixpkgsFor = forAllSystems (system: self.overlays.default null nixpkgs.legacyPackages.${system}); + in + { + packages = forAllSystems (system: rec { + python3Packages = { + inherit (nixpkgsFor.${system}.python3Packages) univers; + }; + default = python3Packages.univers; + }); + } + ); +} diff --git a/overlay.nix b/overlay.nix new file mode 100644 index 00000000..22e223a5 --- /dev/null +++ b/overlay.nix @@ -0,0 +1,42 @@ +final: prev: rec { + python3 = prev.python3.override { + packageOverrides = final: prev: + { + univers = python3Packages.callPackage + ({ lib + , buildPythonPackage + , git + , setuptools-scm + , attrs + , packaging + , pyparsing + , semantic-version + , semver + , black + , commoncode + , pytestCheckHook + , saneyaml + }: buildPythonPackage rec { + name = "univers"; + + src = ./.; + + nativeBuildInputs = [ git setuptools-scm ]; + propagatedBuildInputs = [ attrs packaging pyparsing semantic-version semver ]; + checkInputs = [ black commoncode pytestCheckHook saneyaml ]; + + dontConfigure = true; # ./configure tries to setup virtualenv and downloads dependencies + + pythonImportsCheck = [ "univers" ]; + + meta = with lib; { + description = "Library for parsing version ranges and expressions"; + homepage = "https://github.com/nexB/univers"; + license = with licenses; [ asl20 bsd3 mit ]; + }; + }) + { }; + }; + }; + python3Packages = prev.recurseIntoAttrs python3.pkgs; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..8331b17a --- /dev/null +++ b/shell.nix @@ -0,0 +1,3 @@ +(import (fetchTarball https://github.com/edolstra/flake-compat/archive/b4a34015c698c7793d592d66adbab377907a2be8.tar.gz) { + src = builtins.fetchGit ./.; +}).shellNix