Skip to content
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

Add Nix flake as a build system #78

Merged
merged 1 commit into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ tcl

# Ignore Jupyter Notebook related temp files
.ipynb_checkpoints/

# Nix
/result*
3 changes: 3 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(import (fetchTarball https://github.com/edolstra/flake-compat/archive/b4a34015c698c7793d592d66adbab377907a2be8.tar.gz) {
src = builtins.fetchGit ./.;
}).defaultNix
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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;
});
}
);
}
42 changes: 42 additions & 0 deletions overlay.nix
Original file line number Diff line number Diff line change
@@ -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;
}
3 changes: 3 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(import (fetchTarball https://github.com/edolstra/flake-compat/archive/b4a34015c698c7793d592d66adbab377907a2be8.tar.gz) {
src = builtins.fetchGit ./.;
}).shellNix