flake.nix: transition to flake-parts

This commit is contained in:
Mihai Fufezan 2023-02-07 14:03:21 +02:00
parent b3c5dd3402
commit 885a43f6e7
No known key found for this signature in database
GPG Key ID: 5899325F2F120900
3 changed files with 255 additions and 225 deletions

168
extra.nix Normal file
View File

@ -0,0 +1,168 @@
inputs: let
modulesWithInputs = import ./modules {inherit inputs;};
neovimConfiguration = {
modules ? [],
pkgs,
lib ? pkgs.lib,
check ? true,
extraSpecialArgs ? {},
}:
modulesWithInputs {
inherit pkgs lib check extraSpecialArgs;
configuration = {...}: {
imports = modules;
};
};
mainConfig = isMaximal: {
config = {
vim = {
viAlias = true;
vimAlias = true;
};
vim.lsp = {
enable = true;
formatOnSave = true;
lightbulb.enable = true;
lspsaga.enable = false;
nvimCodeActionMenu.enable = true;
trouble.enable = true;
lspSignature.enable = true;
rust.enable = isMaximal;
python = isMaximal;
clang.enable = isMaximal;
sql = isMaximal;
ts = isMaximal;
go = isMaximal;
zig.enable = isMaximal;
nix = {
enable = true;
formatter = "alejandra";
};
};
vim.visuals = {
enable = true;
nvimWebDevicons.enable = true;
scrollBar.enable = true;
smoothScroll.enable = true;
cellularAutomaton.enable = true;
lspkind.enable = true;
indentBlankline = {
enable = true;
fillChar = "";
eolChar = "";
showCurrContext = true;
};
cursorWordline = {
enable = true;
lineTimeout = 0;
};
};
vim.statusline.lualine = {
enable = true;
theme = "catppuccin";
};
vim.theme = {
enable = true;
name = "catppuccin";
style = "mocha";
};
vim.autopairs.enable = true;
vim.autocomplete = {
enable = true;
type = "nvim-cmp";
};
vim.filetree = {
nvimTreeLua = {
enable = true;
view = {
width = 25;
};
};
};
vim.tabline = {
nvimBufferline.enable = true;
};
vim.treesitter = {
enable = true;
context.enable = true;
};
vim.binds = {
whichKey.enable = true;
cheatsheet.enable = true;
};
vim.telescope = {
enable = true;
};
vim.markdown = {
enable = true;
glow.enable = true;
};
vim.git = {
enable = true;
gitsigns.enable = true;
};
vim.minimap = {
minimap-vim.enable = false;
codewindow.enable = true; # lighter, faster, and uses lua for configuration
};
vim.dashboard = {
dashboard-nvim.enable = false;
alpha.enable = true;
};
vim.notify = {
nvim-notify.enable = true;
};
vim.utility = {
colorizer.enable = true;
icon-picker.enable = true;
venn-nvim.enable = false; # FIXME throws an error when its commands are ran manually
};
vim.notes = {
obsidian.enable = false; # FIXME neovim fails to build if obsidian is enabled
orgmode.enable = true;
};
vim.terminal = {
toggleterm.enable = true;
};
vim.ui = {
noice.enable = true;
};
vim.assistant = {
copilot.enable = false;
tabnine.enable = false; # FIXME: this is not working because the plugin depends on an internal script to be ran by the package manager
};
vim.session = {
nvim-session-manager.enable = false;
};
vim.gestures = {
gesture-nvim.enable = false;
};
};
};
in {
inherit neovimConfiguration mainConfig;
}

View File

@ -305,6 +305,24 @@
"type": "github" "type": "github"
} }
}, },
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1675295133,
"narHash": "sha256-dU8fuLL98WFXG0VnRgM00bqKX6CEPBLybhiIDIgO45o=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "bf53492df08f3178ce85e0c9df8ed8d03c030c9f",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"locked": { "locked": {
"lastModified": 1667395993, "lastModified": 1667395993,
@ -557,6 +575,24 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1672350804,
"narHash": "sha256-jo6zkiCabUBn3ObuKXHGqqORUMH27gYDIFFfLq5P4wg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "677ed08a50931e38382dbef01cba08a8f7eac8f6",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1656753965, "lastModified": 1656753965,
@ -1014,6 +1050,7 @@
"dashboard-nvim": "dashboard-nvim", "dashboard-nvim": "dashboard-nvim",
"discord-nvim": "discord-nvim", "discord-nvim": "discord-nvim",
"dressing-nvim": "dressing-nvim", "dressing-nvim": "dressing-nvim",
"flake-parts": "flake-parts",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"gesture-nvim": "gesture-nvim", "gesture-nvim": "gesture-nvim",
"gitsigns-nvim": "gitsigns-nvim", "gitsigns-nvim": "gitsigns-nvim",

