Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
105 lines (90 loc) · 3.12 KB
/
Copy pathflake.nix
File metadata and controls
105 lines (90 loc) · 3.12 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
101
102
103
104
105
# SPDX-FileCopyrightText: 2026 ECOS Team <ecos-all@ict.ac.cn>
# SPDX-License-Identifier: MulanPSL-2.0
{
description = "Flake for AnserCore project";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
devshell.url = "github:numtide/devshell";
git-hooks-nix.url = "github:cachix/git-hooks.nix";
treefmt-nix.url = "github:numtide/treefmt-nix";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
# To import an internal flake module: ./other.nix
# To import an external flake module:
# 1. Add foo to inputs
# 2. Add foo as a parameter to the outputs function
# 3. Add here: foo.flakeModule
inputs.devshell.flakeModule
inputs.git-hooks-nix.flakeModule
inputs.treefmt-nix.flakeModule
];
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: {
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
# Equivalent to inputs'.nixpkgs.legacyPackages.hello;
packages.default = pkgs.hello;
devshells.default = {
name = "ansercore-devshell";
devshell.startup.pre-commit.text = config.pre-commit.installationScript;
packages = [
pkgs.reuse
(pkgs.python3.withPackages (ps: with ps; [sphinx myst-parser furo]))
];
commands = [
{
name = "docs-build";
help = "build docs";
command = "sphinx-build --nitpicky --fail-on-warning docs docs/_build/html";
category = "docs";
}
];
};
pre-commit = {
settings = {
package = pkgs.prek;
hooks = {
# pre-commit built-in hooks
check-yaml.enable = true;
end-of-file-fixer.enable = true;
gitlint.enable = true;
mixed-line-endings.enable = true;
trim-trailing-whitespace.enable = true;
reuse = {
enable = true;
excludes = ["flake.lock"];
};
treefmt.enable = true;
};
};
};
treefmt = {
programs.alejandra.enable = true;
programs.autocorrect.enable = true;
programs.mdformat.enable = true;
settings.formatter.sphinx-lint = {
command = "${pkgs.sphinx-lint}/bin/sphinx-lint";
options = ["--enable=default-role"];
includes = ["*.rst"];
};
settings.excludes = ["LICENSES/*" "LICENSE"];
};
};
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
};
}