-
Notifications
You must be signed in to change notification settings - Fork 73
/
flake.nix
133 lines (130 loc) · 4.19 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# -*- coding: utf-8 -*-
# :Project: metapensiero.pj — Nix package file
# :Created: dom 17 lug 2022, 11:06:06
# :Author: Alberto Berti <[email protected]>
# :License: GNU General Public License version 3 or later
# :Copyright: © 2022 Alberto Berti
#
{
description = "JavaScripthon: a Python 3 to ES6 JavaScript translator";
inputs = {
dukpy = {
url = "github:amol-/dukpy/0.2.3";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
gitignore = {
url = "github:hercules-ci/gitignore.nix";
# Use the same nixpkgs
inputs.nixpkgs.follows = "nixpkgs";
};
meta = {
url = "github:srossross/Meta/0.4.1";
flake = false;
};
};
outputs = { self, nixpkgs, dukpy, flake-utils, gitignore, meta}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
inherit (pkgs.lib) genAttrs recursiveUpdate;
inherit (builtins) elemAt filter getAttr;
inherit (gitignore.lib) gitignoreSource;
pyVersions = ["python37" "python38" "python39" "python310"];
/* Find the Python version associated with `pkgs.python3`*/
findDefaultPyVersion =
let
python3 = getAttr "python3" pkgs;
defaultPy = filter (pyv: (getAttr pyv pkgs) == python3) pyVersions;
in elemAt defaultPy 0;
defPyVersion = findDefaultPyVersion;
/*
Make a Python application out of a Python version string and some
package details.
*/
mkPyApp = pyVersion: details:
let
py = getAttr pyVersion pkgs;
in py.pkgs.buildPythonApplication (details py pyVersion);
/*
Make a Python package out of a Python version string and some
package details.
*/
mkPyPkg = pyVersion: details:
let
py = getAttr pyVersion pkgs;
in py.pkgs.buildPythonPackage (details py pyVersion);
/*
Make an attr containing multiple packages
*/
mkMultiPyPkg = details:
let
multiPkgs = genAttrs pyVersions (pyv: mkPyPkg pyv details);
in multiPkgs // ( rec {
default = python3;
python3 = getAttr defPyVersion multiPkgs;
});
dukpyPkg = python: pyVersion: {
checkInputs = with python.pkgs; [
pytest
pytest-cov
mock
webassets
];
checkPhase = "pytest --ignore=tests/test_installer.py";
dontUseSetuptoolsShellHook = 1;
pname = "dukpy";
version = "0.2.3";
src = dukpy;
};
dukpyPkgs = mkMultiPyPkg dukpyPkg;
metaPkg = python: pyVersion: {
doCheck = false;
pname = "meta";
version = "0.4.1";
src = meta;
};
metaPkgs = mkMultiPyPkg metaPkg;
pjPkg = python: pyVersion: {
checkInputs = with python.pkgs; [
pytest
pytest-cov
];
checkPhase = "pytest";
pname = "javascripthon";
propagatedBuildInputs = [
(getAttr pyVersion dukpyPkgs)
(getAttr pyVersion metaPkgs)
];
version = builtins.readFile ./version.txt;
src = gitignoreSource ./.;
meta = {
homepage = "https://github.com/azazel75/metapensiero.pj";
description = "JavaScripthon: a Python 3 to ES6 JavaScript translator";
license = pkgs.lib.licenses.gpl3;
mainProgram = "pj";
};
};
pjPkgs = mkMultiPyPkg pjPkg;
in {
apps = rec {
default = javascripthon;
javascripthon = {
type = "app";
program = "${self.outputs.packages."${system}".app}/bin/pj";
};
pj = javascripthon;
};
packages = pjPkgs // {
all = pkgs.buildEnv {
name = "allpjs";
paths = map (pyv: pjPkgs."${pyv}") pyVersions;
pathsToLink = [ "/lib" ];
};
app = mkPyApp defPyVersion pjPkg;
};
checks.default = self.outputs.packages."${system}".all;
});
}