Merge branch 'nixos' into nixos-work

This commit is contained in:
Moritz Böhme 2024-11-05 09:38:52 +01:00
commit 988789346c
27 changed files with 4918 additions and 249 deletions

8
modules/config/ai.nix Normal file
View file

@ -0,0 +1,8 @@
{ lib
, ...
}:
with lib;
{
options.my.ai.enable = mkEnableOption "AI stuff";
}

View file

@ -0,0 +1,13 @@
{ lib
, ...
}:
with lib;
{
options.my.terminal = {
package = mkOption {
type = types.package;
apply = lib.getExe;
};
};
}

View file

@ -48,6 +48,7 @@ in
(_: value:
import value {
inherit (prev) system;
config.allowUnfree = true;
overlays = optional cfg.overlaysForAllChannels cfg.overlays;
}
)

View file

@ -187,14 +187,13 @@ in
rs = "sudo systemctl";
uj = "journalctl --user";
rj = "sudo journalctl";
lg = "lazygit";
};
aliases = {
ls = "${getExe pkgs.eza} -lh --icons --git";
cat = "bat";
rm = "rm -i";
mv = "mv -i";
nixos-update = "pushd ~/.dotfiles && nix flake update && popd";
};
variables = { EDITOR = "vim"; };
};
@ -241,6 +240,7 @@ in
which-nix
# utils
(viu.override { withSixel = true; })
bat
cht-sh
f
@ -249,7 +249,6 @@ in
parallel
ripgrep
vim
(viu.override { withSixel = true; })
wget
];
@ -300,6 +299,65 @@ in
];
};
starship.enable = true;
lazygit.enable = true;
lazygit.settings = {
customCommands = [
{
key = "<c-v>";
context = "global";
description = "Create new conventional commit";
prompts = [
{
type = "menu";
key = "Type";
title = "Type of change";
options = [
{ name = "build"; description = "Changes that affect the build system or external dependencies"; value = "build"; }
{ name = "feat"; description = "A new feature"; value = "feat"; }
{ name = "fix"; description = "A bug fix"; value = "fix"; }
{ name = "chore"; description = "Other changes that don't modify src or test files"; value = "chore"; }
{ name = "ci"; description = "Changes to CI configuration files and scripts"; value = "ci"; }
{ name = "docs"; description = "Documentation only changes"; value = "docs"; }
{ name = "perf"; description = "A code change that improves performance"; value = "perf"; }
{ name = "refactor"; description = "A code change that neither fixes a bug nor adds a feature"; value = "refactor"; }
{ name = "revert"; description = "Reverts a previous commit"; value = "revert"; }
{ name = "style"; description = "Changes that do not affect the meaning of the code"; value = "style"; }
{ name = "test"; description = "Adding missing tests or correcting existing tests"; value = "test"; }
];
}
{
type = "input";
title = "Scope";
key = "Scope";
initialValue = "";
}
{
type = "menu";
key = "Breaking";
title = "Breaking change";
options = [
{ name = "no"; value = ""; }
{ name = "yes"; value = "!"; }
];
}
{
type = "input";
title = "message";
key = "Message";
initialValue = "";
}
{
type = "confirm";
key = "Confirm";
title = "Commit";
body = "Are you sure you want to commit?";
}
];
command = "git commit --message '{{.Form.Type}}{{ if .Form.Scope }}({{ .Form.Scope }}){{ end }}{{.Form.Breaking}}: {{.Form.Message}}'";
loadingText = "Creating conventional commit...";
}
];
};
};
home = {
username = "moritz";

View file

@ -31,7 +31,7 @@ in
chromium.enable = mkDefault true;
firefox.enable = mkDefault true;
gpg.enable = mkDefault true;
hyprland.enable = mkDefault true;
river.enable = mkDefault true;
nix-edit.enable = mkDefault true;
nvim.enable = mkDefault true;
python.versions."311".enable = mkDefault true;

View file

@ -45,6 +45,8 @@ in
".cat_installer" # eduroam
".config/JetBrains"
".config/Nextcloud"
".config/Signal/"
".config/Mullvad VPN/"
".config/calibre"
".config/github-copilot"
".config/kdeconnect"

View file

@ -0,0 +1,35 @@
{ config
, lib
, pkgs
, inputs
, ...
}:
with lib;
let
cfg = config.my.programs.ghostty;
format = pkgs.formats.keyValue {
listsAsDuplicateKeys = true;
};
in
{
options.my.programs.ghostty.enable = mkEnableOption "Ghostty";
options.my.programs.ghostty.package = (mkPackageOption pkgs "Ghostty" { }) // {
inherit (inputs.ghostty.packages.${pkgs.system}) default;
};
options.my.programs.ghostty.settings = mkOption {
inherit (format) type;
description = ''
Configuration written to {file}`$XDG_CONFIG_HOME/ghostty/config`.
'';
default = { };
};
config = mkIf cfg.enable {
my.terminal.package = cfg.package;
home-manager.users.moritz = {
home.packages = [ cfg.package ];
xdg.configFile."ghostty/config".source = format.generate "ghostty-config" cfg.settings;
};
};
}

