-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
85 lines (81 loc) · 2.79 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
{
description = "Tool for creating, managing, and running qutebrowser profiles";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.pyproject-nix.url = "github:nix-community/pyproject.nix";
inputs.pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";
inputs.pyproject-nix.inputs.treefmt-nix.follows = "treefmt-nix";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.treefmt-nix.url = "github:numtide/treefmt-nix";
inputs.treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
outputs =
{
self,
nixpkgs,
pyproject-nix,
flake-utils,
treefmt-nix,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
project = pyproject-nix.lib.project.loadPyproject { projectRoot = ./.; };
treefmt = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs.mypy.enable = true;
programs.mypy.directories."." = {
modules = [
"src/qbpm"
"tests"
];
extraPythonPackages = self.packages.${system}.default.propagatedBuildInputs;
};
programs.ruff.check = true;
programs.ruff.format = true;
programs.nixfmt.enable = true;
};
python = pkgs.python3;
projectPackage =
args:
python.pkgs.buildPythonApplication (
args // project.renderers.buildPythonPackage { inherit python; }
);
projectEnv =
extraPackages:
python.withPackages (project.renderers.withPackages { inherit python extraPackages; });
in
{
packages.qbpm = projectPackage {
nativeBuildInputs = [
pkgs.scdoc
pkgs.installShellFiles
];
nativeCheckInputs = [ python.pkgs.pytestCheckHook ];
postInstall = ''
_QBPM_COMPLETE=bash_source $out/bin/qbpm > completions/qbpm.bash
_QBPM_COMPLETE=zsh_source $out/bin/qbpm > completions/qbpm.zsh
installShellCompletion completions/qbpm.{bash,zsh,fish}
scdoc < qbpm.1.scd > qbpm.1
installManPage qbpm.1
'';
};
packages.default = self.packages.${system}.qbpm;
apps.qbpm = flake-utils.lib.mkApp { drv = self.packages.${system}.qbpm; };
apps.default = self.apps.${system}.qbpm;
devShells.default = pkgs.mkShell {
inputsFrom = [ treefmt.config.build.devShell ];
buildInputs = [
(projectEnv (
ps: with ps; [
pytest
mypy
pylsp-mypy
]
))
];
};
formatter = treefmt.config.build.wrapper;
checks.formatting = treefmt.config.build.check self;
}
);
}