-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathflake.nix
More file actions
100 lines (86 loc) · 2.89 KB
/
Copy pathflake.nix
File metadata and controls
100 lines (86 loc) · 2.89 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
96
97
98
99
100
{
outputs = inputs: inputs.parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
perSystem = { lib, pkgs, system, ... }: {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
(
let pythonSelector = "python314"; in _: prev: {
python = prev.${pythonSelector};
pythonPackages = prev."${pythonSelector}Packages";
}
)
];
};
packages.default = pkgs.pythonPackages.buildPythonPackage (finalAttrs: {
pyproject = true;
pname = (lib.importTOML ./pyproject.toml).project.name;
inherit ((lib.importTOML ./pyproject.toml).project) version;
src = with lib.fileset; toSource {
root = ./.;
fileset = unions [
# code
./src
./tests
./.github/actions/atelier/hook.sh
# meta
./license.txt
./pyproject.toml
./readme.md
];
};
build-system = [ pkgs.pythonPackages.setuptools ];
dependencies = lib.map (n: pkgs.pythonPackages.${n}) (lib.importTOML ./pyproject.toml).project.dependencies;
nativeCheckInputs = [ pkgs.pythonPackages.pytestCheckHook ];
pythonImportsCheck = [ finalAttrs.pname ];
});
devShells.default = pkgs.mkShell {
packages = with pkgs; [
deno
nixpkgs-fmt
python
python.pkgs.venvShellHook
ruff
ty
uv
];
venvDir = "./.venv";
preShellHook = "uv venv $venvDir";
postShellHook = "uv sync";
UV_PYTHON = pkgs.python.interpreter;
UV_PYTHON_DOWNLOADS = "never";
UV_VENV_CLEAR = true;
LD_LIBRARY_PATH = lib.makeLibraryPath (with pkgs; [ stdenv.cc.cc ]);
};
formatter = pkgs.writeShellScriptBin "formatter" ''
set -eoux pipefail
shopt -s globstar
root="$PWD"
while [[ ! -f "$root/.git/index" ]]; do
if [[ "$root" == "/" ]]; then
exit 1
fi
root="$(dirname "$root")"
done
pushd "$root" > /dev/null
${lib.getExe pkgs.actionlint} -color
${lib.getExe pkgs.deno} fmt **/*.md **/*.yaml
${lib.getExe pkgs.gitleaks} git --no-banner --pre-commit --staged
${lib.getExe pkgs.nixpkgs-fmt} .
${lib.getExe pkgs.ruff} check --fix --unsafe-fixes --preview .
${lib.getExe pkgs.taplo} format pyproject.toml
${lib.getExe pkgs.ty} check --fix --error all .
${lib.getExe pkgs.uv} run pytest
${lib.getExe pkgs.zizmor} --fix=all .
popd
'';
};
};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
parts.url = "github:hercules-ci/flake-parts";
parts.inputs.nixpkgs-lib.follows = "nixpkgs";
systems.url = "github:nix-systems/triplet";
};
}