refactor nix flake to be easier to read

This commit is contained in:
RingOfStorms (Joshua Bell) 2025-01-02 12:10:37 -06:00
parent 4d020ff3e2
commit 71d82c875f
2 changed files with 143 additions and 164 deletions

17
flake.lock generated
View file

@ -16,22 +16,6 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-stable": {
"locked": {
"lastModified": 1735531152,
"narHash": "sha256-As8I+ebItDKtboWgDXYZSIjGlKeqiLBvjxsQHUmAf1Q=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "3ffbbdbac0566a0977da3d2657b89cbcfe9a173b",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-24.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nvim_plugin-Almo7aya/openingh.nvim": { "nvim_plugin-Almo7aya/openingh.nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -947,7 +931,6 @@
"root": { "root": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-stable": "nixpkgs-stable",
"nvim_plugin-Almo7aya/openingh.nvim": "nvim_plugin-Almo7aya/openingh.nvim", "nvim_plugin-Almo7aya/openingh.nvim": "nvim_plugin-Almo7aya/openingh.nvim",
"nvim_plugin-CopilotC-Nvim/CopilotChat.nvim": "nvim_plugin-CopilotC-Nvim/CopilotChat.nvim", "nvim_plugin-CopilotC-Nvim/CopilotChat.nvim": "nvim_plugin-CopilotC-Nvim/CopilotChat.nvim",
"nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring": "nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring", "nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring": "nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring",

290
flake.nix
View file

@ -2,7 +2,7 @@
description = "RingOfStorms's Neovim configuration using nix flake for portability"; description = "RingOfStorms's Neovim configuration using nix flake for portability";
# Nixpkgs / NixOS version to use. # Nixpkgs / NixOS version to use.
inputs = { inputs = {
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.11"; # nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.11";
nixpkgs.url = "github:nixos/nixpkgs/master"; nixpkgs.url = "github:nixos/nixpkgs/master";
rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.url = "github:oxalica/rust-overlay";
@ -140,7 +140,8 @@
{ {
self, self,
nixpkgs, nixpkgs,
nixpkgs-stable, # nixpkgs-stable,
rust-overlay,
... ...
}@inputs: }@inputs:
let let
@ -151,141 +152,137 @@
version = "hydrogen"; version = "hydrogen";
# =================== # ===================
# Utilities
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
withSystem = # Define the systems to support (all Linux systems exposed by nixpkgs)
f: systems = lib.intersectLists lib.systems.flakeExposed lib.platforms.linux;
lib.fold lib.recursiveUpdate { } ( forAllSystems = lib.genAttrs systems;
map f [ # Create a mapping from system to corresponding nixpkgs : https://nixos.wiki/wiki/Overlays#In_a_Nix_flake
"x86_64-linux" nixpkgsFor = forAllSystems (system: (nixpkgs.legacyPackages.${system}.extend rustOverlay));
"x86_64-darwin"
"aarch64-linux" # =========
"aarch64-darwin" rustOverlay = import rust-overlay;
]
);
in in
withSystem ( {
system: packages = forAllSystems (
let system:
# pkgs = nixpkgs.legacyPackages.${system}; let
overlays = [ (import inputs.rust-overlay) ]; pkgs = nixpkgsFor.${system};
pkgs = import nixpkgs { inherit system overlays; }; lazyPath = inputs."nvim_plugin-folke/lazy.nvim";
stable_pkgs = import nixpkgs-stable { inherit system overlays; }; nixPkgsPlugins = with pkgs.vimPlugins; {
"nvim_plugin-nvim-treesitter/nvim-treesitter" = nvim-treesitter.withAllGrammars;
lazyPath = inputs."nvim_plugin-folke/lazy.nvim";
nixPkgsPlugins = with stable_pkgs.vimPlugins; {
"nvim_plugin-nvim-treesitter/nvim-treesitter" = nvim-treesitter.withAllGrammars;
};
avante-nvim-lib = pkgs.rustPlatform.buildRustPackage {
pname = "avante-nvim-lib";
version = "0.0.0";
src = inputs."nvim_plugin-yetone/avante.nvim";
buildFeatures = [ "luajit" ];
doCheck = false;
cargoLock = {
lockFile = inputs."nvim_plugin-yetone/avante.nvim" + "/Cargo.lock";
allowBuiltinFetchGit = true;
}; };
nativeBuildInputs = with pkgs; [ avante-nvim-lib = pkgs.rustPlatform.buildRustPackage {
pkg-config pname = "avante-nvim-lib";
]; version = "0.0.0";
src = inputs."nvim_plugin-yetone/avante.nvim";
buildInputs = with pkgs; [ buildFeatures = [ "luajit" ];
openssl.dev doCheck = false;
]; cargoLock = {
env = { lockFile = inputs."nvim_plugin-yetone/avante.nvim" + "/Cargo.lock";
OPENSSL_NO_VENDOR = "1"; allowBuiltinFetchGit = true;
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib"; };
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include";
OPENSSL_DIR = "${pkgs.openssl.dev}";
};
postInstall = ''
# mv $out/lib/libavante_repo_map.so $out/lib/avante_repo_map.so
for f in $out/lib/lib*; do
mv "$f" "$out/lib/''${f##*/lib}"
done
'';
meta = {
description = "Avante nvim libraries";
homepage = "https://github.com/yetone/avante.nvim";
license = pkgs.lib.licenses.asl20;
};
};
# This will be how we put any nix related stuff into our lua config nativeBuildInputs = with pkgs; [
luaNixGlobal = pkg-config
"NIX="
+
lib.generators.toLua
{
multiline = false;
indent = false;
}
({
storePath = "${./.}";
# This will look at all inputs and grab any prefixed with `nvim_plugin-`
pluginPaths =
builtins.foldl' (dirs: name: { "${name}" = inputs.${name}.outPath; } // dirs) nixPkgsPlugins
(builtins.filter (n: builtins.substring 0 12 n == "nvim_plugin-") (builtins.attrNames inputs));
});
# These are appended at the start of the path so that they take precedence over local install tools
runtimeDependencies = with pkgs; [
# tools
ripgrep # search
fd # search
fzf # search fuzzy
tree-sitter
glow # markdown renderer
curl # http requests
sshfs # remote dev for nosduco/remote-sshfs.nvim
# nodePackages.cspell TODO check out `typos` rust checker instead?
];
# These are appended at the end of the PATH so any local installed tools will take precedence
defaultRuntimeDependencies = with pkgs; [
# linters
markdownlint-cli
luajitPackages.luacheck
biome # (t|s)j[x]
# formatters
stylua
nixfmt-rfc-style
nodePackages.prettier
rustywind
markdownlint-cli2
# LSPs
python312Packages.tiktoken # needed for copilot chat
nil # nix
lua-language-server
vscode-langservers-extracted # HTML/CSS/JSON/ESLint
nodePackages.typescript-language-server
nodePackages.svelte-language-server
tailwindcss-language-server
python312Packages.python-lsp-server
rust-analyzer
marksman # markdown
taplo # toml
yaml-language-server
lemminx # xml
# ocamlPackages.ocaml-lsp # ocaml
# Other
typescript
nodejs_20
clang
# zig
(pkgs.rust-bin.stable.latest.default.override {
extensions = [
"rust-src"
"rust-analyzer"
]; ];
})
]; buildInputs = with pkgs; [
in openssl.dev
{ ];
packages.${system} = { env = {
OPENSSL_NO_VENDOR = "1";
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include";
OPENSSL_DIR = "${pkgs.openssl.dev}";
};
postInstall = ''
# mv $out/lib/libavante_repo_map.so $out/lib/avante_repo_map.so
for f in $out/lib/lib*; do
mv "$f" "$out/lib/''${f##*/lib}"
done
'';
meta = {
description = "Avante nvim libraries";
homepage = "https://github.com/yetone/avante.nvim";
license = pkgs.lib.licenses.asl20;
};
};
# This will be how we put any nix related stuff into our lua config
luaNixGlobal =
"NIX="
+
lib.generators.toLua
{
multiline = false;
indent = false;
}
({
storePath = "${./.}";
# This will look at all inputs and grab any prefixed with `nvim_plugin-`
pluginPaths =
builtins.foldl' (dirs: name: { "${name}" = inputs.${name}.outPath; } // dirs) nixPkgsPlugins
(builtins.filter (n: builtins.substring 0 12 n == "nvim_plugin-") (builtins.attrNames inputs));
});
# These are appended at the start of the path so that they take precedence over local install tools
runtimeDependencies = with pkgs; [
# tools
ripgrep # search
fd # search
fzf # search fuzzy
tree-sitter
glow # markdown renderer
curl # http requests
sshfs # remote dev for nosduco/remote-sshfs.nvim
# nodePackages.cspell TODO check out `typos` rust checker instead?
];
# These are appended at the end of the PATH so any local installed tools will take precedence
defaultRuntimeDependencies = with pkgs; [
# linters
markdownlint-cli
luajitPackages.luacheck
biome # (t|s)j[x]
# formatters
stylua
nixfmt-rfc-style
nodePackages.prettier
rustywind
markdownlint-cli2
# LSPs
python312Packages.tiktoken # needed for copilot chat
nil # nix
lua-language-server
vscode-langservers-extracted # HTML/CSS/JSON/ESLint
nodePackages.typescript-language-server
nodePackages.svelte-language-server
tailwindcss-language-server
python312Packages.python-lsp-server
rust-analyzer
marksman # markdown
taplo # toml
yaml-language-server
lemminx # xml
# ocamlPackages.ocaml-lsp # ocaml
# Other
typescript
nodejs_20
clang
# zig
(pkgs.rust-bin.stable.latest.default.override {
extensions = [
"rust-src"
"rust-analyzer"
];
})
];
in
{
default = self.packages.${system}.neovim; default = self.packages.${system}.neovim;
neovim = neovim =
(pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped ( (pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped (
@ -294,7 +291,7 @@
customRC = '' customRC = ''
lua ${luaNixGlobal} lua ${luaNixGlobal}
luafile ${./.}/init.lua luafile ${./.}/init.lua
set runtimepath^=${builtins.concatStringsSep "," (builtins.attrValues stable_pkgs.vimPlugins.nvim-treesitter.grammarPlugins)} set runtimepath^=${builtins.concatStringsSep "," (builtins.attrValues pkgs.vimPlugins.nvim-treesitter.grammarPlugins)}
''; '';
} }
)).overrideAttrs )).overrideAttrs
@ -378,20 +375,19 @@
"ALL_PROXY" "ALL_PROXY"
]; ];
}); });
}; }
);
nixosModules = { nixosModules = {
default = default =
{ {
pkgs, pkgs,
... ...
}: }:
{ {
environment.systemPackages = [ environment.systemPackages = [
self.packages.${pkgs.system}.default self.packages.${pkgs.system}.default
]; ];
}; };
}; };
} };
);
} }