View file

@ -44,12 +44,17 @@ in
nix = config.nix.package;
};
age.secrets.nix-github-token.file = ../../secrets/nix-github-token.age;
nix = {
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
package = pkgs.nix;
extraOptions = "experimental-features = nix-command flakes";
extraOptions = ''
!include ${config.age.secrets.nix-github-token.path}
experimental-features = nix-command flakes
'';
gc = {
automatic = cfg.gc.enable;

View file

@ -17,30 +17,6 @@ in
xdotool # for vimtex
];
# programs.neovim = {
# extraPackages = with pkgs;
# [
# alejandra
# checkmake
# codespell
# deadnix
# dotenv-linter
# fish
# jq
# nil
# nixd
# nixpkgs-fmt
# nodePackages.bash-language-server
# python3Packages.python-lsp-server
# shellcheck
# shfmt
# stable.yamlfix
# statix
# taplo
# yamllint
# ];
# };
programs.nixvim = {
enable = true;
package = inputs.neovim-nightly-overlay.packages.${pkgs.system}.default;

View file

@ -1,37 +1,55 @@
{ config, lib, pkgs, inputs, ... }:
{ config, lib, pkgs, ... }:
let
inherit (lib) mkEnableOption mkIf readFile;
inherit (lib) mkIf;
cfg = config.my.ai;
in
{
home-manager.users.moritz.programs.nixvim = {
extraPlugins = with pkgs.vimPlugins; [
nui-nvim
render-markdown-nvim
avante-nvim
];
extraConfigLuaPost = ''
require("render-markdown").setup({ file_types = {"markdown", "Avante"} })
config = mkIf cfg.enable {
home-manager.users.moritz.programs.nixvim = {
extraPlugins = with pkgs.vimPlugins; [
nui-nvim
render-markdown-nvim
avante-nvim
];
extraConfigLuaPost = ''
require("render-markdown").setup({ file_types = {"markdown", "Avante"} })
require("avante_lib").load()
require("avante").setup({
provider = "openai",
auto_suggestions_provider = "openai",
behaviour = {
-- auto_suggestions = true,
},
openai = {
model = "gpt-4o",
api_key_name = "cmd:cat /run/agenix/openai"
}
})
'';
# plugins.copilot-lua.enable = true;
# plugins.copilot-lua.suggestion.enabled = false;
# plugins.copilot-lua.panel.enabled = false;
plugins.dressing.enable = true;
# performance.combinePlugins.standalonePlugins = [ "copilot.lua" ];
require("avante_lib").load()
require("avante").setup({
provider = "openai",
auto_suggestions_provider = "openai-cheap",
behaviour = {
auto_suggestions = false,
},
openai = {
model = "gpt-4o",
api_key_name = "cmd:cat /run/agenix/openai",
},
vendors = {
---@type AvanteProvider
["openai-cheap"] = {
model = "gpt-4o-mini",
api_key_name = "cmd:cat /run/agenix/openai",
endpoint = "https://api.openai.com/v1",
parse_curl_args = function(opts, code_opts)
return require("avante.providers").openai.parse_curl_args(opts, code_opts)
end,
parse_response_data = function(data_stream, event_state, opts)
return require("avante.providers").openai.parse_response(data_stream, event_state, opts)
end
},
},
})
'';
plugins.dressing.enable = true;
};
age.secrets = {
"openai".file = ../../../../secrets/openai.age;
"openai".owner = "moritz";
anthropic.file = ../../../../secrets/anthropic.age;
anthropic.owner = "moritz";
};
};
age.secrets."openai".file = ../../../../secrets/openai.age;
age.secrets."openai".owner = "moritz";
}

View file

@ -10,6 +10,7 @@ in
colorschemes.catppuccin = {
enable = true;
settings.flavour = "macchiato";
settings.default_integrations = true;
};
};
}

View file

@ -0,0 +1,14 @@
_:
{
home-manager.users.moritz.programs.nixvim = {
keymaps = [
{ key = "<leader>g"; action = "<cmd>LazyGit<cr>"; options.desc = "Lazygit"; }
];
plugins.lazygit = {
enable = true;
settings = { };
};
};
}

View file

@ -10,7 +10,7 @@ in
inlayHints = true;
servers.elixirls.enable = true;
servers.nextls.enable = true;
servers.nil-ls.enable = true;
servers.nil_ls.enable = true;
servers.nixd.enable = true;
servers.nixd.extraOptions.settings.nixd = {
nixpkgs = {

View file

@ -26,16 +26,21 @@ in
{
keymaps = [
{ key = "<esc>"; action = "<cmd>noh<cr><esc>"; options.desc = "Escape and clear hlsearch"; mode = [ "i" "n" ]; }
{ key = "<"; action = "<gv"; options.desc = "Shift left"; mode = [ "v" ]; }
{ key = ">"; action = ">gv"; options.desc = "Shift right"; mode = [ "v" ]; }
{ key = "y"; action = "ygv<esc>"; options.desc = "Yank"; mode = [ "v" ]; }
];
}
{ plugins.oil.enable = true; }
{ plugins.nvim-autopairs.enable = true; }
{ plugins.vim-surround.enable = true; }
{
plugins.lint.enable = true;
# TODO: add linters
plugins.lint.lintersByFt = { };
}
# TODO: add linters
# {
# plugins.lint.enable = true;
# plugins.lint.lintersByFt = { };
# }
{
plugins.marks.enable = true;
plugins.marks.defaultMappings = false;

View file

@ -0,0 +1,91 @@
{ config, lib, pkgs, inputs, ... }:
let
inherit (lib) mkEnableOption mkIf readFile;
in
{
home-manager.users.moritz.programs.nixvim = {
plugins.treesitter-textobjects = {
enable = true;
move = {
enable = true;
gotoNext = {
"]f" = {
desc = "Next function";
query = "@function.outer";
};
"]c" = {
desc = "Next class";
query = "@class.outer";
};
"]b" = {
desc = "Next block";
query = "@block.outer";
};
"]P" = {
desc = "Next parameter";
query = "@parameter.outer";
};
};
gotoPrevious = {
"[f" = {
desc = "Previous function";
query = "@function.outer";
};
"[c" = {
desc = "Previous class";
query = "@class.outer";
};
"[b" = {
desc = "Previous block";
query = "@block.outer";
};
"[P" = {
desc = "Previous parameter";
query = "@parameter.outer";
};
};
};
select = {
enable = true;
keymaps = {
"af" = {
desc = "function";
query = "@function.outer";
};
"if" = {
desc = "inner function";
query = "@function.inner";
};
"ac" = {
desc = "class";
query = "@class.outer";
};
"ic" = {
desc = "inner class";
query = "@class.inner";
};
"ab" = {
desc = "block";
query = "@block.outer";
};
"ib" = {
desc = "inner block";
query = "@block.inner";
};
"aP" = {
desc = "parameter";
query = "@parameter.outer";
};
"iP" = {
desc = "inner parameter";
query = "@parameter.inner";
};
};
};
};
performance.combinePlugins.standalonePlugins = [
"nvim-treesitter-textobjects"
];
};
}

View file

@ -11,6 +11,12 @@ in
nixvimInjections = true;
settings.indent.enable = true;
settings.highlight.enable = true;
settings.incremental_selection = {
enable = true;
keymaps.init_selection = "gn";
keymaps.node_decremental = "gp";
keymaps.node_incremental = "gn";
};
};
performance.combinePlugins.standalonePlugins = [
"nvim-treesitter"

View file

@ -61,14 +61,14 @@ in
];
map-switch.normal.lid = {
close = ''
spawn 'wlr-randr --output eDP-1 --off; monitors=$(wlr-randr --json | jq .[].name | count); [ "$monitors" = 1] && loginctl lock-session'
spawn 'monitors=$(wlr-randr --json | jq .[].name | count); [ "$monitors" = 1] && loginctl lock-session'
'';
open = "spawn 'wlr-randr --output eDP-1 --on'";
};
map = {
normal = {
"Super Q" = "close";
"Super Return" = "spawn kitty";
"Super Return" = "spawn '${config.my.terminal.package}'";
"Super R" = ''spawn 'exec $(tofi-run --fuzzy-match=true)' '';
"Super W" = ''spawn "pkill -USR1 waybar"'';
"Super+Shift R" = "spawn ~/.config/river/init";
@ -94,6 +94,7 @@ in
# lock screen
"Super+Alt L" = ''spawn "loginctl lock-session"'';
"Control I" = ''spawn "loginctl lock-session"'';
# XF86 keys
"None XF86AudioLowerVolume" = "spawn 'pamixer -d 5'";
@ -213,10 +214,9 @@ in
# adds pam module for swaylock
security.pam.services.swaylock = { };
# add user packages for wayland and hyprland in particular
users.users.moritz.packages = with pkgs; [
brightnessctl # control brightness
grimblast # screenshot tool for hyprland
grimblast # screenshot tool
pamixer # pulse audio cli
playerctl # control media playback
slurp # region select for wayland (for screensharing)