-
Notifications
You must be signed in to change notification settings - Fork 6
/
flake.nix
97 lines (92 loc) · 3.06 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
{
description = "Run Python code right in your Telegram messages";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ nixpkgs, flake-parts, ... }:
let
readMetadata = { lib }: (
let
pyproject = builtins.fromTOML (
builtins.readFile ./pyproject.toml
);
in
(with pyproject.tool.poetry; {
inherit description;
homepage = documentation;
license = lib.meta.getLicenseFromSpdxId license;
})
);
in
flake-parts.lib.mkFlake { inherit inputs; } rec {
flake = rec {
lib.mkPackageRequirements =
{ overrides, requirements }:
overrides.extend (final: prev:
builtins.mapAttrs (package: reqs:
(builtins.getAttr package prev).overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ (builtins.map (pkg: prev.${pkg}) reqs);
})
) requirements
);
lib.mkTgpy =
{ system ? null
, pkgs ? import nixpkgs { inherit system; }
, poetry2nix ? inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }
}: poetry2nix.mkPoetryApplication {
projectDir = ./.;
preferWheels = false;
meta = readMetadata { lib = pkgs.lib; };
overrides = lib.mkPackageRequirements {
overrides = poetry2nix.defaultPoetryOverrides.extend (self: super: {
cryptg-anyos = super.cryptg-anyos.override {
preferWheel = true;
};
nh3 = import ./nix/nh3overrides.nix { inherit self super pkgs; };
});
requirements = {
telethon-v1-24 = [ "setuptools" ];
pipreqs = [ "setuptools" ];
python-semantic-release = [ "setuptools" ];
};
};
};
};
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
perSystem = { self', pkgs, ... }: {
packages = {
tgpy = flake.lib.mkTgpy {
inherit pkgs;
};
default = self'.packages.tgpy;
};
devShells.default =
let
poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs; };
in
(poetry2nix.mkPoetryEnv {
projectDir = ./.;
preferWheels = true;
groups = [ "dev" ];
}).overrideAttrs (old: {
nativeBuildInputs = with pkgs; [
poetry
python3Packages.python-lsp-server
] ++ (with pkgs.python3Packages; [
mkdocs
mkdocs-material
mkdocs-redirects
mkdocs-git-revision-date-localized-plugin
cairosvg
pillow
]);
});
formatter = pkgs.nixpkgs-fmt;
};
};
}