2024-11-22 02:48:41 -05:00
|
|
|
self: {
|
2024-05-07 22:49:00 -04:00
|
|
|
config,
|
2024-11-22 02:48:41 -05:00
|
|
|
lib,
|
2024-11-18 12:30:54 -05:00
|
|
|
osConfig,
|
2024-05-07 22:49:00 -04:00
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
2024-12-16 17:44:17 -05:00
|
|
|
inherit (builtins) toJSON;
|
|
|
|
inherit (lib) attrValues getExe hasPrefix mkIf removePrefix;
|
2024-11-18 12:30:54 -05:00
|
|
|
inherit (osConfig.networking) hostName;
|
2024-06-10 22:57:20 -04:00
|
|
|
|
2024-11-22 02:48:41 -05:00
|
|
|
cfg = config.programs.neovim;
|
2024-12-22 04:42:36 -05:00
|
|
|
mainHmCfg = osConfig.home-manager.users.${cfg.user} or config;
|
2024-11-22 02:48:41 -05:00
|
|
|
|
2024-08-02 11:26:15 -04:00
|
|
|
defaultFormatter = self.formatter.${pkgs.system};
|
2024-05-07 22:49:00 -04:00
|
|
|
|
2024-11-22 02:48:41 -05:00
|
|
|
nixdPkg = self.inputs.nixd.packages.${pkgs.system}.default;
|
2024-05-07 22:49:00 -04:00
|
|
|
|
|
|
|
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
2024-12-22 04:42:36 -05:00
|
|
|
flakeDir = "${removePrefix "${mainHmCfg.home.homeDirectory}/" flakeEnv}";
|
2024-12-22 04:52:07 -05:00
|
|
|
optionsAttr =
|
|
|
|
if osConfig != null
|
|
|
|
then "nixosConfigurations.${hostName}.options"
|
|
|
|
else "nixOnDroidConfigurations.default";
|
2024-11-22 02:48:41 -05:00
|
|
|
in {
|
2024-12-21 23:34:10 -05:00
|
|
|
config = mkIf cfg.enable {
|
2024-05-07 22:49:00 -04:00
|
|
|
assertions = [
|
|
|
|
{
|
2024-12-22 04:42:36 -05:00
|
|
|
assertion = hasPrefix "${mainHmCfg.home.homeDirectory}/" flakeEnv;
|
2024-05-07 22:49:00 -04:00
|
|
|
message = ''
|
|
|
|
Your $FLAKE environment variable needs to point to a directory in
|
|
|
|
the main users' home to use the neovim module.
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2024-12-22 00:04:13 -05:00
|
|
|
# We keep the packages here
|
2024-12-16 17:44:17 -05:00
|
|
|
home.packages = attrValues {
|
|
|
|
inherit
|
|
|
|
defaultFormatter
|
|
|
|
nixdPkg
|
|
|
|
;
|
|
|
|
};
|
2024-05-07 22:49:00 -04:00
|
|
|
|
2024-08-02 11:26:15 -04:00
|
|
|
# nixd by default kinda spams LspLog
|
|
|
|
home.sessionVariables.NIXD_FLAGS = "-log=error";
|
|
|
|
|
2024-12-16 17:44:17 -05:00
|
|
|
xdg.dataFile."${flakeDir}/.nixd.json".text = toJSON {
|
2024-05-07 22:49:00 -04:00
|
|
|
nixpkgs = {
|
|
|
|
expr = "import (builtins.getFlake \"${flakeDir}\").inputs.nixpkgs {}";
|
|
|
|
};
|
|
|
|
options.nixos = {
|
2024-12-22 04:52:07 -05:00
|
|
|
expr = "(builtins.getFlake \"${flakeDir}\").${optionsAttr}";
|
2024-05-07 22:49:00 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
programs = {
|
|
|
|
neovim = {
|
2024-12-16 17:44:17 -05:00
|
|
|
extraPackages = attrValues {
|
|
|
|
inherit nixdPkg;
|
|
|
|
};
|
2024-05-07 22:49:00 -04:00
|
|
|
|
2024-05-08 23:04:16 -04:00
|
|
|
extraLuaConfig =
|
2024-06-09 22:49:30 -04:00
|
|
|
# lua
|
2024-05-08 23:04:16 -04:00
|
|
|
''
|
2024-07-28 02:54:34 -04:00
|
|
|
require('lspconfig').nixd.setup({
|
|
|
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
|
|
|
|
2024-05-20 01:17:07 -04:00
|
|
|
filetypes = { 'nix', 'in.nix' },
|
2024-05-09 10:42:45 -04:00
|
|
|
settings = {
|
|
|
|
nixd = {
|
2024-06-09 22:49:30 -04:00
|
|
|
formatting = {
|
|
|
|
-- TODO: Try to find <flake>.formatter
|
2024-08-02 11:26:15 -04:00
|
|
|
command = { '${getExe defaultFormatter}' },
|
2024-06-09 22:49:30 -04:00
|
|
|
},
|
2024-05-09 10:42:45 -04:00
|
|
|
},
|
|
|
|
},
|
2024-07-28 02:54:34 -04:00
|
|
|
});
|
2024-05-08 23:04:16 -04:00
|
|
|
'';
|
2024-05-07 22:49:00 -04:00
|
|
|
};
|
|
|
|
};
|
2024-11-22 02:48:41 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
# For accurate stack trace
|
2024-12-21 23:34:10 -05:00
|
|
|
_file = ./default.nix;
|
2024-11-22 02:48:41 -05:00
|
|
|
}
|