Skip to content

Commit

Permalink
Merge pull request #78 from ngi-nix/flake
Browse files Browse the repository at this point in the history
Add Nix flake as a build system
  • Loading branch information
pombredanne authored Apr 10, 2023
2 parents 7a4e715 + 0ce080e commit 5dc7d88
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 0 deletions.
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

0 comments on commit 5dc7d88

Please sign in to comment.