I have two repos, my nixos config repo and my nixvim config repo. I add my nixvim flake as an input to my nixos flake and build it as the neovim package.
I want my nixvim flake to be configurable based on the system I am currently building with my nixos flake. Mainly, I am trying to pass along information from my nixos flake to my nixvim flake that it takes as an input that it’s building on a wsl system. I have spent too many hours banging my head against the nix compiler, google, and yes even turned to AI and I am officially lost. I turn to the good people here for any help. Is there any way I can achieve this?
My current main flake is as follows:
{
description = "Sammy's NixVim configuration (forked from DecorTech)";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
nixvim = {
url = "github:nix-community/nixvim";
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
};
};
outputs =
{
nixpkgs,
nixvim,
flake-parts,
pre-commit-hooks,
...
}@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"aarch64-linux"
"x86_64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
flake = {
# NOTE: This was my original attempt to add the option.
nixvimModules.wslOption = import ./config/modules/wsl-option.nix;
nixvimFunctions = {
x86_64-linux = inputs.nixvim.legacyPackages.x86_64-linux.makeNixvimWithModule;
aarch64-linux = inputs.nixvim.legacyPackages.aarch64-linux.makeNixvimWithModule;
x86_64-darwin = inputs.nixvim.legacyPackages.x86_64-darwin.makeNixvimWithModule;
aarch64-darwin = inputs.nixvim.legacyPackages.aarch64-darwin.makeNixvimWithModule;
};
};
perSystem =
{
system,
pkgs,
self',
lib,
...
}:
let
nixvimLib = nixvim.lib.${system};
nixvim' = nixvim.legacyPackages.${system};
nixvimModule = {
inherit pkgs;
module = import ./config; # import the module directly
# You can use `extraSpecialArgs` to pass additional arguments to your module files
extraSpecialArgs = {
# inherit (inputs) foo;
};
};
nvim = nixvim'.makeNixvimWithModule nixvimModule;
in
{
checks = {
default = nixvimLib.check.mkTestDerivationFromNixvimModule nixvimModule;
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
statix.enable = true;
nixfmt-rfc-style.enable = true;
};
};
};
formatter = pkgs.nixfmt-rfc-style;
packages = {
default = nvim;
};
devShells = {
default = with pkgs; mkShell { inherit (self'.checks.pre-commit-check) shellHook; };
};
};
};
}