forked from python-acoustics/python-acoustics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
76 lines (66 loc) · 2.14 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{
description = "Python module for loading sound files as xarray arrays.";
inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable";
inputs.utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, utils }: let
attribute = "acoustics";
inherit (nixpkgs) lib;
interpreters-to-test = [
"python39"
"python310"
"python3"
];
# Overlay we expose externally
overlay = final: prev: {
pythonPackagesOverrides = (prev.pythonPackagesOverrides or []) ++ [
(self: super: {
"${attribute}" = self.callPackage ./. {};
})
];
};
create-overlay-for-interpreter = interpreter: (self: super: {
"${interpreter}" = let
self = super.${interpreter}.override {
inherit self;
packageOverrides = lib.composeManyExtensions super.pythonPackagesOverrides;
};
in self;
});
overlay-for-testing = lib.composeManyExtensions ([
overlay
] ++ (map create-overlay-for-interpreter interpreters-to-test));
in {
overlays = {
default = overlay;
};
} // (utils.lib.eachSystem [ "x86_64-linux" ] (system: let
# Our own overlay does not get applied to nixpkgs because that would lead to
# an infinite recursion. Therefore, we need to import nixpkgs and apply it ourselves.
pkgs = import nixpkgs {
inherit system;
overlays = [
overlay-for-testing
];
};
python = pkgs.python3;
in rec {
packages = rec {
# Development environment that includes our package, its dependencies
# and additional dev inputs.
devEnv = python.withPackages(_: (pkg.nativeBuildInputs ++ pkg.propagatedBuildInputs));
pkg = python.pkgs."${attribute}";
default = pkg;
} // (lib.genAttrs interpreters-to-test (interpreter: pkgs."${interpreter}".pkgs.acoustics));
devShells = {
default = pkgs.mkShell {
nativeBuildInputs = [
packages.devEnv
];
shellHook = ''
export PYTHONPATH=$(readlink -f .):$PYTHONPATH
'';
};
};
checks = lib.genAttrs interpreters-to-test (interpreter: pkgs."${interpreter}".pkgs.acoustics);
}));
}