feat(flake): add module for overlays

This commit is contained in:
Moritz Böhme 2024-02-12 10:10:32 +01:00
parent 59c843d452
commit 9e4fdb00e3
No known key found for this signature in database
GPG key ID: 970C6E89EB0547A9
15 changed files with 201 additions and 246 deletions

60
modules/nixpkgs.nix Normal file
View file

@ -0,0 +1,60 @@
{ config, lib, ... }:
with lib;
let
cfg = config.my.nixpkgs;
overlayType = mkOptionType {
name = "nixpkgs-overlay";
description = "nixpkgs overlay";
check = lib.isFunction;
merge = lib.mergeOneOption;
};
in
{
options.my.nixpkgs = {
overlays = mkOption {
default = [ ];
type = types.listOf overlayType;
example = literalExpression
''
[
(self: super: {
openssh = super.openssh.override {
hpnSupport = true;
kerberos = self.libkrb5;
};
})
]
'';
};
channels = mkOption {
default = { };
example = literalExpression ''
{
stable = inputs.nixpkgs-stable;
}
'';
type = with types; attrsOf package;
};
overlaysForAllChannels = mkEnableOption "apply overlays for all channels";
};
config.nixpkgs = {
overlays =
let
channelOverlays = _: prev:
mapAttrs
(_: value:
import value {
inherit (prev) system;
overlays = optional cfg.overlaysForAllChannels cfg.overlays;
}
)
cfg.channels;
in
cfg.overlays ++ [ channelOverlays ];
config.allowUnfree = true;
};
}

View file

@ -1,6 +1,7 @@
{ config
, lib
, pkgs
, inputs
, ...
}:
@ -88,6 +89,95 @@ in
time.timeZone = "Europe/Berlin";
my = {
nixpkgs = {
overlays = [
(_: prev:
{
nur = import inputs.nur {
pkgs = prev;
nurpkgs = prev;
};
}
)
(
final: _:
with final.lib;
rec {
fishFile =
{ name
, destination
, content
, checkPhase ? null
}:
final.writeTextFile {
inherit name destination;
executable = true;
allowSubstitutes = true;
preferLocalBuild = false;
text = ''
#!${getExe final.fish}
${content}
'';
checkPhase =
if checkPhase == null then ''
runHook preCheck
${getExe final.fish} -n "$target"
runHook postCheck
''
else checkPhase;
};
writeFishApplication =
{ name
, text
, completions ? null
, runtimeInputs ? [ ]
, checkPhase ? null
}:
let
runtimeHeader = optionalString (runtimeInputs != [ ])
''export PATH="${makeBinPath runtimeInputs}:$PATH"'';
script = fishFile {
inherit checkPhase;
name = "${name}_script";
destination = "/bin/${name}";
content = concatLines [ runtimeHeader text ];
};
completions_file = fishFile {
inherit checkPhase;
name = "${name}_completions";
destination = "/share/fish/vendor_completions.d/${name}.fish";
content = concatLines [ runtimeHeader completions ];
};
in
final.symlinkJoin {
inherit name;
paths = [
script
] ++ optional (completions != null) completions_file;
};
}
)
(
_: prev: {
xorg = prev.xorg // {
lndir = prev.xorg.lndir.overrideAttrs (_: {
meta.mainProgram = "lndir";
});
};
}
)
];
channels = {
master = inputs.master;
stable = inputs.stable;
};
};
bin.enable = true;
shell = {
abbreviations = {

View file

@ -43,6 +43,9 @@ in
config = mkIf cfg.enable {
my = {
nixpkgs.overlays = [
inputs.hypr-contrib.overlays.default
];
programs = {
wallpaper.enable = true;
kitty.enable = true;

View file

@ -10,15 +10,27 @@ in
options.my.programs.nvim.enable = mkEnableOption "nvim";
config = mkIf cfg.enable {
home-manager.users.moritz = {
home.packages = with pkgs; [
(
if config.my.programs.hyprland.enable
then neovide-hyprland
else neovide
)
];
my.nixpkgs.overlays = [
(
_: prev:
with lib.my;
{
vimPlugins = prev.vimPlugins // {
nvim-treesitter = prev.vimPlugins.nvim-treesitter.overrideAttrs (_: {
version = mkVersionInput inputs.nvim-treesitter;
src = inputs.nvim-treesitter;
});
# HACK: to fix error in nixpkgs version of nvim-lspconfig
nvim-lspconfig = prev.vimPlugins.nvim-lspconfig.overrideAttrs (_: {
version = mkVersionInput inputs.nvim-lspconfig;
src = inputs.nvim-lspconfig;
});
};
}
)
];
home-manager.users.moritz = {
programs.neovim = {
enable = true;
package = inputs.neovim-nightly-overlay.packages.${pkgs.system}.default;

View file

@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, lib, inputs, ... }:
with builtins;
{
@ -115,7 +115,10 @@ with builtins;
conf = readFile ./lua/nvim-lspconfig.lua;
dependencies = [
{
plugin = null-ls-nvim;
plugin = pkgs.vimPlugins.null-ls-nvim.overrideAttrs (_: {
version = lib.my.mkVersionInput inputs.none-ls-nvim;
src = inputs.none-ls-nvim;
});
conf = readFile ./lua/null-ls-nvim.lua;
dependencies = [
{ plugin = which-key-nvim; }
@ -144,7 +147,13 @@ with builtins;
{ plugin = dressing-nvim; }
];
}
{ plugin = actions-preview-nvim; }
{
plugin = pkgs.vimUtils.buildVimPlugin {
pname = "actions-preview-nvim";
version = lib.my.mkVersionInput inputs.actions-preview-nvim;
src = inputs.actions-preview-nvim;
};
}
];
}
{
@ -325,7 +334,11 @@ with builtins;
];
}
{
plugin = nvim-puppeteer;
plugin = pkgs.vimUtils.buildVimPlugin {
pname = "nvim-puppeteer";
version = lib.my.mkVersionInput inputs.nvim-puppeteer;
src = inputs.nvim-puppeteer;
};
lazy = false; # NOTE: plugin lazy-loads itself.
}
{

View file

@ -1,4 +1,4 @@
{ pkgs, config, ... }:
{ pkgs, ... }:
with builtins;
{

View file

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ pkgs, lib, inputs, ... }:
with builtins;
{
@ -21,12 +21,19 @@ with builtins;
opts = { };
}
{
plugin = statuscol-nvim;
plugin = pkgs.vimPlugins.statuscol-nvim.overrideAttrs (_: {
version = lib.my.mkVersionInput inputs.statuscol-nvim;
src = inputs.statuscol-nvim;
});
event = [ "VeryLazy" ];
conf = readFile ./lua/statuscol-nvim.lua;
}
{
plugin = smartcolumn-nvim;
plugin = pkgs.vimUtils.buildVimPlugin {
pname = "smartcolumn-nvim";
version = lib.my.mkVersionInput inputs.smartcolumn-nvim;
src = inputs.smartcolumn-nvim;
};
event = [ "BufReadPost" "BufNewFile" ];
opts = {
colorcolumn = "120";