forked from NvChad/NvChad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
83 lines (81 loc) · 2.61 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
{
description = "A Nix-flake-based Python development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixvim.url = "github:nix-community/nixvim";
nixvim.inputs.nixpkgs.follows = "nixpkgs";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
};
outputs = inputs: let
disabledModules = ["${inputs.nixvim}/plugins/pluginmanagers/lazy.nix"];
mkNvchad = { system, modules ? [] }:
inputs.nixvim.legacyPackages.${system}.makeNixvimWithModule {
module.imports = modules ++ [
{ inherit disabledModules; }
./nix
./modules
];
extraSpecialArgs = specialArgs // { inherit inputs; };
};
specialArgs = let
nixvimLib = inputs.nixvim.lib.nixvim;
in {
nixvimLib.helpers = nixvimLib // (let
generator = { name ? "", args ? [], lua ? "", ... }:
''
function${if name == "" then "" else " ${name}"}(${builtins.concatStringsSep ", " args})
${lua}
end
'';
in {
mkLuaFnWithName = name: x: if builtins.isList x then
lua: generator { inherit name lua; args = x; }
else generator { inherit name; args = []; lua = x; };
mkLuaFn = x: if builtins.isList x then
lua: generator { inherit lua; args = x; }
else generator { args = []; lua = x; };
});
};
in inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
flake = { inherit inputs; lib = { inherit mkNvchad; }; };
perSystem = { config, self', inputs', pkgs, system, ... }: {
packages = inputs.nixvim.packages.${system} // rec {
nvchad = mkNvchad { inherit system; };
simple = mkNvchad {
inherit system;
modules = [
./templates/simple/config/nvim
];
};
default = nvchad;
};
};
} // builtins.listToAttrs (map (name: let
nvchad = { ... }: {
imports = [ inputs.nixvim.${name}.nixvim ];
programs.nixvim.imports = [
{
_file = ./flake.nix;
_module.args = specialArgs;
inherit disabledModules;
}
./nix
./modules
];
};
in {
inherit name;
value = {
inherit nvchad;
default = nvchad;
};
}) ["homeManagerModules" "nixDarwinModules" "nixosModules"]) // {
lib = specialArgs.nixvimLib;
templates.default = {
description = "simple nixos configuration";
path = ./templates/simple;
};
};
}