275
flake.nix
View File

@ -2,26 +2,11 @@
description = "A neovim flake with a modular configuration"; description = "A neovim flake with a modular configuration";
outputs = { outputs = {
nixpkgs, nixpkgs,
flake-utils, flake-parts,
... ...
} @ inputs: let } @ inputs: let
modulesWithInputs = import ./modules {inherit inputs;}; inherit (nixpkgs) lib;
inherit (import ./extra.nix inputs) neovimConfiguration mainConfig;
neovimConfiguration = {
modules ? [],
pkgs,
lib ? pkgs.lib,
check ? true,
extraSpecialArgs ? {},
}:
modulesWithInputs {
inherit pkgs lib check extraSpecialArgs;
configuration = {...}: {
imports = modules;
};
};
nvimBin = pkg: "${pkg}/bin/nvim";
buildPkg = pkgs: modules: buildPkg = pkgs: modules:
(neovimConfiguration { (neovimConfiguration {
@ -30,179 +15,42 @@
.neovim; .neovim;
tidalConfig = { tidalConfig = {
config = { config.vim.tidal.enable = true;
vim.tidal.enable = true;
};
};
mainConfig = isMaximal: {
config = {
vim = {
viAlias = true;
vimAlias = true;
};
vim.lsp = {
enable = true;
formatOnSave = true;
lightbulb.enable = true;
lspsaga.enable = false;
nvimCodeActionMenu.enable = true;
trouble.enable = true;
lspSignature.enable = true;
rust.enable = isMaximal;
python = isMaximal;
clang.enable = isMaximal;
sql = isMaximal;
ts = isMaximal;
go = isMaximal;
zig.enable = isMaximal;
nix = {
enable = true;
formatter = "alejandra";
};
};
vim.visuals = {
enable = true;
nvimWebDevicons.enable = true;
scrollBar.enable = true;
smoothScroll.enable = true;
cellularAutomaton.enable = true;
lspkind.enable = true;
indentBlankline = {
enable = true;
fillChar = "";
eolChar = "";
showCurrContext = true;
};
cursorWordline = {
enable = true;
lineTimeout = 0;
};
};
vim.statusline.lualine = {
enable = true;
theme = "catppuccin";
};
vim.theme = {
enable = true;
name = "catppuccin";
style = "mocha";
};
vim.autopairs.enable = true;
vim.autocomplete = {
enable = true;
type = "nvim-cmp";
};
vim.filetree = {
nvimTreeLua = {
enable = true;
view = {
width = 25;
};
};
};
vim.tabline = {
nvimBufferline.enable = true;
};
vim.treesitter = {
enable = true;
context.enable = true;
};
vim.binds = {
whichKey.enable = true;
cheatsheet.enable = true;
};
vim.telescope = {
enable = true;
};
vim.markdown = {
enable = true;
glow.enable = true;
};
vim.git = {
enable = true;
gitsigns.enable = true;
};
vim.minimap = {
minimap-vim.enable = false;
codewindow.enable = true; # lighter, faster, and uses lua for configuration
};
vim.dashboard = {
dashboard-nvim.enable = false;
alpha.enable = true;
};
vim.notify = {
nvim-notify.enable = true;
};
vim.utility = {
colorizer.enable = true;
icon-picker.enable = true;
venn-nvim.enable = false; # FIXME throws an error when its commands are ran manually
};
vim.notes = {
obsidian.enable = false; # FIXME neovim fails to build if obsidian is enabled
orgmode.enable = true;
};
vim.terminal = {
toggleterm.enable = true;
};
vim.ui = {
noice.enable = true;
};
vim.assistant = {
copilot.enable = false;
tabnine.enable = false; # FIXME: this is not working because the plugin depends on an internal script to be ran by the package manager
};
vim.session = {
nvim-session-manager.enable = false;
};
vim.gestures = {
gesture-nvim.enable = false;
};
};
}; };
nixConfig = mainConfig false; nixConfig = mainConfig false;
maximalConfig = mainConfig true; maximalConfig = mainConfig true;
in in
{ flake-parts.lib.mkFlake {inherit inputs;} {
lib = { systems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
nvim = (import ./lib/stdlib-extended.nix nixpkgs.lib).nvim;
inherit neovimConfiguration; flake = {
lib = {
nvim = (import ./lib/stdlib-extended.nix nixpkgs.lib).nvim;
inherit neovimConfiguration;
};
overlays.default = final: prev: {
inherit neovimConfiguration;
neovim-nix = buildPkg prev [nixConfig];
neovim-maximal = buildPkg prev [maximalConfig];
neovim-tidal = buildPkg prev [tidalConfig];
};
nixosModules.hm-module = {
imports = [
./lib/hm.nix
# {nixpkgs.overlays = [inputs.self.overlays.default];} what?
];
};
}; };
overlays.default = final: prev: { perSystem = {
inherit neovimConfiguration; system,
neovim-nix = buildPkg prev [nixConfig]; self',
neovim-maximal = buildPkg prev [maximalConfig]; ...
neovim-tidal = buildPkg prev [tidalConfig]; }: {
}; legacyPackages = import nixpkgs {
}
// (flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [ overlays = [
inputs.tidalcycles.overlays.default inputs.tidalcycles.overlays.default
@ -213,42 +61,28 @@
]; ];
}; };
docs = import ./docs {
inherit pkgs;
nmdSrc = inputs.nmd;
};
# Available Configurations
tidalPkg = buildPkg pkgs [tidalConfig];
nixPkg = buildPkg pkgs [nixConfig];
maximalPkg = buildPkg pkgs [maximalConfig];
in {
apps = apps =
rec { {
nix = { nix.program = lib.getExe self'.packages.nix;
type = "app"; maximal.program = lib.getExe self'.packages.maximal;
program = nvimBin nixPkg; default = self'.apps.nix;
};
maximal = {
type = "app";
program = nvimBin maximalPkg;
};
default = nix;
} }
// ( // (
if !(builtins.elem system ["aarch64-darwin" "x86_64-darwin"]) if !(builtins.elem system ["aarch64-darwin" "x86_64-darwin"])
then { then {
tidal = { tidal.program = lib.getExe self'.packages.tidal;
type = "app";
program = nvimBin tidalPkg;
};
} }
else {} else {}
); );
devShells.default = pkgs.mkShell {nativeBuildInputs = [nixPkg];}; devShells.default = self'.legacyPackages.mkShell {nativeBuildInputs = [self'.packages.nix];};
packages = packages = let
docs = import ./docs {
pkgs = self'.legacyPackages;
nmdSrc = inputs.nmd;
};
in
{ {
# Documentation # Documentation
docs = docs.manual.html; docs = docs.manual.html;
@ -257,31 +91,22 @@
docs-json = docs.options.json; docs-json = docs.options.json;
# Available Configurations # Available Configurations
default = nixPkg; nix = buildPkg self'.legacyPackages [nixConfig];
nix = nixPkg; maximal = buildPkg self'.legacyPackages [maximalConfig];
maximal = maximalPkg;
} }
// ( // (
if !(builtins.elem system ["aarch64-darwin" "x86_64-darwin"]) if !(builtins.elem system ["aarch64-darwin" "x86_64-darwin"])
then { then {tidal = buildPkg self'.legacyPackages [tidalConfig];}
tidal = tidalPkg;
}
else {} else {}
); );
};
nixosModules.hm-module = { };
imports = [
./lib/hm.nix
# {nixpkgs.overlays = [inputs.self.overlays.default];} what?
];
};
}
));
# Flake inputs # Flake inputs
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
flake-parts.url = "github:hercules-ci/flake-parts";
# For generating documentation website # For generating documentation website
nmd = { nmd = {