forked from nix-community/nixvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
118 lines (105 loc) · 3.43 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
{
description = "A neovim configuration system for NixOS";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.beautysh.url = "github:lovesegfault/beautysh";
inputs.beautysh.inputs.nixpkgs.follows = "nixpkgs";
outputs = {
self,
nixpkgs,
flake-utils,
...
} @ inputs:
with nixpkgs.lib;
with builtins; let
# TODO: Support nesting
nixvimModules = map (f: ./modules + "/${f}") (attrNames (builtins.readDir ./modules));
modules = pkgs:
nixvimModules
++ [
rec {
_file = ./flake.nix;
key = _file;
config = {
_module.args = {
pkgs = mkForce pkgs;
inherit (pkgs) lib;
helpers = import ./plugins/helpers.nix {inherit (pkgs) lib;};
inputs = inputs;
};
};
}
# ./plugins/default.nix
];
flakeOutput =
flake-utils.lib.eachDefaultSystem
(system: let
pkgs = import nixpkgs {inherit system;};
extractRustAnalyzer = {
stdenv,
pkgs,
}:
stdenv.mkDerivation {
pname = "extract_rust_analyzer";
version = "master";
dontUnpack = true;
dontBuild = true;
buildInputs = [pkgs.python3];
installPhase = ''
ls -la
mkdir -p $out/bin
cp ${./helpers/extract_rust_analyzer.py} $out/bin/extract_rust_analyzer.py
'';
};
extractRustAnalyzerPkg = pkgs.callPackage extractRustAnalyzer {};
in {
checks = import ./tests/checks.nix {
inherit pkgs;
makeNixvim = self.legacyPackages."${system}".makeNixvim;
};
packages = {
docs = pkgs.callPackage (import ./docs.nix) {
modules = nixvimModules;
};
runUpdates =
pkgs.callPackage
({
pkgs,
stdenv,
}:
stdenv.mkDerivation {
pname = "run-updates";
version = pkgs.rust-analyzer.version;
src = pkgs.rust-analyzer.src;
nativeBuildInputs = with pkgs; [extractRustAnalyzerPkg alejandra nixpkgs-fmt];
buildPhase = ''
extract_rust_analyzer.py editors/code/package.json |
alejandra --quiet |
nixpkgs-fmt > rust-analyzer-config.nix
'';
installPhase = ''
mkdir -p $out/share
cp rust-analyzer-config.nix $out/share
'';
})
{};
};
legacyPackages = rec {
makeNixvimWithModule = import ./wrappers/standalone.nix pkgs modules;
makeNixvim = configuration:
makeNixvimWithModule {
module = {
config = configuration;
};
};
};
formatter = pkgs.alejandra;
});
in
flakeOutput
// {
nixosModules.nixvim = import ./wrappers/nixos.nix modules;
homeManagerModules.nixvim = import ./wrappers/hm.nix modules;
nixDarwinModules.nixvim = import ./wrappers/darwin.nix modules;
};
}