-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
165 lines (163 loc) · 5.11 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
{
description = "Vim/Neovim package manager.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
pre-commit-hooks = {
url = "github:cachix/git-hooks.nix";
inputs = {
flake-compat.follows = "flake-compat";
nixpkgs.follows = "nixpkgs";
nixpkgs-stable.follows = "nixpkgs";
};
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-filter.url = "github:numtide/nix-filter";
};
outputs =
inputs@{
flake-parts,
crane,
pre-commit-hooks,
...
}:
(
flake-parts.lib.mkFlake { inherit inputs; } (
{ flake-parts-lib, withSystem, ... }:
let
inherit (flake-parts-lib) importApply;
flakeModules = {
neovim = importApply ./modules { inherit withSystem; };
};
in
{
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
perSystem =
{
self',
system,
pkgs,
lib,
...
}:
let
inherit (pkgs.lib) optionals;
inherit (pkgs.stdenv) isDarwin;
toolchain = pkgs.fenix.fromToolchainFile {
file = ./bundler/rust-toolchain.toml;
sha256 = "sha256-opUgs6ckUQCyDxcB9Wy51pqhd0MPGHUVbwRKKPGiwZU=";
};
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
bundler = with craneLib; rec {
commonArgs = {
src = cleanCargoSource (path ./bundler);
buildInputs = optionals isDarwin (
with pkgs;
[
libiconv
darwin.apple_sdk.frameworks.Security
]
);
nativeBuildgInputs = [ ];
};
artifacts = buildDepsOnly (commonArgs // { pname = "bundler-deps"; });
clippy = cargoClippy (commonArgs // { cargoArtifacts = artifacts; });
nextest = cargoNextest (commonArgs // { cargoArtifacts = artifacts; });
package = buildPackage (commonArgs // { cargoArtifacts = artifacts; });
};
in
{
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = with inputs; [
fenix.overlays.default
nix-filter.overlays.default
];
};
packages = {
bundler = bundler.package;
mdbook =
let
inherit (pkgs) nix-filter;
src = nix-filter {
root = ./.;
include = [
./docs
./book.toml
(nix-filter.matchExt "md")
];
};
in
pkgs.runCommand "mdbook" { } ''
${pkgs.mdbook}/bin/mdbook build --dest-dir $out ${src}
'';
};
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
settings.rust.cargoManifestPath = "./bundler/Cargo.toml";
hooks = {
deadnix.enable = true;
stylua.enable = true;
nixfmt = {
enable = true;
package = pkgs.nixfmt-rfc-style;
};
statix.enable = true;
rustfmt = {
enable = true;
packageOverrides = with pkgs.fenix.stable; {
inherit cargo rustfmt;
};
};
};
};
inherit (bundler) clippy nextest;
};
devShells.default = pkgs.mkShell {
inherit (self'.checks.pre-commit-check) shellHook;
packages =
[ toolchain ]
++ (with pkgs; [
mdbook
rust-analyzer-nightly
nixfmt-rfc-style
])
++ (with pkgs; lib.optional stdenv.isDarwin libiconv);
inputsFrom = [ bundler ];
RUST_BACKTRACE = "full";
};
};
flake = {
inherit flakeModules;
};
}
)
// {
templates = {
neovim = {
path = examples/neovim;
description = "neovim with bundler";
welcomeText = ''
Run `nix run .#bundler-nvim`
'';
};
};
}
);
}