Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
95 lines (92 loc) · 3.47 KB
/
Copy pathflake.nix
File metadata and controls
95 lines (92 loc) · 3.47 KB
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
{
description = "alot: Terminal-based Mail User Agent";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.pyproject-nix.url = "github:pyproject-nix/pyproject.nix";
inputs.pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.url = "github:nix-systems/default";
outputs = {
self,
nixpkgs,
pyproject-nix,
systems,
}: let
project = pyproject-nix.lib.project.loadPyproject {projectRoot = ./.;};
eachSystem = nixpkgs.lib.genAttrs (import systems);
# the package is called gpg on PyPI and gpgme in nixpkgs
packageOverrides = final: prev: {gpg = final.gpgme;};
version = "0.dev+" + self.shortRev or self.dirtyShortRev or "override";
in {
packages = eachSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
python3 = pkgs.python3;
# let pyproject-nix generate the argument for buildPythonApplication
# from our pyproject.toml file
attrs = project.renderers.buildPythonPackage {
python = python3.override {inherit packageOverrides;};
};
# overwrite these attributes in the buildPythonApplication call
overrides = {
inherit version;
outputs = ["out" "doc" "man"];
postPatch = ''
substituteInPlace alot/settings/manager.py \
--replace /usr/share "$out/share"
'';
postInstall = ''
installShellCompletion --zsh --name _alot extra/completion/alot-completion.zsh
mkdir -p $out/share/{applications,alot}
cp -r extra/themes $out/share/alot
sed "s,/usr/bin,$out/bin,g" extra/alot.desktop > $out/share/applications/alot.desktop
'';
checkPhase = ''
python3 -m unittest -v
'';
nativeCheckInputs = with pkgs; [gnupg notmuch procps];
nativeBuildInputs = [python3.pkgs.sphinxHook pkgs.installShellFiles];
sphinxBuilders = ["html" "man"];
};
alot-pkg = python3.pkgs.buildPythonPackage (attrs // overrides);
alot-app = python3.pkgs.toPythonApplication alot-pkg;
in {
alot = alot-app;
docs =
pkgs.lib.trivial.warn "The docs attribute moved to alot.doc"
self.packages.${system}.alot.doc;
default = alot-app;
theme-test = pkgs.runCommand "theme-test.py" {
propagatedBuildInputs = [
(python3.withPackages (ps: [ alot-pkg ]))
];
} ''
install -Dm755 ${./extra/theme_test.py} $out/bin/theme-test.py
patchShebangs $out/bin
'';
});
devShells = eachSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
arg = project.renderers.withPackages {
python = pkgs.python3.override {inherit packageOverrides;};
extras = builtins.attrNames project.dependencies.extras;
extraPackages = ps: [ps.twine ps.build];
};
pythonEnv = pkgs.python3.withPackages arg;
in {
default = pkgs.mkShell {packages = [pythonEnv];};
});
checks = eachSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
arg = project.renderers.withPackages {
python = pkgs.python3.override {inherit packageOverrides;};
extras = ["typing"];
};
pythonEnv = pkgs.python3.withPackages arg;
in {
alot = self.packages.${system}.alot;
types = pkgs.runCommand "alot-type-check" {buildInputs = [pythonEnv];} ''
cd ${self}
mypy --ignore-missing-imports alot/errors.py alot/__init__.py alot/utils/cached_property.py
touch $out
'';
});
};
}