refactor(flake): Get rid of flake-utils to simplify things

This commit is contained in:
Jiří Štefka 2025-06-12 23:51:34 +02:00
parent a662bdb249
commit e849070a3a
Signed by: jiriks74
GPG key ID: 1D5E30D3DB2264DE
2 changed files with 52 additions and 80 deletions

View file

@ -3,7 +3,6 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
gen-luarc.url = "github:mrcjkb/nix-gen-luarc-json";
# Add bleeding-edge plugins here.
@ -25,7 +24,6 @@
outputs = inputs @ {
self,
nixpkgs,
flake-utils,
gen-luarc,
...
}: let
@ -36,51 +34,59 @@
"aarch64-darwin"
];
# This is where the Neovim derivation is built.
neovim-overlay = import ./nix/neovim-overlay.nix {inherit inputs;};
inherit (self) outputs;
# This is a function that generates an attribute by calling a function you
# pass to it, with each system as an argument
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
in
flake-utils.lib.eachSystem supportedSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
# Import the overlay, so that the final Neovim derivation(s) can be accessed via pkgs.<nvim-pkg>
neovim-overlay
# This adds a function can be used to generate a .luarc.json
# containing the Neovim API all plugins in the workspace directory.
# The generated file can be symlinked in the devShell's shellHook.
gen-luarc.overlays.default
];
{
formatter = forAllSystems(system: nixpkgs.legacyPackages.${system}.alejandra);
overlays = {
neovim-overlay = import ./nix/neovim-overlay.nix {inherit inputs;};
# You can add this overlay to your NixOS configuration
default = self.outputs.overlays.neovim-overlay;
};
shell = pkgs.mkShell {
name = "nvim-devShell";
buildInputs = with pkgs; [
# Tools for Lua and Nix development, useful for editing files in this repo
lua-language-server
nil
stylua
luajitPackages.luacheck
];
shellHook = ''
# symlink the .luarc.json generated in the overlay
ln -fs ${pkgs.nvim-luarc-json} .luarc.json
'';
};
in {
formatter = nixpkgs.legacyPackages.${system}.alejandra;
packages = rec {
default = nvim;
nvim = pkgs.nvim-pkg;
};
devShells = {
default = shell;
};
})
// {
# You can add this overlay to your NixOS configuration
overlays.default = neovim-overlay;
packages = forAllSystems (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.outputs.overlays.neovim-overlay ];
};
in {
nvim-pkg = pkgs.nvim-pkg;
default = self.outputs.packages.${system}.nvim-pkg;
}
);
devShells = forAllSystems (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.outputs.overlays.neovim-overlay
gen-luarc.overlays.default
];
};
in {
default = pkgs.mkShell {
name = "nvim-devShell";
buildInputs = with pkgs; [
# Tools for Lua and Nix development, useful for editing files in this repo
lua-language-server
nil
stylua
luajitPackages.luacheck
];
shellHook = ''
# symlink the .luarc.json generated in the overlay
ln -fs ${pkgs.nvim-luarc-json} .luarc.json
'';
};
}
);
# templates = {
# };
};
}