Compare commits

..

1 Commits

Author SHA1 Message Date
Moritz Böhme 11a779c036
feat(nvim): add guard-nvim 2023-10-08 12:01:07 +02:00
94 changed files with 1823 additions and 4025 deletions

9
.nixd.json Normal file
View File

@ -0,0 +1,9 @@
{
"options": {
"enable": true,
"target": {
"args": [],
"installable": ".#nixosConfigurations.nixos-desktop.options"
}
}
}

1167
flake.lock

File diff suppressed because it is too large Load Diff

113
flake.nix
View File

@ -15,50 +15,46 @@
master.url = "github:nixos/nixpkgs";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
stable.url = "github:nixos/nixpkgs/nixos-24.05";
nur.url = "github:nix-community/NUR";
nix-index-database.url = "github:Mic92/nix-index-database";
nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
stable.url = "github:nixos/nixpkgs/nixos-23.05";
# Programs
nix-super.inputs.nixpkgs.follows = "stable";
nix-super.url = "github:privatevoid-net/nix-super";
nix-monitored.url = "github:ners/nix-monitored";
nix-monitored.inputs.nixpkgs.follows = "nixpkgs";
rofi-wayland.flake = false;
rofi-wayland.url = "github:lbonn/rofi/wayland";
timers.url = "git+https://gitea.moritzboeh.me/moritz/timers.git";
# Neovim
actions-preview-nvim.flake = false;
actions-preview-nvim.url = "github:aznhe21/actions-preview.nvim";
codeium-nvim = {
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
url = "github:jcdickinson/codeium.nvim";
};
hmts-nvim.flake = false;
hmts-nvim.url = "github:calops/hmts.nvim";
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
nix-lazy-nvim.url = "git+https://git.moritzboeh.me/moritz/NixLazy.nvim";
nvim-lspconfig.flake = false;
nvim-lspconfig.url = "github:neovim/nvim-lspconfig";
nvim-puppeteer.flake = false;
nvim-puppeteer.url = "github:chrisgrieser/nvim-puppeteer";
nvim-treesitter.flake = false;
nvim-treesitter.url = "github:nvim-treesitter/nvim-treesitter/v0.9.1"; # NOTE: to fix weird latest issues
smartcolumn-nvim.flake = false;
smartcolumn-nvim.url = "github:m4xshen/smartcolumn.nvim";
telekasten-nvim.flake = false;
telekasten-nvim.url = "github:renerocksai/telekasten.nvim";
neotest-python.flake = false;
neotest-python.url = "github:MoritzBoehme/neotest-python/fix-runtimepath-search";
gen-nvim.flake = false;
gen-nvim.url = "github:David-Kunz/gen.nvim";
hawtkeys-nvim.flake = false;
hawtkeys-nvim.url = "github:tris203/hawtkeys.nvim";
none-ls-shellcheck-nvim.flake = false;
none-ls-shellcheck-nvim.url = "github:gbprod/none-ls-shellcheck.nvim";
cmp-vimtex.flake = false;
cmp-vimtex.url = "github:micangl/cmp-vimtex";
# river
river.url = "git+https://github.com/riverwm/river?submodules=1";
river.flake = false;
telescope-nvim.flake = false;
telescope-nvim.url = "github:nvim-telescope/telescope.nvim";
guard-nvim.flake = false;
guard-nvim.url = "/home/moritz/Devel/Lua/guard.nvim";
# Hyprland
hypr-contrib.url = "github:hyprwm/contrib";
hyprland = {
type = "git";
url = "https://github.com/hyprwm/Hyprland";
submodules = true;
};
hyprland.url = "github:hyprwm/Hyprland";
hyprpaper.url = "github:hyprwm/hyprpaper";
# Laptop
asus-touchpad-numpad-driver.url = "github:MoritzBoehme/asus-touchpad-numpad-driver/german-layout";
@ -70,8 +66,29 @@
};
outputs = inputs@{ self, flake-parts, ... }:
let
defaultOverlays = [
inputs.hypr-contrib.overlays.default
inputs.neovim-nightly-overlay.overlay
self.overlays.default
];
finalOverlays = defaultOverlays ++ [
(
_: prev: {
master = import inputs.master {
inherit (prev) system;
overlays = defaultOverlays;
};
stable = import inputs.stable {
inherit (prev) system;
overlays = defaultOverlays;
};
}
)
];
in
flake-parts.lib.mkFlake { inherit inputs; } {
debug = true; # NOTE: for nixd
imports = [
inputs.pre-commit-hooks.flakeModule
inputs.devshell.flakeModule
@ -79,6 +96,12 @@
systems = [ "x86_64-linux" ];
perSystem = { config, self', inputs', pkgs, system, ... }: {
_module.args.pkgs =
import inputs.nixpkgs {
inherit system;
overlays = finalOverlays;
};
devshells.default = {
devshell.startup.pre-commit-hook.text = config.pre-commit.installationScript;
commands = [
@ -90,7 +113,7 @@
'';
}
{
name = "build";
name = "nixos-build";
help = "use nom to build system";
command =
''
@ -98,25 +121,21 @@
'';
}
{
name = "apply";
name = "nixos-switch";
help = "wrapper for nixos-rebuild switch";
command = "sudo nixos-rebuild switch --flake . $@";
}
{
name = "test";
name = "nixos-test";
help = "wrapper for nixos-rebuild switch";
command = "sudo nixos-rebuild test --flake . $@";
}
{
name = "boot";
name = "nixos-boot";
help = "wrapper for nixos-rebuild switch";
command = "sudo nixos-rebuild boot --flake . $@";
}
];
packages = with pkgs; [
stylua
sumneko-lua-language-server
];
};
pre-commit = {
@ -133,12 +152,20 @@
legacyPackages = pkgs;
packages =
self.lib.filterAttrs (_: self.lib.isDerivation)
(self.overlays.default pkgs pkgs);
};
flake = {
lib = inputs.nixpkgs.lib.extend
(self: _: { my = import ./lib { lib = self; }; });
overlays.default = import ./overlays {
inherit inputs;
inherit (self) lib;
};
nixosConfigurations = self.lib.my.mapModules
(path: self.lib.nixosSystem {
inherit (self) lib;
@ -148,6 +175,12 @@
modules =
[
./modules
{
nixpkgs = {
overlays = finalOverlays;
config.allowUnfree = true;
};
}
{
home-manager = {
useGlobalPkgs = true;
@ -160,22 +193,10 @@
inputs.disko.nixosModules.default
inputs.home-manager.nixosModule
inputs.impermanence.nixosModules.impermanence
inputs.nix-index-database.nixosModules.nix-index
path
];
})
./hosts;
templates = {
python = {
description = "Simple poetry shell.nix";
path = ./templates/python;
};
rust = {
description = "Crane + Fenix flake with mold for faster local builds.";
path = ./templates/rust;
};
};
};
};

View File

@ -2,7 +2,6 @@
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ pkgs
, config
, ...
}:
@ -10,7 +9,6 @@
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
./disko.nix
];
my = {
@ -18,47 +16,53 @@
desktop.enable = true;
gaming.enable = true;
personal.enable = true;
impermanence.enable = true;
webis.enable = true;
};
programs.hyprland.enable = true;
programs.hyprland.nvidiaSupport = true;
programs.hyprland.keyboardLayouts = [ "us" "de" ];
programs.hyprland.monitors."HDMI-A-2" = { scale = 1.2; };
programs.exercism.enable = true;
programs.hyprland = {
nvidiaSupport = true;
monitors = [ "HDMI-A-1,3840x2160,auto,1.2" ",preferred,auto,1" ];
extraConfig = "exec=hyprctl keyword monitor HDMI-A-1,3840x2160@120,auto,1.2";
keyboardLayouts = [ "us" "de" ];
};
services.mullvad.enable = true;
services.wallpaper.enable = true;
programs.ledger.enable = true;
};
virtualisation.containers.cdi.dynamic.nvidia.enable = true;
home-manager.users.moritz.home.packages = with pkgs; [
anki
stable.calibre # NOTE: breaks often in unstable
jetbrains.idea-community
];
hardware = {
keyboard.qmk.enable = true;
nvidia.modesetting.enable = true;
opengl = {
enable = true;
driSupport32Bit = true;
driSupport = true;
};
# sensors
enableAllFirmware = true;
bluetooth.enable = true;
};
boot = {
# KERNEL
kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; # NOTE: use latest zfs compatible kernel
kernelPackages = pkgs.linuxPackages_latest;
# BOOT
supportedFilesystems = [ "zfs" "btrfs" "ntfs" ];
supportedFilesystems = [ "btrfs" "ntfs" ];
loader = {
systemd-boot.enable = true;
grub = {
enable = true;
device = "nodev";
efiSupport = true;
useOSProber = true;
};
efi.canTouchEfiVariables = true;
};
kernelModules = [ "lm92" "drivetemp" ];
};
@ -68,7 +72,7 @@
defaultGateway = "192.168.0.1";
nameservers = [ "192.168.0.4" ];
useDHCP = false;
interfaces.enp6s0 = {
interfaces.enp42s0 = {
ipv4.addresses = [
{
address = "192.168.0.14";

View File

@ -1,102 +0,0 @@
{ lib, ... }:
{
# needed for zfs pool
networking.hostId = "1f8b8073";
disko.devices = {
disk = {
main = {
type = "disk";
device = "/dev/disk/by-id/ata-Samsung_SSD_850_EVO_500GB_S2RBNX0J351943M";
content = {
type = "gpt";
partitions = {
ESP = {
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
encryptedSwap = {
size = "8G";
content = {
type = "swap";
randomEncryption = true;
};
};
zfs = {
size = "100%";
content = {
type = "zfs";
pool = "zroot";
};
};
};
};
};
};
zpool = {
zroot = {
type = "zpool";
rootFsOptions = {
compression = "zstd";
"com.sun:auto-snapshot" = "false";
"acltype" = "posixacl"; # NOTE: needed for systemd https://github.com/NixOS/nixpkgs/issues/16954
};
mountpoint = null;
datasets = {
encrypted = {
type = "zfs_fs";
options = {
mountpoint = "none";
encryption = "aes-256-gcm";
keyformat = "passphrase";
};
# use this to read the key during boot
postCreateHook = ''
zfs set keylocation="prompt" "zroot/$name";
'';
};
"encrypted/root" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/";
postCreateHook = "zfs snapshot zroot/encrypted/root@blank";
};
"encrypted/nix" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/nix";
};
"encrypted/persist" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/persist";
options."com.sun:auto-snapshot" = "true";
};
};
};
};
};
# rollback to blank
boot.initrd.postDeviceCommands = lib.mkAfter ''
zfs rollback -r zroot/encrypted/root@blank && echo "rollback complete"
'';
fileSystems."/persist".neededForBoot = true;
# HACK: to fix issue of agenix running before impermanence
age.identityPaths = [
"/etc/ssh/ssh_host_ed25519_key"
"/etc/ssh/ssh_host_rsa_key"
"/persist/etc/ssh/ssh_host_ed25519_key"
"/persist/etc/ssh/ssh_host_rsa_key"
];
services.zfs = {
autoScrub.enable = true;
trim.enable = true;
autoSnapshot.enable = true;
};
}

View File

@ -1,27 +1,62 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ config
, lib
, modulesPath
, ...
}: {
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot = {
initrd = {
availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
kernelModules = [ ];
luks.devices."enc".device = "/dev/disk/by-uuid/30025a9f-44cf-4074-8ae2-d4925efd67dd";
};
kernelModules = [ "kvm-amd" ];
extraModulePackages = [ ];
};
fileSystems = {
"/" = {
device = "/dev/disk/by-uuid/668a49b3-d169-461f-861d-0c3e6a1642d1";
fsType = "btrfs";
options = [ "subvol=root" "compress=zstd" ];
};
{
imports =
[
(modulesPath + "/installer/scan/not-detected.nix")
];
"/home" = {
device = "/dev/disk/by-uuid/668a49b3-d169-461f-861d-0c3e6a1642d1";
fsType = "btrfs";
options = [ "subvol=home" "compress=zstd" ];
};
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
"/nix" = {
device = "/dev/disk/by-uuid/668a49b3-d169-461f-861d-0c3e6a1642d1";
fsType = "btrfs";
options = [ "subvol=nix" "compress=zstd" ];
};
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp6s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp7s0.useDHCP = lib.mkDefault true;
"/var/log" = {
device = "/dev/disk/by-uuid/668a49b3-d169-461f-861d-0c3e6a1642d1";
fsType = "btrfs";
options = [ "subvol=log" "compress=zstd" ];
neededForBoot = true;
};
"/boot" = {
device = "/dev/disk/by-uuid/297B-C04C";
fsType = "vfat";
};
"/media/games" = {
device = "/dev/disk/by-uuid/8f92ff36-a685-4a67-a3d4-55136dc5f286";
fsType = "ext4";
};
};
swapDevices = [{ device = "/dev/disk/by-uuid/00ad6f74-f23e-4ac0-abfb-89bdfe5ab8ae"; }];
hardware.cpu.amd.updateMicrocode =
lib.mkDefault config.hardware.enableRedistributableFirmware;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@ -3,12 +3,14 @@
# and in the NixOS manual (accessible by running nixos-help).
{ pkgs
, inputs
, lib
, ...
}: {
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
./disko.nix
./impermanence.nix
];
my = {
@ -17,121 +19,25 @@
profiles = {
desktop.enable = true;
personal.enable = true;
webis.enable = true;
impermanence.enable = true;
};
programs.river.enable = true;
programs.hyprland.enable = false;
programs.exercism.enable = true;
};
users.users.moritz.packages = [ pkgs.poetry ];
home-manager.users.moritz.services.kanshi.profiles = {
undocked = {
outputs = [
{
criteria = "eDP-1";
}
];
};
docked = {
outputs = [
{
criteria = "eDP-1";
position = "640,1800"; # NOTE: 2160 / 1.2 = 1800
}
{
criteria = "DP-3";
scale = 1.2;
position = "0,0";
}
];
# webis.enable = true;
};
};
services.kanata = {
enable = true;
keyboards = {
laptop = {
devices = [
"/dev/input/by-path/platform-i8042-serio-0-event-kbd"
];
config = "
(defsrc
grv 1 2 3 4 5 6 7 8 9 0 - = bspc
tab q w e r t y u i o p [ ] \
caps a s d f g h j k l ; ' ret
lsft z x c v b n m , . / rsft
lctl lmet lalt spc ralt rctl
)
environment.systemPackages = [
(
pkgs.writeShellApplication {
name = "zfs-diff";
runtimeInputs = with pkgs; [ zfs coreutils parallel tree ];
text = ''
zfs diff -F zroot/encrypted/root@blank | awk '$2 == "F" && system("test -e /persist/"$3) != 0 { print $3 }' 2>/dev/null | tree --fromfile . "$@"
'';
}
)
];
(deflayermap (default)
;; tarmak 1a
j n
n k
k e
;; tarmak 1b
h m
m h
;; tarmak 2a
b z
z x
x c
;; tarmak 2b
e f
f t
t b
;; tarmak 3
c d
d s
s r
;; tarmak 4
r p
p ;
; o
o y
y j
;; tarmak 5
u l
l i
i u
;; caps-word tap-dance
lsft (tap-dance 200 (_ (caps-word 2000) _ _))
;; change ctrl alt and meta
lctl lalt
lmet lctl
lalt (tap-dance 200 (lmet (multi lmet alt) lmet lmet))
;; hjkl layer
ralt (tap-hold 200 200 (layer-switch hjkl) (layer-while-held hjkl)) ;; tap: switch hold: switch while held
;; switch to normal keyboard layout
rctl (layer-switch normal)
)
(deflayermap (normal)
rctl (layer-switch default))
(deflayermap (hjkl)
h left
j down
k up
l right
ralt (layer-switch default))
";
};
};
};
home-manager.users.moritz.home.packages = with pkgs; [
# jetbrains.idea-ultimate
];
# BOOT
boot = {
@ -141,8 +47,8 @@
# SERVICES
services = {
libinput.enable = true;
libinput.touchpad.disableWhileTyping = true;
xserver.libinput.enable = true;
xserver.libinput.touchpad.disableWhileTyping = true;
printing.enable = true;
logind.lidSwitch = "hybrid-sleep";
};
@ -205,7 +111,7 @@
}/bin/python asus_touchpad.py m433ia
'';
# Probably needed because it fails on boot seemingly because the driver
# is not ready yet. Alternatively, you can use `sleep 3` or similar in the
# is not ready yet. Alternativly, you can use `sleep 3` or similar in the
# `script`.
serviceConfig = {
RestartSec = "1s";

View File

@ -12,7 +12,7 @@
type = "gpt";
partitions = {
ESP = {
size = "512M";
size = "64M";
type = "EF00";
content = {
type = "filesystem";
@ -37,7 +37,6 @@
rootFsOptions = {
compression = "zstd";
"com.sun:auto-snapshot" = "false";
"acltype" = "posixacl"; # NOTE: needed for systemd https://github.com/NixOS/nixpkgs/issues/16954
};
mountpoint = null;

View File

@ -0,0 +1,71 @@
{ config, ... }:
{
age.secrets = {
root-password.file = ../../secrets/root-password.age;
moritz-password.file = ../../secrets/moritz-password.age;
};
users.users = {
root.hashedPasswordFile = config.age.secrets.root-password.path;
moritz.hashedPasswordFile = config.age.secrets.moritz-password.path;
};
users.mutableUsers = false;
environment.persistence."/persist" = {
hideMounts = true;
directories = [
"/etc/NetworkManager/system-connections"
"/var/db/dhcpcd/"
"/var/lib/NetworkManager/"
"/var/lib/bluetooth"
"/var/lib/nixos"
"/var/lib/systemd/coredump"
"/var/log"
];
files = [
"/etc/machine-id"
"/etc/nix/id_rsa"
"/etc/ssh/ssh_host_ed25519_key"
"/etc/ssh/ssh_host_ed25519_key.pub"
"/etc/ssh/ssh_host_rsa_key"
"/etc/ssh/ssh_host_rsa_key.pub"
];
users.moritz = {
directories = [
".SynologyDrive/data"
".SynologyDrive/log"
".cache/keepassxc"
".cache/nvim/luac"
".config/Nextcloud"
".config/keepassxc"
".local/share/direnv"
".local/share/nvim"
".local/share/zoxide"
".local/state/nvim"
".mozilla"
"Documents"
"Downloads"
"Music"
"Pictures"
"Videos"
{ directory = ".gnupg"; mode = "0700"; }
{ directory = ".local/share/keyrings"; mode = "0700"; }
{ directory = ".ssh"; mode = "0700"; }
];
files = [
".local/share/fish/fish_history"
".local/share/nix/trusted-settings.json"
".parallel/will-cite"
];
};
users.root = {
home = "/root";
directories = [
{ directory = ".gnupg"; mode = "0700"; }
{ directory = ".ssh"; mode = "0700"; }
];
files = [
".local/share/nix/trusted-settings.json"
];
};
};
}

View File

@ -31,12 +31,6 @@
}:
{
my.programs.tofi.settings = {
text-color = "#${text}";
prompt-color = "#${red}";
selection-color = "#${yellow}";
background-color = "#${base}";
};
home-manager.users.moritz = {
programs = {
fzf.colors = {
@ -53,26 +47,6 @@
prompt = "#${mauve}";
spinner = "#${rosewater}";
};
foot.settings.colors = {
foreground = text; # Text
background = base; # Base
regular0 = surface1; # Surface 1
regular1 = red; # red
regular2 = green; # green
regular3 = yellow; # yellow
regular4 = blue;
regular5 = pink;
regular6 = teal;
regular7 = subtext1;
bright0 = surface2;
bright1 = red;
bright2 = green;
bright3 = yellow;
bright4 = blue;
bright5 = pink;
bright6 = teal;
bright7 = subtext0;
};
kitty.extraConfig = ''
# vim:ft=kitty

View File

@ -9,7 +9,7 @@ in
(import ./_catppuccin.nix
{
inherit config lib pkgs;
flavor = "macchiato";
flavor = "mocha";
rosewater = "f4dbd6";
flamingo = "f0c6c6";
pink = "f5bde6";

View File

@ -31,20 +31,6 @@ in
};
config = mkIf cfg.enable {
my.programs.tofi.settings = {
font-size = "20";
font =
let
fontBasePath = pkgs.nerdfonts.override {
fonts = [ "FiraCode" ];
};
in
"${fontBasePath}/share/fonts/truetype/NerdFonts/FiraCodeNerdFont-Regular.ttf";
height = "360";
width = "720";
outline-width = "0";
border-width = "0";
};
home-manager.users.moritz = {
services.polybar = {
config = {
@ -53,7 +39,7 @@ in
monitor = "\${env:MONITOR}";
bottom = true;
width = "100%";
height = 15;
heigth = 15;
border-size = 2;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 4.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

View File

@ -1,60 +0,0 @@
{ 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,7 +1,6 @@
{ config
, lib
, pkgs
, inputs
, ...
}:
@ -44,7 +43,7 @@ let
gi = pkgs.writeFishApplication {
name = "gi";
runtimeInputs = with pkgs; [ fzf gum curl coreutils-full ];
runtimeInputs = with pkgs; [ fzf gum curl ];
text = /* fish */ ''
set url https://www.gitignore.io/api
@ -57,12 +56,10 @@ let
set choice (string join "," $argv[1..])
end
set contents "$(curl -sL $url/$choice | head -n -2 | tail -n +4)"
if gum confirm "Overwrite current .gitignore?"
echo "$contents" > .gitignore
curl -sL $url/$choice > .gitignore
else
echo "$contents" >> .gitignore
curl -sL $url/$choice >> .gitignore
end
'';
completions = /* fish */ ''
@ -79,7 +76,7 @@ in
isNormalUser = true;
home = "/home/moritz";
extraGroups = [ "wheel" "networkmanager" "video" ];
# initialPassword = "password"; # CHANGE ME PLEASE
initialPassword = "password"; # CHANGE ME PLEASE
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGoAqa2m7hIzZ2LS96Z+RCIlRvhBM/j7h27tMBCwMT+a" # Moritz
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDhtwHDGAZshiQWKkCcPWV9tC83b+bKBgjDcjP/N2CKO" # Laptop
@ -91,95 +88,6 @@ 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 = {
@ -193,6 +101,7 @@ in
cat = "bat";
rm = "rm -i";
mv = "mv -i";
cd = "__zoxide_z";
nixos-update = "pushd ~/.dotfiles && nix flake update && popd";
};
@ -214,8 +123,10 @@ in
"|" = "split-window -h";
"C-l" = "send-keys C-l";
"R" = "source-file $XDG_CONFIG_HOME/tmux/tmux.conf \\; display-message 'Reloaded tmux.conf'";
"f" = "new-window ts";
"a" = "new-window ta";
};
root = {
"C-f" = "new-window ts";
"C-a" = "new-window ta";
};
copy-mode-vi = {
"v" = "send -X begin-selection";
@ -249,23 +160,23 @@ in
parallel
ripgrep
vim
(viu.override { withSixel = true; })
viu
wget
];
fonts = {
enableDefaultPackages = true;
packages = [
(pkgs.nerdfonts.override {
packages = with pkgs; [
(nerdfonts.override {
fonts = [ "FiraCode" ];
})
pkgs.master.intel-one-mono
];
};
programs = {
mtr.enable = true;
command-not-found.enable = false;
command-not-found.enable = true;
starship.enable = true;
};
services = {
@ -299,7 +210,6 @@ in
"--cmd c"
];
};
starship.enable = true;
};
home = {
username = "moritz";

View File

@ -4,8 +4,8 @@
, ...
}:
with lib;
let
inherit (lib) mkEnableOption mkIf mkDefault;
cfg = config.my.profiles.desktop;
in
{
@ -16,7 +16,7 @@ in
yubikey = {
enable = mkDefault true;
luksSupport = {
enable = mkDefault false;
enable = mkDefault true;
devices = mkDefault [ "enc" ];
};
};
@ -32,6 +32,7 @@ in
firefox.enable = mkDefault true;
gpg.enable = mkDefault true;
hyprland.enable = mkDefault true;
logseq.enable = mkDefault true;
nix-edit.enable = mkDefault true;
nvim.enable = mkDefault true;
python.versions."311".enable = mkDefault true;
@ -90,15 +91,6 @@ in
stable.texlive.combined.scheme-full # NOTE breaks often
thunderbird
vlc
(symlinkJoin {
name = "obsidian-wayland";
paths = [ obsidian ];
nativeBuildInputs = [ makeWrapper ];
postBuild = ''
wrapProgram $out/bin/obsidian \
--add-flags "--socket=wayland --enable-features=UseOzonePlatform --ozone-platform=wayland"
'';
})
];
programs.nix-ld.enable = true;
@ -108,14 +100,10 @@ in
enable = true;
startInBackground = true;
};
systemd.user.services.nextcloud-client.Service = {
RestartSec = "500ms";
Restart = "on-failure";
};
};
services = {
illum.enable = true;
resolved.enable = true;
gnome.gnome-keyring.enable = true;
pipewire = {
enable = true;
@ -123,19 +111,5 @@ in
pulse.enable = true;
};
};
# faster startup https://majiehong.com/post/2021-07-30_slow_nixos_startup/
networking = {
# no need to wait interfaces to have an IP to continue booting
dhcpcd.wait = "background";
# avoid checking if IP is already taken to boot a few seconds faster
dhcpcd.extraConfig = "noarp";
};
# disable network-online.target
systemd.services.NetworkManager-wait-online.enable = false;
boot = {
consoleLogLevel = 0;
kernelParams = [ "quiet" "udev.log_level=3" ];
};
};
}

View File

@ -16,6 +16,7 @@ in
environment.systemPackages = with pkgs; [
lutris
legendary-gl
heroic
mangohud
];
};

View File

@ -1,99 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.my.profiles.impermanence;
in
{
options.my.profiles.impermanence.enable = mkEnableOption "impermanence";
config = mkIf cfg.enable {
age.secrets = {
root-password.file = ../../secrets/root-password.age;
moritz-password.file = ../../secrets/moritz-password.age;
};
users.users = {
root.hashedPasswordFile = config.age.secrets.root-password.path;
moritz.hashedPasswordFile = config.age.secrets.moritz-password.path;
};
users.mutableUsers = false;
environment.persistence."/persist" = {
hideMounts = true;
directories = [
"/etc/NetworkManager/system-connections"
"/var/db/dhcpcd/"
"/var/lib/NetworkManager/"
"/var/lib/bluetooth"
"/var/lib/nixos"
"/var/lib/systemd"
"/var/log"
];
files = [
"/etc/machine-id"
"/etc/nix/id_rsa"
"/etc/ssh/ssh_host_ed25519_key"
"/etc/ssh/ssh_host_ed25519_key.pub"
"/etc/ssh/ssh_host_rsa_key"
"/etc/ssh/ssh_host_rsa_key.pub"
];
users.moritz = {
directories = [
".SynologyDrive/data"
".SynologyDrive/log"
".cache/keepassxc"
".cache/nvim/luac"
".cat_installer" # eduroam
".config/JetBrains"
".config/Nextcloud"
".config/calibre"
".config/github-copilot"
".config/kdeconnect"
".config/keepassxc"
".java/.userPrefs/jetbrains/"
".local/share/JetBrains"
".local/share/direnv"
".local/share/nvim"
".local/share/zoxide"
".local/state/nvim"
".mozilla"
"Documents"
"Downloads"
"Music"
"Pictures"
"Videos"
{ directory = ".gnupg"; mode = "0700"; }
{ directory = ".local/share/keyrings"; mode = "0700"; }
{ directory = ".ssh"; mode = "0700"; }
];
files = [
".local/share/fish/fish_history"
".local/share/nix/trusted-settings.json"
".parallel/will-cite"
".local/state/tofi-history"
];
};
users.root = {
home = "/root";
directories = [
{ directory = ".gnupg"; mode = "0700"; }
{ directory = ".ssh"; mode = "0700"; }
];
files = [
".local/share/nix/trusted-settings.json"
];
};
};
environment.systemPackages = [
(
pkgs.writeShellApplication {
name = "zfs-diff";
runtimeInputs = with pkgs; [ zfs coreutils parallel tree ];
text = ''
zfs diff -F zroot/encrypted/root@blank | awk '$2 == "F" && system("test -e /persist/"$3) != 0 { print $3 }' 2>/dev/null | tree --fromfile . "$@"
'';
}
)
];
};
}

View File

@ -30,8 +30,8 @@ in
"browser.search.suggest.enabled" = true;
"browser.urlbar.suggest.searches" = true;
# Restore previous session on startup
"browser.startup.page" = 3;
# startup page
"browser.startup.page" = 0;
# drm
"media.eme.enabled" = true;
@ -41,6 +41,30 @@ in
# disable letterboxing
"privacy.resistFingerprinting.letterboxing" = false;
## OTHER
# Dont show warning when accessing about:config
"browser.aboutConfig.showWarning" = false;
# Hide bookmarks
"browser.toolbars.bookmarks.visibility" = "never";
# Smooth scrolling
"general.smoothScroll.lines.durationMaxMS" = 125;
"general.smoothScroll.lines.durationMinMS" = 125;
"general.smoothScroll.mouseWheel.durationMaxMS" = 200;
"general.smoothScroll.mouseWheel.durationMinMS" = 100;
"general.smoothScroll.msdPhysics.enabled" = true;
"general.smoothScroll.other.durationMaxMS" = 125;
"general.smoothScroll.other.durationMinMS" = 125;
"general.smoothScroll.pages.durationMaxMS" = 125;
"general.smoothScroll.pages.durationMinMS" = 125;
"mousewheel.min_line_scroll_amount" = 40;
"mousewheel.system_scroll_override_on_root_content.enabled" = true;
"mousewheel.system_scroll_override_on_root_content.horizontal.factor" = 175;
"mousewheel.system_scroll_override_on_root_content.vertical.factor" = 175;
"toolkit.scrollbox.horizontalScrollDistance" = 6;
"toolkit.scrollbox.verticalScrollDistance" = 2;
};
};
};

View File

@ -4,23 +4,16 @@
, ...
}:
with lib;
let
cfg = config.my.profiles.webis;
inherit (lib) mkEnableOption mkIf;
in
{
options.my.profiles.webis.enable = mkEnableOption "webis profile";
config = mkIf cfg.enable {
my.programs = {
ssh.includeSecrets = [ ../../secrets/webis-ssh.age ];
jetbrains = {
pycharm.enable = true;
pycharm.package = pkgs.jetbrains.pycharm-professional;
};
};
my.programs.ssh.includeSecrets = [ ../../secrets/webis-ssh.age ];
age.secrets.webis = {
file = ../../secrets/webis.age;
name = "webis.ovpn";
@ -32,6 +25,9 @@ in
updateResolvConf = true;
};
};
environment.systemPackages = with pkgs; [
jetbrains.pycharm-professional
];
programs.dconf.enable = true;
};
}

View File

@ -1,19 +0,0 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.my.programs.exercism;
in
{
options.my.programs.exercism.enable = mkEnableOption "Exercism";
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ exercism ];
age.secrets.exercism = {
path = "/home/moritz/.config/exercism/user.json";
file = ../../secrets/exercism.age;
owner = "1000";
mode = "500";
};
};
}

View File

@ -1,7 +1,6 @@
{ config
, lib
, inputs
, pkgs
, ...
}:
@ -29,153 +28,18 @@ in
);
};
};
package = mkOption {
type = types.package;
default = pkgs.firefox;
example = pkgs.firefox-esr;
};
};
config = mkIf cfg.enable {
home-manager.users.moritz.programs.firefox = {
enable = true;
policies =
let
removeExtensions = [ "Google" "Amazon.de" "Bing" "Amazon" "Wikipedia (en)" "Wikipedia (de)" ];
convertName = name:
let
lower = toLower name;
escaped = replaceStrings [ "." ] [ "dot" ] lower;
sanitized = head (splitString " " escaped);
in
"${sanitized}@search.mozilla.org";
in
{
SearchEngines = mkIf (hasInfix "esr" cfg.package) {
Default = "Kagi";
Remove = removeExtensions;
};
ExtensionSettings = genAttrs
(map convertName removeExtensions)
(_: { installation_mode = "blocked"; });
};
profiles."default" = {
extraConfig = mkIf cfg.arkenfox.enable ''
// Arkenfox user.js
${arkenfox}
profiles."default".extraConfig = mkIf cfg.arkenfox.enable ''
// Arkenfox user.js
${arkenfox}
// Overrides
${cfg.arkenfox.overrides}
'';
extensions = with pkgs.nur.repos.rycee.firefox-addons; [
darkreader
firefox-color
istilldontcareaboutcookies
kagi-search
keepassxc-browser
languagetool
multi-account-containers
sponsorblock
temporary-containers
ublock-origin
vimium
];
settings = {
# Disable Pocket
"extensions.pocket.enabled" = false;
# Disable Activity Stream
# https://wiki.mozilla.org/Firefox/Activity_Stream
"browser.newtabpage.activity-stream.enabled" = false;
"browser.newtabpage.activity-stream.telemetry" = false;
"browser.newtabpage.activity-stream.feeds.discoverystreamfeed" = false;
"browser.newtabpage.activity-stream.feeds.section.topstories" = false;
"browser.newtabpage.activity-stream.section.highlights.includePocket" = false;
"browser.newtabpage.activity-stream.showSponsored" = false;
"browser.newtabpage.activity-stream.improvesearch.topSiteSearchShortcuts.havePinned" = "";
"browser.newtabpage.activity-stream.improvesearch.topSiteSearchShortcuts.searchEngines" = "";
"browser.newtabpage.pinned" = "[]";
# Disable new tab tile ads & preload
# http://www.thewindowsclub.com/disable-remove-ad-tiles-from-firefox
# http://forums.mozillazine.org/viewtopic.php?p=13876331#p13876331
# https://wiki.mozilla.org/Tiles/Technical_Documentation#Ping
# https://gecko.readthedocs.org/en/latest/browser/browser/DirectoryLinksProvider.html#browser-newtabpage-directory-source
# https://gecko.readthedocs.org/en/latest/browser/browser/DirectoryLinksProvider.html#browser-newtabpage-directory-ping
"browser.newtabpage.enhanced" = false;
"browser.newtabpage.introShown" = true;
"browser.newtab.preload" = false;
"browser.newtabpage.directory.ping" = "";
"browser.newtabpage.directory.source" = "data:text/plain,{}";
# Disable some not so useful functionality.
"browser.disableResetPrompt" = true; # "Looks like you haven't started Firefox in a while."
"browser.onboarding.enabled" = false; # "New to Firefox? Let's get started!" tour
"browser.aboutConfig.showWarning" = false; # Warning when opening about:config
"extensions.shield-recipe-client.enabled" = false;
# do not offer to save passwords = nor allow the user to enable the feature
"signon.rememberSignons" = false;
"signon.rememberSignons.visibilityToggle" = false;
# send do not track header
"privacy.donottrackheader.enabled" = true;
# Hide bookmarks
"browser.toolbars.bookmarks.visibility" = "never";
# Smooth scrolling
"general.smoothScroll.lines.durationMaxMS" = 125;
"general.smoothScroll.lines.durationMinMS" = 125;
"general.smoothScroll.mouseWheel.durationMaxMS" = 200;
"general.smoothScroll.mouseWheel.durationMinMS" = 100;
"general.smoothScroll.msdPhysics.enabled" = true;
"general.smoothScroll.other.durationMaxMS" = 125;
"general.smoothScroll.other.durationMinMS" = 125;
"general.smoothScroll.pages.durationMaxMS" = 125;
"general.smoothScroll.pages.durationMinMS" = 125;
"mousewheel.min_line_scroll_amount" = 40;
"mousewheel.system_scroll_override_on_root_content.enabled" = true;
"mousewheel.system_scroll_override_on_root_content.horizontal.factor" = 175;
"mousewheel.system_scroll_override_on_root_content.vertical.factor" = 175;
"toolkit.scrollbox.horizontalScrollDistance" = 6;
"toolkit.scrollbox.verticalScrollDistance" = 2;
# Do not check if Firefox is the default browser
"browser.shell.checkDefaultBrowser" = false;
# Reduce search engine noise in the urlbar's completion window. The
# shortcuts and suggestions will still work, but Firefox won't clutter
# its UI with reminders that they exist.
"browser.urlbar.suggest.searches" = false;
"browser.urlbar.shortcuts.bookmarks" = false;
"browser.urlbar.shortcuts.history" = false;
"browser.urlbar.shortcuts.tabs" = false;
"browser.urlbar.showSearchSuggestionsFirst" = false;
"browser.urlbar.speculativeConnect.enabled" = false;
# https://bugzilla.mozilla.org/1642623
"browser.urlbar.dnsResolveSingleWordsAfterSearch" = 0;
# https://blog.mozilla.org/data/2021/09/15/data-and-firefox-suggest/
"browser.urlbar.suggest.quicksuggest.nonsponsored" = false;
"browser.urlbar.suggest.quicksuggest.sponsored" = false;
# Show whole URL in address bar
"browser.urlbar.trimURLs" = false;
# auto enable addons
"extensions.autoDisableScopes" = 0;
# Disable Form autofill
# https://wiki.mozilla.org/Firefox/Features/Form_Autofill
"browser.formfill.enable" = false;
"extensions.formautofill.addresses.enabled" = false;
"extensions.formautofill.available" = "off";
"extensions.formautofill.creditCards.available" = false;
"extensions.formautofill.creditCards.enabled" = false;
"extensions.formautofill.heuristics.enabled" = false;
};
};
// Overrides
${cfg.arkenfox.overrides}
'';
};
};
}

View File

@ -31,7 +31,7 @@ in
enable = true;
shellAbbrs = shellConfig.abbreviations;
shellAliases = shellConfig.aliases;
shellInit = /* fish */ ''
shellInit = ''
# Vi Mode
fish_vi_key_bindings
@ -62,7 +62,7 @@ in
end
abbr --add dotdot --regex '^\.\.+$' --function multicd
abbr -a .P --position anywhere --set-cursor "% | $PAGER"
abbr -a P --position anywhere --set-cursor "% | $PAGER"
function editor_edit
echo $EDITOR $argv
@ -114,7 +114,6 @@ in
'';
};
};
starship.enableTransience = true;
};
};
};

View File

@ -1,29 +0,0 @@
{ config
, lib
, ...
}:
with lib;
let
cfg = config.my.programs.foot;
in
{
options.my.programs.foot.enable = mkEnableOption "foot";
config = mkIf cfg.enable {
home-manager.users.moritz = {
programs.foot = {
enable = true;
settings = {
main = {
term = "xterm-256color";
font = "FiraCode Nerd Font:size=10";
};
colors = {
alpha = 0.98;
};
};
};
};
};
}

View File

@ -1,5 +1,6 @@
{ config
, lib
, pkgs
, ...
}:
@ -29,24 +30,18 @@ in
config = mkIf cfg.enable {
my.shell.abbreviations = {
g = "git";
gC = "git clone";
gF = "git pull";
gS = "git switch";
ga = "git add";
gap = "git add --patch";
gr = "git restore";
grp = "git restore --patch";
gb = "git branch";
gc = "git commit";
gco = "git checkout";
gd = "git diff";
gds = "git diff --staged";
gf = "git fetch";
gp = "git push";
gr = "git restore";
grm = "git rm --cached";
grp = "git restore --patch";
grps = "git restore --patch --staged";
grs = "git restore --staged";
gf = "git fetch";
gF = "git pull";
gs = "git status";
};
home-manager.users.moritz = {
@ -55,23 +50,21 @@ in
userName = cfg.identity.name;
userEmail = cfg.identity.email;
extraConfig = {
commit.verbose = true;
diff.algorithm = "histogram";
fetch.fsckobjects = true;
init.defaultBranch = "main";
merge.conflictstyle = "zdiff3";
diff.external = getExe pkgs.difftastic;
push.autoSetupRemote = true;
receive.fsckObjects = true;
transfer.fsckobjects = true;
};
signing = mkIf cfg.signing {
key = "0x970C6E89EB0547A9";
signByDefault = true;
};
lfs.enable = true;
delta.enable = true;
};
};
programs.git.enable = true;
programs.git = {
enable = true;
config.safe.directory = "/home/moritz/.dotfiles";
};
};
}

View File

@ -1,24 +0,0 @@
{ config
, pkgs
, lib
, ...
}:
let
inherit (lib) mkEnableOption mkIf mkOption types;
cfg = config.my.programs.gitbutler;
in
{
options.my.programs.gitbutler = {
enable = mkEnableOption "gitbutler";
package = mkOption {
default = pkgs.callPackage ./package.nix { };
type = types.package;
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
};
}

View File

@ -1,16 +0,0 @@
{ fetchzip, appimageTools }:
let
pname = "git-butler";
version = "0.12.4";
buildNum = "994";
srcZipped = fetchzip {
url = "https://releases.gitbutler.com/releases/release/${version}-${buildNum}/linux/x86_64/git-butler_${version}_amd64.AppImage.tar.gz";
hash = "sha256-+QP+H0bVSLbobv/W6lFBbl08RnwKvG8BVo68bwMrAzM=";
};
in
appimageTools.wrapType2 {
inherit pname version;
src = "${srcZipped}/git-butler_${version}_amd64.AppImage";
}

View File

@ -20,7 +20,10 @@ in
config = lib.mkIf cfg.enable {
hardware = {
opengl.enable = true;
opengl = {
enable = true;
driSupport = true;
};
pulseaudio.enable = false;
};
services.xserver = {

View File

@ -3,18 +3,10 @@
, ...
}:
with lib;
let
inherit (lib) concatStringsSep flip boolToString mapAttrsToList;
cfg = config.my.programs.hyprland;
mkMonitor = { name, resolution, position, scale, disabled, extra }:
if disabled
then "monitor=${name},disabled"
else "monitor=${name},${resolution},${position},${scale},${extra}";
monitorsList = mapAttrsToList (name: value: { name = name; } // value) cfg.monitors;
monitors = map mkMonitor monitorsList;
mkRule = rule: windowRegexes: "windowrulev2 = ${rule},${concatStringsSep "," windowRegexes}";
mkRules = rules: windowRegexes: concatStringsSep "\n" (map (flip mkRule windowRegexes) rules);
in
@ -25,14 +17,17 @@ in
#
# See https://wiki.hyprland.org/Configuring/Monitors/
${concatStringsSep "\n" monitors}
${concatLines (map (x: "monitor=${x}") cfg.monitors)}
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
# For all categories, see https://wiki.hyprland.org/Configuring/Variables/
input {
kb_layout = ${concatStringsSep "," cfg.keyboardLayouts}
kb_variant =
kb_model =
kb_options = grp:win_space_toggle,caps:escape
kb_rules =
follow_mouse = 1
@ -52,11 +47,9 @@ in
col.active_border = rgba(1affffee)
col.inactive_border = rgba(595959aa)
layout = dwindle
}
cursor_inactive_timeout = 1
cursor {
inactive_timeout = 1
layout = dwindle
}
decoration {
@ -109,7 +102,7 @@ in
master {
# See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
no_gaps_when_only = true
new_on_top = false
new_is_master = false
}
gestures {
@ -118,28 +111,21 @@ in
}
misc {
vrr = 0
# disable_hypr_chan = true
vrr = 1
mouse_move_enables_dpms = true
key_press_enables_dpms = true
force_default_wallpaper = 0
}
xwayland {
force_zero_scaling = true
}
# scale non native wayland gtk applications
env = GDK_SCALE,1.2
# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
# Firefox Sharing Indicator
${mkRules ["float" "move 49% 40" "noborder"] ["title:^(.*Sharing Indicator.*)$"]}
${mkRules ["float" "move 49% 40" "noborder" "nofullscreenrequest"] ["title:^(.*Sharing Indicator.*)$"]}
# Emacs
windowrulev2 = opaque, class:^(emacs)$
# Fullscreen Applications
${mkRules ["opaque" "noblur" "noborder" "noshadow" "allowsinput"] ["fullscreen:1"]}
${mkRules ["opaque" "noblur" "noborder" "noshadow" "forceinput"] ["fullscreen:1"]}
${mkRules ["tile" "opaque"] ["class:^(neovide)$"]}
@ -147,7 +133,7 @@ in
windowrulev2 = rounding 0, xwayland:1, floating:1
windowrulev2 = center, class:^(.*jetbrains.*)$, title:^(Confirm Exit|Open Project|win424|win201|splash)$
windowrulev2 = size 640 400, class:^(.*jetbrains.*)$, title:^(splash)$
windowrulev2 = nofocus, class:^jetbrains-(?!toolbox), floating:1, title:^win\d+$
${mkRules ["opaque" "noshadow" "noblur" "noanim" "move cursor 5 5"] ["class:^(.*jetbrains-.*)$"]}
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
$mainMod = SUPER
@ -156,89 +142,80 @@ in
# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
# Window binds
bind = $mainMod , F , togglefloating ,
bind = $mainMod , P , pseudo ,
bind = $mainMod , Q , killactive ,
bind = $mainMod , T , togglesplit ,
bind = $mainMod SHIFT , F , fullscreen ,
bind = $mainMod , F , togglefloating ,
bind = $mainMod , P , pseudo ,
bind = $mainMod , Q , killactive ,
bind = $mainMod , T , togglesplit ,
bind = $mainMod SHIFT , F , fullscreen ,
# Program binds
bind = $mainMod , B , exec , rofi-bluetooth
bind = $mainMod , C , exec , rofi -show calc -modi calc -no-show-match -no-sort | wl-copy
bind = $mainMod , D , exec , hyprctl keyword general:layout dwindle
bind = $mainMod , M , exec , hyprctl keyword general:layout master
bind = $mainMod , R , exec , rofi -show combi
# bind = $mainMod , RETURN , exec , systemctl --user is-active --quiet foot && footclient --no-wait || foot
bind = $mainMod , RETURN , exec , kitty
bind = $mainMod , B , exec , rofi-bluetooth
bind = $mainMod , C , exec , rofi -show calc -modi calc -no-show-match -no-sort | wl-copy
bind = $mainMod , D , exec , hyprctl keyword general:layout dwindle
bind = $mainMod , M , exec , hyprctl keyword general:layout master
bind = $mainMod , R , exec , rofi -show combi
bind = $mainMod , RETURN , exec , kitty
# XF86 keys
binde = , XF86AudioLowerVolume , exec , pamixer -d 5
binde = , XF86AudioRaiseVolume , exec , pamixer -i 5
bind = , XF86AudioMute , exec , pamixer -t
bind = , XF86AudioNext , exec , playerctl -p "spotifyd,firefox" next
bind = , XF86AudioPlay , exec , playerctl -p "spotifyd,firefox" play-pause
bind = , XF86AudioPrev , exec , playerctl -p "spotifyd,firefox" previous
bind = , XF86AudioMute , exec , pamixer -t
bind = , XF86AudioNext , exec , playerctl -p "spotifyd,firefox" next
bind = , XF86AudioPlay , exec , playerctl -p "spotifyd,firefox" play-pause
bind = , XF86AudioPrev , exec , playerctl -p "spotifyd,firefox" previous
# Move focus with mainMod + hjkl
binde = $mainMod , H , movefocus , l
binde = $mainMod , L , movefocus , r
binde = $mainMod , K , movefocus , u
binde = $mainMod , J , movefocus , d
binde = $mainMod, H, movefocus, l
binde = $mainMod, L, movefocus, r
binde = $mainMod, K, movefocus, u
binde = $mainMod, J, movefocus, d
# Change current active window size with mainMod + SHIFT + hjkl
binde = $mainMod SHIFT , H , resizeactive , -10 0
binde = $mainMod SHIFT , J , resizeactive , 0 10
binde = $mainMod SHIFT , K , resizeactive , 0 -10
binde = $mainMod SHIFT , L , resizeactive , 10 0
binde = $mainMod SHIFT, H, resizeactive, -10 0
binde = $mainMod SHIFT, J, resizeactive, 0 10
binde = $mainMod SHIFT, K, resizeactive, 0 -10
binde = $mainMod SHIFT, L, resizeactive, 10 0
# Move current active window with mainMod + ALT + hjkl
bind = $mainMod ALT , H , movewindow , l
bind = $mainMod ALT , J , movewindow , d
bind = $mainMod ALT , K , movewindow , u
bind = $mainMod ALT , L , movewindow , r
bind = $mainMod ALT, H, movewindow, l
bind = $mainMod ALT, J, movewindow, d
bind = $mainMod ALT, K, movewindow, u
bind = $mainMod ALT, L, movewindow, r
# Switch workspaces with mainMod + [0-9]
bind = $mainMod , 1 , workspace , 1
bind = $mainMod , 2 , workspace , 2
bind = $mainMod , 3 , workspace , 3
bind = $mainMod , 4 , workspace , 4
bind = $mainMod , 5 , workspace , 5
bind = $mainMod , 6 , workspace , 6
bind = $mainMod , 7 , workspace , 7
bind = $mainMod , 8 , workspace , 8
bind = $mainMod , 9 , workspace , 9
bind = $mainMod , 0 , workspace , 10
bind = $mainMod, 1, workspace, 1
bind = $mainMod, 2, workspace, 2
bind = $mainMod, 3, workspace, 3
bind = $mainMod, 4, workspace, 4
bind = $mainMod, 5, workspace, 5
bind = $mainMod, 6, workspace, 6
bind = $mainMod, 7, workspace, 7
bind = $mainMod, 8, workspace, 8
bind = $mainMod, 9, workspace, 9
bind = $mainMod, 0, workspace, 10
# Move active window to a workspace with mainMod + SHIFT + [0-9]
bind = $mainMod SHIFT , 1 , movetoworkspace , 1
bind = $mainMod SHIFT , 2 , movetoworkspace , 2
bind = $mainMod SHIFT , 3 , movetoworkspace , 3
bind = $mainMod SHIFT , 4 , movetoworkspace , 4
bind = $mainMod SHIFT , 5 , movetoworkspace , 5
bind = $mainMod SHIFT , 6 , movetoworkspace , 6
bind = $mainMod SHIFT , 7 , movetoworkspace , 7
bind = $mainMod SHIFT , 8 , movetoworkspace , 8
bind = $mainMod SHIFT , 9 , movetoworkspace , 9
bind = $mainMod SHIFT , 0 , movetoworkspace , 10
bind = $mainMod SHIFT, 1, movetoworkspace, 1
bind = $mainMod SHIFT, 2, movetoworkspace, 2
bind = $mainMod SHIFT, 3, movetoworkspace, 3
bind = $mainMod SHIFT, 4, movetoworkspace, 4
bind = $mainMod SHIFT, 5, movetoworkspace, 5
bind = $mainMod SHIFT, 6, movetoworkspace, 6
bind = $mainMod SHIFT, 7, movetoworkspace, 7
bind = $mainMod SHIFT, 8, movetoworkspace, 8
bind = $mainMod SHIFT, 9, movetoworkspace, 9
bind = $mainMod SHIFT, 0, movetoworkspace, 10
# Scroll through existing workspaces with mainMod + scroll
bind = $mainMod , mouse_down , workspace , e+1
bind = $mainMod , mouse_up , workspace , e-1
bind = $mainMod, mouse_down, workspace, e+1
bind = $mainMod, mouse_up, workspace, e-1
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod , mouse:272 , movewindow
bindm = $mainMod , mouse:273 , resizewindow
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow
# Toggle waybar
bindr = $mainMod , SUPER_L , exec , pkill -USR1 waybar
# Lid open/close
bindl=,switch:on:Lid Switch,exec,monitors="$(hyprctl monitors | grep -c '^Monitor')" && hyprctl keyword monitor "eDP-1, disable" && [ "$monitors" = 1 ] && loginctl lock-session
bindl=,switch:off:Lid Switch,exec, hyprctl keyword monitor "eDP-1, preferred, auto"
# Lock Screen
bind=$mainMod ALT, L, exec, loginctl lock-session
bindr = $mainMod, SUPER_L, exec, pkill -USR1 waybar
# Extra Config
${cfg.extraConfig}

View File

@ -5,11 +5,12 @@
, ...
} @ args:
with lib;
let
inherit (lib) mkOption mkEnableOption mkIf types getExe genAttrs optionalAttrs optional;
cfg = config.my.programs.hyprland;
hyprland = inputs.hyprland.packages.${pkgs.system}.default;
hyprland-nvidia = pkgs.hyprland.override { enableNvidiaPatches = true; };
hyprland = if cfg.nvidiaSupport then hyprland-nvidia else pkgs.hyprland;
in
{
options.my.programs.hyprland = {
@ -31,35 +32,9 @@ in
default = [ "de" "us" ];
};
monitors = mkOption {
type = types.attrsOf (
let
sub = types.submodule {
options = {
resolution = mkOption {
type = types.strMatching "\(preferred\)|\([[:digit:]]+x[[:digit:]]+\(@[[:digit:]]+\)\?\)";
default = "preferred";
};
position = mkOption {
type = types.strMatching "\(auto\)|\(-\?[[:digit:]]+x-?[[:digit:]]+\)";
default = "auto";
};
disabled = mkEnableOption "disabled";
scale = mkOption {
type = types.oneOf [ types.float (types.strMatching "auto") ];
default = 1.0;
apply = x: if lib.isFloat x then lib.strings.floatToString x else x;
};
extra = mkOption {
type = types.listOf types.str;
default = [ ];
apply = lib.concatStringsSep ",";
};
};
};
in
sub
);
description = "monitor setting";
type = types.listOf types.str;
description = "monitor settings";
default = [ ",preferred,auto,1" ];
};
extraConfig = mkOption {
type = types.str;
@ -69,63 +44,37 @@ in
config = mkIf cfg.enable {
my = {
nixpkgs.overlays = [
inputs.hypr-contrib.overlays.default
];
programs = {
wallpaper.enable = true;
# foot.enable = true;
kitty.enable = true;
rofi.enable = true;
hyprland.monitors."" = lib.mkDefault { };
hyprland.monitors."Unknown-1" = { disabled = true; };
};
wallpapers.enable = true;
services = {
dunst.enable = true;
wallpaper = {
enable = true;
target = "hyprland-session.target";
};
spotify-player.target = "hyprland-session.target";
};
};
programs.hyprland = {
enable = true;
package = hyprland;
portalPackage = inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland;
services.dunst.enable = true;
services.wallpaper.enable = true;
};
home-manager.users.moritz = {
# import home-manager module
imports = [ inputs.hyprland.homeManagerModules.default ];
# enable home-manager module
wayland.windowManager.hyprland = {
enable = true;
package = hyprland;
recommendedEnvironment = true;
extraConfig = import ./_config.nix args;
systemd.extraCommands = [
"systemctl --user stop hyprland-session.target"
"sleep 1.5"
"systemctl --user start hyprland-session.target"
"systemctl --user start xdg-desktop-portal-hyprland.service"
];
};
# add waybar as a status bar
programs.waybar = {
enable = true;
package = pkgs.waybar.overrideAttrs (old: {
patches = old.patches or [ ] ++ [
(pkgs.fetchpatch {
url = "https://gitlab.archlinux.org/archlinux/packaging/packages/waybar/-/raw/0306af03fcb6de6aee1e288f42b0bf1b223513bd/a544f4b2cdcf632f1a4424b89f6e3d85ef5aaa85.patch";
sha256 = "sha256-S/1oUj9Aj6BElNTsDY8CTcKtS1j7Gl54JFgCywH05pg=";
})
];
});
# start using systemd service
systemd = {
enable = true;
target = "hyprland-session.target";
target = "graphical-session.target";
};
settings = {
@ -133,7 +82,7 @@ in
start_hidden = true;
layer = "top";
position = "top";
height = 24;
height = 20;
modules-left = [ "hyprland/workspaces" ];
modules-center = [ "hyprland/window" ];
modules-right = [ "hyprland/language" "network" "memory" "cpu" "battery" "clock" ];
@ -186,11 +135,29 @@ in
};
systemdTarget = "hyprland-session.target";
};
systemd.user.services.nextcloud-client.Service = {
RestartSec = "500ms";
Restart = "on-failure";
};
};
# adds pam module for swaylock
security.pam.services.swaylock = { };
# only consider graphical-session.target started when hyprland-sesstion.target is reached
systemd.user.targets.hyprland-session = {
partOf = [ "graphical-session.target" ];
wantedBy = [ "graphical-session.target" ];
before = [ "graphical-session.target" ];
};
systemd.user.services.xdg-desktop-portal-hyprland = {
after = [ "hyrpland-session.target" ];
requiredBy = [ "xdg-desktop-portal.service" ];
};
# add user packages for wayland and hyprland in particular
users.users.moritz.packages = with pkgs; [
brightnessctl # control brightness
@ -223,6 +190,7 @@ in
__GL_VRR_ALLOWED = "0";
});
services = {
dbus.enable = true;
# use pipewire (needed for screensharing)
@ -232,39 +200,27 @@ in
alsa.support32Bit = true;
pulse.enable = true;
};
displayManager = {
xserver = {
enable = true;
autoLogin = {
enable = true;
user = "moritz";
displayManager = {
lightdm.enable = true;
autoLogin = {
enable = true;
user = "moritz";
};
defaultSession = "hyprland";
sessionPackages = [ hyprland ]; # can't set the defaultSession otherwise
};
defaultSession = "hyprland";
};
xserver.enable = true;
xserver.displayManager.lightdm.enable = true;
};
security.rtkit.enable = true;
home-manager.users.moritz.systemd.user.services =
let
units = [ "waybar" ];
mkAfter = _: {
Unit = {
After = [ "hyprland-session.target" ];
Wants = [ "hyprland-session.target" ];
};
};
in
genAttrs units mkAfter;
systemd.user.services =
let
units = [ "pipewire" "xdg-desktop-portal" "xdg-desktop-portal-hyprland" "wireplumber" ];
mkAfter = _: {
after = [ "hyprland-session.target" ];
wants = [ "hyprland-session.target" ];
};
in
genAttrs units mkAfter;
# desktop portal (for screensharing)
xdg.portal = {
enable = true;
wlr.enable = mkForce false;
extraPortals = [ pkgs.xdg-desktop-portal-hyprland ];
};
};
}

View File

@ -1,38 +0,0 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) any filterAttrs mapAttrsToList mkEnableOption mkIf mkOption;
cfg = config.my.programs.jetbrains;
isEnabled = _: value: value.enable;
anyEnabled = any (x: x) (mapAttrsToList isEnabled cfg);
in
{
options.my.programs.jetbrains = {
pycharm = {
enable = mkEnableOption "pycharm";
package = mkOption {
default = pkgs.jetbrains.pycharm-community;
};
};
idea = {
enable = mkEnableOption "idea";
package = mkOption {
default = pkgs.jetbrains.idea-community;
};
};
};
config = mkIf anyEnabled {
home-manager.users.moritz = {
xdg.configFile."ideavim/ideavimrc" = {
source = ./ideavimrc;
};
home.packages =
let
enabledPackages = filterAttrs isEnabled cfg;
in
mapAttrsToList (_: value: value.package) enabledPackages;
};
};
}

View File

@ -1,90 +0,0 @@
""" Map leader to space ---------------------
let mapleader=" "
""" Plugins --------------------------------
set surround
set commentary
set NERDTree
""" Common settings -------------------------
set showmode
set so=5
set incsearch
set nu
set relativenumber
set number
""" Which-Key
set which-key
set timeoutlen=5000
""" Idea specific settings ------------------
set ideajoin
""" Mappings --------------------------------
"" Quick action
let g:WhichKeyDesc_quick_action = '<leader>q Quick action'
map <leader>q <Action>(ShowIntentionActions)
"" Refactor binds
let g:WhichKeyDesc_inline = '<leader>i Inline'
map <leader>i <Action>(Inline)
let g:WhichKeyDesc_extract = '<leader>e Extract'
let g:WhichKeyDesc_extract_variable = '<leader>ev Extract variable'
map <leader>ev <Action>(IntroduceVariable)
let g:WhichKeyDesc_extract_constant = '<leader>ec Extract constant'
map <leader>ec <Action>(IntroduceConstant)
let g:WhichKeyDesc_extract_field = '<leader>ef Extract field'
map <leader>ef <Action>(IntroduceField)
let g:WhichKeyDesc_extract_parameter = '<leader>ep Extract parameter'
map <leader>ep <Action>(IntroduceParameter)
let g:WhichKeyDesc_extract_method = '<leader>em Extract method'
map <leader>em <Action>(ExtractMethod)
let g:WhichKeyDesc_rename = '<leader>r Rename'
map <leader>r <Action>(RenameElement)
"" Navigation
let g:WhichKeyDesc_prev_buffer = ']b Previous buffer'
map [b <Action>(PreviousTab)
let g:WhichKeyDesc_next_buffer = ']b Next buffer'
map ]b <Action>(NextTab)
let g:WhichKeyDesc_goto_impl = 'gI Goto implementation'
map gI <Action>(GotoImplementation)
let g:WhichKeyDesc_goto_type = 'gt Goto type declaration'
map gt <Action>(GotoTypeDeclaration)
"" Other
let g:WhichKeyDesc_terminal = '<leader>t Terminal'
map <leader>t <Action>(ActivateTerminalToolWindow)
map = <Action>(ReformatCode)
"" Folding
let g:WhichKeyDesc_folding = 'z Folding'
let g:WhichKeyDesc_folding_toggle = 'za Toggle fold'
map za <Action>(ExpandCollapseToggleAction)
let g:WhichKeyDesc_folding_expand = 'zr Fold less'
map zr <Action>(ExpandRegion)
let g:WhichKeyDesc_folding_collapse = 'zR Open all folds'
map zR <Action>(ExpandAllRegions)
let g:WhichKeyDesc_folding_collapse = 'zm Fold more'
map zm <Action>(CollapseRegion)
let g:WhichKeyDesc_folding_collapse = 'zM Close all folds'
map zM <Action>(CollapseAllRegions)
let g:WhichKeyDesc_folding_collapse_doc = 'zc Collapse doc comments'
map zc <Action>(CollapseDocComments)
let g:WhichKeyDesc_folding_expand_doc = 'zC Expand doc comments'
map zC <Action>(ExpandDocComments)
let g:WhichKeyDesc_folding_expand_level_one = 'z1 Expand all to level 1'
map z1 <Action>(ExpandAllToLevel1)
let g:WhichKeyDesc_folding_expand_level_two = 'z2 Expand all to level 2'
map z2 <Action>(ExpandAllToLevel2)
let g:WhichKeyDesc_folding_expand_level_three = 'z3 Expand all to level 3'
map z3 <Action>(ExpandAllToLevel3)
let g:WhichKeyDesc_folding_expand_level_four = 'z4 Expand all to level 4'
map z4 <Action>(ExpandAllToLevel4)

View File

@ -22,15 +22,13 @@ in
window_padding_width = 3;
confirm_os_window_close = 0;
background_opacity = "0.9";
font_features = "IntelOneMono-Regular +ss01";
resize_in_steps = "yes";
};
keybindings = {
"ctrl+plus" = "change_font_size all +2.0";
"ctrl+minus" = "change_font_size all -2.0";
};
font = {
name = "Intel One Mono";
name = "FiraCode Nerd Font";
size = 10;
};
};

View File

@ -6,16 +6,9 @@
, ...
}:
with lib;
let
inherit (lib) mkEnableOption mkOption types;
cfg = config.my.programs.nix;
mkNom = system: nix:
inputs.nix-monitored.packages.${system}.default.override
{
withNotify = false;
nix = nix;
};
in
{
options.my.programs.nix = {
@ -30,62 +23,46 @@ in
optimise.enable = mkEnableOption "nix-optimise";
};
config = {
my.nixpkgs.overlays = [
(final: prev:
{
nixos-rebuild = prev.nixos-rebuild.override {
nix = mkNom final.system final.nix;
};
})
];
config.nix = {
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
home-manager.users.moritz.programs.direnv.nix-direnv.package = pkgs.nix-direnv.override {
nix = config.nix.package;
package = pkgs.nix-super;
extraOptions = "experimental-features = nix-command flakes";
gc = {
automatic = cfg.gc.enable;
options = "--max-freed ${cfg.gc.minimumFreedGB} --delete-older-than 14d";
dates = "weekly";
};
nix = {
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
optimise = {
automatic = cfg.optimise.enable;
dates = [ "weekly" ];
};
package = pkgs.nix;
extraOptions = "experimental-features = nix-command flakes";
gc = {
automatic = cfg.gc.enable;
options = "--max-freed ${cfg.gc.minimumFreedGB} --delete-older-than 14d";
dates = "weekly";
registry = {
master-upstream.to = {
type = "github";
owner = "nixos";
repo = "nixpkgs";
};
master.flake = inputs.master;
nixpkgs.flake = inputs.nixpkgs;
stable.flake = inputs.stable;
dotfiles.flake = self;
default.flake = self;
};
optimise = {
automatic = cfg.optimise.enable;
dates = [ "weekly" ];
};
settings = {
substituters = [
"https://cache.nixos.org/"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
registry = {
master-upstream.to = {
type = "github";
owner = "nixos";
repo = "nixpkgs";
};
master.flake = inputs.master;
nixpkgs.flake = inputs.nixpkgs;
stable.flake = inputs.stable;
dotfiles.flake = self;
default.flake = self;
d.flake = self;
};
settings = {
substituters = [
"https://cache.nixos.org/"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
trusted-users = [ "root" "@wheel" ];
};
trusted-users = [ "root" "@wheel" ];
};
};
}

View File

@ -1,8 +1,7 @@
{ config, lib, pkgs, inputs, ... }:
{ config, lib, pkgs, ... }:
with lib;
let
inherit (lib) mkEnableOption mkIf readFile;
cfg = config.my.programs.nvim;
in
{
@ -12,18 +11,17 @@ in
config = mkIf cfg.enable {
home-manager.users.moritz = {
xdg.configFile."nvim/snippets" = {
recursive = true;
source = ./plugins/snippets;
};
home.packages = with pkgs; [
xdotool # for vimtex
(
if config.my.programs.hyprland.enable
then neovide-hyprland
else neovide
)
];
programs.neovim = {
enable = true;
package = inputs.neovim-nightly-overlay.packages.${pkgs.system}.default;
package = pkgs.neovim-nightly;
vimAlias = true;
vimdiffAlias = true;
withNodeJs = true;
@ -31,23 +29,23 @@ in
extraPackages = with pkgs;
[
alejandra
checkmake
codespell
black
deadnix
dotenv-linter
fish
isort
jq
nil
nixd
nixpkgs-fmt
nodePackages.bash-language-server
python3Packages.python-lsp-server
rustfmt
shellcheck
shfmt
stable.yamlfix
statix
stylua
sumneko-lua-language-server
taplo
yamllint
typst
typst-lsp
yamlfmt
];
extraLuaConfig = readFile ./options.lua;
lazy.enable = true;

View File

@ -26,17 +26,6 @@ vim.opt.updatetime = 300
vim.opt_local.spell = true
vim.opt_local.spelllang = { "en", "de_20" } -- all English regions and new German spelling
-- Abbreviations for common typos
vim.cmd("cnoreabbrev W! w!")
vim.cmd("cnoreabbrev Q! q!")
vim.cmd("cnoreabbrev Qall! qall!")
vim.cmd("cnoreabbrev Wq wq")
vim.cmd("cnoreabbrev Wa wa")
vim.cmd("cnoreabbrev wQ wq")
vim.cmd("cnoreabbrev WQ wq")
vim.cmd("cnoreabbrev W w")
vim.cmd("cnoreabbrev Q q")
if vim.g.neovide then
vim.opt.guifont = "Fira Code Nerd Font:h10"
vim.g.neovide_scale_factor = 0.7

View File

@ -1,123 +1,145 @@
{ pkgs, lib, inputs, ... }:
{ pkgs, lib, ... }:
let
inherit (builtins) readFile;
in
with builtins;
{
config.home-manager.users.moritz.programs.neovim.lazy.plugins = [
config.home-manager.users.moritz.programs.neovim.lazy.plugins = with pkgs.vimPlugins; [
{
plugin = pkgs.vimPlugins.oil-nvim;
plugin = formatter-nvim;
cmd = [ "Format" "Fmt" ];
keys = [
{
key = "=";
cmd = "<cmd>Format<cr>";
desc = "format (formatter)";
}
];
conf = readFile ./lua/formatter-nvim.lua;
}
{
plugin = oil-nvim;
lazy = false;
opts = { };
dependencies = [{ plugin = pkgs.vimPlugins.nvim-web-devicons; }];
dependencies = [
{ plugin = which-key-nvim; }
{ plugin = nvim-web-devicons; }
];
}
{
plugin = pkgs.vimPlugins.lualine-nvim;
opts = { };
dependencies = [{ plugin = pkgs.vimPlugins.nvim-web-devicons; }];
}
{
plugin = pkgs.vimPlugins.mini-nvim;
plugin = mini-nvim;
lazy = false;
conf = readFile ./lua/mini-nvim.lua;
}
{
plugin = pkgs.vimPlugins.nvim-cmp;
plugin = trouble-nvim;
keys = [
{ key = "<leader>tc"; cmd = "<cmd>CmpToggle<cr>"; desc = "Toggle Cmp sources"; }
{ key = "<leader>xx"; cmd = "<cmd>TroubleToggle document_diagnostics<cr>"; desc = "Document Diagnostics (Trouble)"; }
{ key = "<leader>xX"; cmd = "<cmd>TroubleToggle workspace_diagnostics<cr>"; desc = "Workspace Diagnostics (Troule)"; }
{ key = "<leader>xl"; cmd = "<cmd>TroubleToggle loclist<cr>"; desc = "Location List (Trouble)"; }
{ key = "<leader>xq"; cmd = "<cmd>TroubleToggle quickfix<cr>"; desc = "Quickfix List (Trouble)"; }
{ key = "<leader>xt"; cmd = "<cmd>TodoTrouble<cr>"; desc = "Todo (Trouble)"; }
{ key = "<leader>xT"; cmd = "<cmd>TodoTrouble keywords=TODO,FIX,FIXME<cr>"; desc = "Todo/Fix/Fixme (Trouble)"; }
{ key = "<leader>ft"; cmd = "<cmd>TodoTelescope<cr>"; desc = "Todo"; }
{
key = "[q";
func = /* lua */ ''
function()
if require("trouble").is_open() then
require("trouble").previous({ skip_groups = true, jump = true })
else
vim.cmd.cprev()
end
end
'';
desc = "Previous trouble/quickfix item";
}
{
key = "]q";
func = /* lua */ ''
function()
if require("trouble").is_open() then
require("trouble").next({ skip_groups = true, jump = true })
else
vim.cmd.cnext()
end
end
'';
desc = "Next trouble/quickfix item";
}
];
opts = { };
dependencies = [
{ plugin = which-key-nvim; }
{ plugin = nvim-web-devicons; }
];
}
{
plugin = nvim-cmp;
conf = readFile ./lua/nvim-cmp.lua;
event = [ "InsertEnter" ];
dependencies = [
{
plugin = pkgs.vimPlugins.nvim-autopairs;
plugin = nvim-autopairs;
opts = { };
}
{ plugin = pkgs.vimPlugins.cmp-async-path; }
{ plugin = pkgs.vimPlugins.cmp-buffer; }
{ plugin = pkgs.vimPlugins.cmp-cmdline; }
{ plugin = pkgs.vimPlugins.cmp-nvim-lsp-signature-help; }
{ plugin = pkgs.vimPlugins.cmp-nvim-lsp; }
{ plugin = cmp-async-path; }
{ plugin = cmp-buffer; }
{ plugin = cmp-cmdline; }
{ plugin = cmp-nvim-lsp; }
{ plugin = cmp_luasnip; }
{
plugin = pkgs.vimUtils.buildVimPlugin {
pname = "cmp-vimtex";
version = lib.my.mkVersionInput inputs.cmp-vimtex;
src = inputs.cmp-vimtex;
};
}
{ plugin = pkgs.vimPlugins.cmp_luasnip; }
# {
# plugin = pkgs.vimPlugins.copilot-cmp;
# opts = { };
# dependencies = [
# {
# plugin = pkgs.vimPlugins.copilot-lua;
# opts = {
# suggestion = { enabled = false; };
# panel = { enabled = false; };
# };
# conf = /* lua */ ''
# require("copilot").setup(opts)
# vim.cmd("Copilot disable")
# '';
# }
# ];
# }
{ plugin = pkgs.vimPlugins.friendly-snippets; }
{ plugin = pkgs.vimPlugins.lspkind-nvim; }
{
plugin = pkgs.vimPlugins.luasnip;
conf = readFile ./lua/luasnip.lua;
plugin = codeium-nvim;
opts = { };
}
{ plugin = friendly-snippets; }
{ plugin = lspkind-nvim; }
{ plugin = luasnip; }
];
}
{
plugin = pkgs.vimPlugins.direnv-vim;
plugin = direnv-vim;
lazy = false;
}
{
plugin = pkgs.vimPlugins.nvim-lspconfig.overrideAttrs (_: {
version = lib.my.mkVersionInput inputs.nvim-lspconfig;
src = inputs.nvim-lspconfig;
});
plugin = nvim-lspconfig;
event = [ "BufRead" "BufNewFile" ];
conf = readFile ./lua/nvim-lspconfig.lua;
dependencies = [
{ plugin = lsp_signature-nvim; }
{
# TODO: add all required tools to neovim or silence warnings
plugin = pkgs.vimPlugins.none-ls-nvim;
plugin = null-ls-nvim;
conf = readFile ./lua/null-ls-nvim.lua;
dependencies = [
{
plugin = pkgs.vimUtils.buildVimPlugin {
pname = "none-ls-shellcheck.nvim";
version = lib.my.mkVersionInput inputs.none-ls-shellcheck-nvim;
src = inputs.none-ls-shellcheck-nvim;
};
}
{ plugin = which-key-nvim; }
{ plugin = plenary-nvim; }
];
}
{ plugin = pkgs.vimPlugins.lsp_lines-nvim; }
{ plugin = which-key-nvim; }
{ plugin = lsp_lines-nvim; }
{
plugin = pkgs.vimPlugins.inc-rename-nvim;
plugin = nvim-ufo;
conf = readFile ./lua/nvim-ufo.lua;
dependencies = [
{ plugin = promise-async; }
];
}
{
plugin = neodev-nvim;
conf = readFile ./lua/neodev-nvim.lua;
}
{
plugin = inc-rename-nvim;
opts = {
input_buffer_type = "dressing";
};
dependencies = [
{ plugin = pkgs.vimPlugins.dressing-nvim; }
{ plugin = dressing-nvim; }
];
}
{
plugin = pkgs.vimUtils.buildVimPlugin {
pname = "actions-preview-nvim";
version = lib.my.mkVersionInput inputs.actions-preview-nvim;
src = inputs.actions-preview-nvim;
};
}
{ plugin = actions-preview-nvim; }
];
}
{
plugin = pkgs.vimPlugins.vim-fugitive;
plugin = vim-fugitive;
cmd = [
"G"
"Git"
@ -143,16 +165,13 @@ in
"GDelete"
"GBrowse"
];
keys = [
{ key = "<leader>gg"; cmd = "<cmd>Gedit :<cr>"; desc = "Open Status"; }
];
}
{
plugin = pkgs.vimPlugins.vim-tmux-navigator;
plugin = vim-tmux-navigator;
event = [ "VeryLazy" ];
}
{
plugin = pkgs.vimPlugins.nvim-lastplace;
plugin = nvim-lastplace;
event = [ "BufReadPost" "BufNewFile" ];
opts = {
lastplace_ignore_buftype = [ "quickfix" "nofile" "help" ];
@ -161,73 +180,135 @@ in
};
}
{
plugin = pkgs.vimPlugins.telescope-nvim;
plugin = telescope-nvim;
cmd = [ "Telescope" ];
conf = builtins.readFile ./lua/telescope.lua;
keys = [
{ key = "<leader>ff"; cmd = "<cmd>Telescope find_files<cr>"; desc = "Find files"; }
{ key = "<leader>fb"; cmd = "<cmd>Telescope buffers<cr>"; desc = "Find buffers"; }
{ key = "<leader>fl"; cmd = "<cmd>Telescope current_buffer_fuzzy_find<cr>"; desc = "Search lines"; }
{
key = "<leader>fl";
cmd = "y<ESC>:Telescope current_buffer_fuzzy_find default_text=<c-r>0<CR>";
desc = "Search lines (selection)";
mode = [ "v" ];
}
{ key = "<leader>fg"; cmd = "<cmd>Telescope live_grep<cr>"; desc = "Live grep"; }
{
key = "<leader>fg";
cmd = "y<ESC>:Telescope live_grep default_text=<c-r>0<CR>";
desc = "Live grep (selection)";
mode = [ "v" ];
}
{ key = "<leader>fh"; cmd = "<cmd>Telescope help_tags<cr>"; desc = "Help tags"; }
{ key = "<leader>fr"; cmd = "<cmd>Telescope oldfiles<cr>"; desc = "Recent files"; }
];
dependencies = [
{ plugin = pkgs.vimPlugins.plenary-nvim; }
{ plugin = pkgs.vimPlugins.telescope-fzf-native-nvim; }
{ plugin = plenary-nvim; }
{ plugin = telescope-fzf-native-nvim; }
];
}
{
plugin = pkgs.vimPlugins.vim-startuptime;
plugin = vim-startuptime;
cmd = [ "StartupTime" ];
conf = readFile ./lua/vim-startuptime.lua;
}
{
plugin = pkgs.vimPlugins.typst-vim;
plugin = typst-vim;
ft = [ "typst" "typ" ];
}
{
plugin = pkgs.vimPlugins.comment-nvim;
plugin = comment-nvim;
event = [ "BufReadPost" "BufNewFile" ];
opts = { };
}
{
plugin = pkgs.vimPlugins.nvim-surround;
event = [ "BufReadPost" "BufNewFile" ];
opts = { };
}
{
plugin = pkgs.vimPlugins.conform-nvim;
keys = [
{ key = "="; cmd = "<cmd>lua require('conform').format()<cr>"; desc = "format buffer"; mode = [ "n" "v" ]; }
plugin = telekasten-nvim;
dependencies = [
{ plugin = telescope-nvim; }
{ plugin = which-key-nvim; }
{
plugin = markdown-preview-nvim;
ft = [ "md" ];
}
];
cmd = [ "ConformInfo" "Format" ];
conf = readFile ./lua/conform.lua;
cmd = [ "Telekasten" ];
keys = [
{ key = "<leader>z"; cmd = "<cmd>Telekasten<cr>"; desc = "zettelkasten"; }
];
conf = builtins.readFile ./lua/zettelkasten-nvim.lua;
}
{ plugin = pkgs.vimPlugins.plantuml-syntax; }
{
plugin = pkgs.vimPlugins.vimtex;
lazy = false;
plugin = nvim-surround;
event = [ "BufReadPost" "BufNewFile" ];
opts = { };
}
{
plugin = zen-mode-nvim;
keys = [
{ key = "<leader>tz"; cmd = "<cmd>ZenMode<cr>"; desc = "Zen mode"; }
];
conf = /* lua */ ''
vim.g.vimtex_view_method = "zathura"
vim.g.vimtex_mappings_disable = vim.fn.executable("texlab") == 1 and { ["n"] = { "K" } } or {} -- disable `K` as it conflicts with LSP hover if texlab is in path
vim.g.vimtex_quickfix_method = vim.fn.executable("pplatex") == 1 and "pplatex" or "latexlog"
require("zen-mode").setup({
plugins = {
tmux = {
enabled = true,
},
},
})
'';
keys = [
{ key = "<localleader>l"; cmd = ""; desc = "+vimtex"; }
dependencies = [
{
plugin = twilight-nvim;
conf = /* lua */ ''
require("twilight").setup({
context = 20,
expand = { -- for treesitter, we we always try to expand to the top-most ancestor with these types
"function",
"function_definition",
"if_statement",
"method",
"method_definition",
"table",
},
})
'';
}
];
}
{
plugin = refactoring-nvim;
keys = [
{ key = "<leader>re"; cmd = ": Refactor eextract "; desc = "Extract"; mode = [ "x" ]; }
{ key = "<leader>rf"; cmd = ": Refactor extract_to_file "; desc = "Extract to file"; mode = [ "x" ]; }
{ key = "<leader>rv"; cmd = ": Refactor extract_var "; desc = "Extract variable"; mode = [ "x" ]; }
{ key = "<leader>ri"; cmd = ": Refactor inline_var"; desc = "Inline variable"; mode = [ "n" "x" ]; }
{ key = "<leader>rI"; cmd = ": Refactor inline_func"; desc = "Inline function"; mode = [ "n" "x" ]; }
{ key = "<leader>rb"; cmd = ": Refactor extract_block"; desc = "Extract block"; mode = [ "n" ]; }
{ key = "<leader>rbf"; cmd = ": Refactor extract_block_to_file"; desc = "Extract block to file"; mode = [ "n" ]; }
];
dependencies = [
{ plugin = which-key-nvim; }
{ plugin = plenary-nvim; }
{ plugin = nvim-lspconfig; }
];
init = /* lua */ ''
require("which-key").register({
["<leader>r"] = {
name = "refactoring",
},
})
'';
opts = { };
}
{
plugin = harpoon;
keys = [
{ key = "<leader>ha"; cmd = "<cmd>lua require('harpoon.mark').add_file()<cr>"; desc = "Add file"; }
{ key = "<leader>hh"; cmd = "<cmd>lua require('harpoon.ui').toggle_quick_menu()<cr>"; desc = "Harpoon"; }
{ key = "<leader>h1"; cmd = "<cmd>lua require('harpoon.ui').nav_file(1)<cr>"; desc = "Harpoon file 1"; }
{ key = "<leader>h2"; cmd = "<cmd>lua require('harpoon.ui').nav_file(2)<cr>"; desc = "Harpoon file 2"; }
{ key = "<leader>h3"; cmd = "<cmd>lua require('harpoon.ui').nav_file(3)<cr>"; desc = "Harpoon file 3"; }
{ key = "<leader>h4"; cmd = "<cmd>lua require('harpoon.ui').nav_file(4)<cr>"; desc = "Harpoon file 4"; }
];
opts = { };
}
{
plugin = nvim-puppeteer;
lazy = false; # NOTE: plugin lazy-loads itself.
}
{
# TODO: replace formatter-nvim with this as well
plugin = guard-nvim;
lazy = false;
conf = readFile ./lua/guard.lua;
}
];
}

View File

@ -1,49 +0,0 @@
{ pkgs, lib, ... }:
with builtins;
{
config.home-manager.users.moritz.programs.neovim.lazy.plugins = with pkgs.vimPlugins; [
{
plugin = nvim-dap;
keys = [
{ key = "<leader>cb"; cmd = "<cmd>lua require('dap').toggle_breakpoint()<cr>"; desc = "Toggle breakpoint"; }
{ key = "<leader>cd"; cmd = "<cmd>lua require('dap').continue()<cr>"; desc = "Continue"; }
];
dependencies = [
{
plugin = nvim-dap-python;
ft = [ "python" ];
conf =
let
pythonWithDebugpy = pkgs.python3.withPackages (ps: with ps; [ debugpy ]);
in
/* lua */ ''
require("dap-python").setup("${lib.getExe pythonWithDebugpy}")
'';
}
{
plugin = nvim-dap-virtual-text;
opts = { };
}
{
plugin = nvim-dap-ui;
opts = { };
conf = /* lua */ ''
local dap = require("dap")
local dapui = require("dapui")
dapui.setup(opts)
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open({})
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close({})
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close({})
end
'';
}
];
}
];
}

View File

@ -1,47 +0,0 @@
local conform = require("conform")
local formatters_by_ft = {
["*"] = { "codespell", "trim_whitespace" },
elixir = { "mix" },
gleam = { "gleam" },
go = { "gofmt" },
json = { "jq" },
lua = { "stylua" },
nix = { { "nixpkgs_fmt", "alejandra" } },
python = { { "ruff_fix", "isort" }, { "ruff_format", "black" } },
rust = { "rustfmt" },
sh = { "shfmt" },
tex = { "latexindent" },
toml = { "taplo" },
yaml = { "yamlfix" },
}
conform.setup({
formatters_by_ft = formatters_by_ft,
formatters = {
gleam = {
command = "gleam",
args = { "format", "--stdin" },
stdin = true,
cwd = require("conform.util").root_file({ "gleam.toml" }),
},
},
})
vim.api.nvim_create_user_command("Format", function(opts)
conform.format({ formatters = opts.fargs })
end, {
nargs = "+",
complete = function()
local names = formatters_by_ft[vim.bo.filetype] or formatters_by_ft["_"] or {}
names = vim.list_extend(names, formatters_by_ft["*"] or {})
names = vim.tbl_flatten(names)
local formatters = vim.tbl_map(conform.get_formatter_info, names)
formatters = vim.tbl_filter(function(formatter)
return formatter.available
end, formatters)
return vim.tbl_map(function(formatter_info)
return formatter_info.name
end, formatters)
end,
})

View File

@ -0,0 +1,70 @@
-- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands
require("formatter").setup({
-- Enable or disable logging
logging = true,
-- Set the log level
log_level = vim.log.levels.WARN,
-- All formatter configurations are opt-in
filetype = {
go = {
require("formatter.filetypes.go").gofmt,
},
json = {
require("formatter.filetypes.json").jq,
},
lua = {
require("formatter.filetypes.lua").stylua,
},
nix = {
require("formatter.filetypes.nix").nixpkgs_fmt,
},
python = {
require("formatter.filetypes.python").black,
},
rust = {
require("formatter.filetypes.rust").rustfmt,
},
sh = {
require("formatter.filetypes.sh").shfmt,
},
toml = {
require("formatter.filetypes.toml").taplo,
},
yaml = {
require("formatter.filetypes.yaml").yamlfmt,
},
-- HACK to use specific formatters only when specified
alejandra = {
require("formatter.filetypes.nix").alejandra,
},
isort = {
require("formatter.filetypes.python").isort,
},
-- Use the special "*" filetype for defining formatter configurations on
-- any filetype
["*"] = {
-- "formatter.filetypes.any" defines default configurations for any
-- filetype
require("formatter.filetypes.any").remove_trailing_whitespace,
},
},
})
vim.api.nvim_create_user_command("Fmt", function(opts)
local params = vim.split(opts.args, "%s+", { trimempty = true })
local filetype = vim.bo.filetype
vim.cmd("set filetype=" .. params[1]) -- fake filetype
vim.cmd(":Format")
vim.cmd("set filetype=" .. filetype) -- restore original filetype
end, {
nargs = 1,
complete = function()
local languages = {
nix = { "alejandra" },
python = { "isort" },
}
return languages[vim.bo.filetype] or {}
end,
})

View File

@ -1,13 +1,15 @@
require("gitsigns").setup()
require("which-key").add({
{ "<leader>gP", "<cmd>Gitsigns preview_hunk<cr>", desc = "Preview hunk (float)" },
{ "<leader>gR", "<cmd>Gitsigns reset_buffer<cr>", desc = "Reset buffer" },
{ "<leader>gS", "<cmd>Gitsigns stage_buffer<cr>", desc = "Stage buffer" },
{ "<leader>gp", "<cmd>Gitsigns preview_hunk_inline<cr>", desc = "Preview hunk (inline)" },
{ "<leader>gu", "<cmd>Gitsigns undo_stage_hunk<cr>", desc = "Undo stage hunk" },
{ "[h", "<cmd>Gitsigns prev_hunk<cr>", desc = "Previous hunk" },
{ "]h", "<cmd>Gitsigns next_hunk<cr>", desc = "Next hunk" },
{ "<leader>gr", "<cmd>Gitsigns reset_hunk<cr>", desc = "Reset hunk", mode = { "n", "v" } },
{ "<leader>gs", "<cmd>Gitsigns stage_hunk<cr>", desc = "Stage hunk", mode = { "n", "v" } },
{ "ih", ":<C-U>Gitsigns select_hunk<cr>", desc = "gitsigns hunk", mode = { "o", "x" } },
require("which-key").register({
["[h"] = { "<cmd>Gitsigns prev_hunk<cr>", "Previous hunk" },
["]h"] = { "<cmd>Gitsigns next_hunk<cr>", "Next hunk" },
["<leader>g"] = {
s = { "<cmd>Gitsigns stage_hunk<cr>", "Stage hunk", mode = { "n", "v" } },
r = { "<cmd>Gitsigns reset_hunk<cr>", "Reset hunk", mode = { "n", "v" } },
S = { "<cmd>Gitsigns stage_buffer<cr>", "Stage buffer" },
R = { "<cmd>Gitsigns reset_buffer<cr>", "Reset buffer" },
u = { "<cmd>Gitsigns undo_stage_hunk<cr>", "Undo stage hunk" },
p = { "<cmd>Gitsigns preview_hunk_inline<cr>", "Preview hunk (inline)" },
P = { "<cmd>Gitsigns preview_hunk<cr>", "Preview hunk (float)" },
},
["ih"] = { ":<C-U>Gitsigns select_hunk<cr>", "gitsigns hunk", mode = { "o", "x" } },
})

View File

@ -1,25 +0,0 @@
local ls = require("luasnip")
local types = require("luasnip.util.types")
-- Every unspecified option will be set to the default.
ls.setup({
history = true,
-- Update more often, :h events for more info.
update_events = "TextChanged,TextChangedI",
-- Snippets aren't automatically removed if their text is deleted.
-- `delete_check_events` determines on which events (:h events) a check for
-- deleted snippets is performed.
-- This can be especially useful when `history` is enabled.
delete_check_events = "TextChanged",
ext_opts = {
[types.choiceNode] = {
active = {
virt_text = { { "<--", "Error" } },
},
},
},
ft_func = require("luasnip.extras.filetype_functions").from_pos_or_filetype,
})
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" })

View File

@ -1 +1,60 @@
require("mini.align").setup()
require("mini.move").setup()
require("mini.starter").setup()
require("mini.statusline").setup({
content = {
active = function()
local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 })
local git = MiniStatusline.section_git({ trunc_width = 75 })
local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 })
local filename = MiniStatusline.section_filename({ trunc_width = 140 })
local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 })
local location = MiniStatusline.section_location({ trunc_width = 75 })
local mode_hl_inverse = mode_hl .. "Inverse"
-- Usage of `MiniStatusline.combine_groups()` ensures highlighting and
-- correct padding with spaces between groups (accounts for 'missing'
-- sections, etc.)
return MiniStatusline.combine_groups({
{ hl = mode_hl_inverse, strings = {} },
"",
{ hl = mode_hl, strings = { mode } },
{ hl = "MiniStatuslineDevinfo", strings = { git, diagnostics } },
"%<", -- Mark general truncate point
{ hl = "MiniStatuslineFilename", strings = { filename } },
"%=", -- End left alignment
{ hl = "MiniStatuslineFileinfo", strings = { fileinfo } },
{ hl = mode_hl, strings = { location } },
{ hl = mode_hl_inverse, strings = {} },
"",
})
end,
},
})
local MiniStatuslineModes = {
"MiniStatuslineModeInsert",
"MiniStatuslineModeNormal",
"MiniStatuslineModeReplace",
"MiniStatuslineModeVisual",
"MiniStatuslineModeCommand",
"MiniStatuslineModeOther",
}
for _, mode_hl in ipairs(MiniStatuslineModes) do
local hl_table = vim.api.nvim_get_hl(0, { name = mode_hl })
local fg = hl_table.fg
hl_table.fg = hl_table.bg
hl_table.bg = fg
vim.api.nvim_set_hl(0, mode_hl .. "Inverse", hl_table)
end
local animate = require("mini.animate")
local animation = {
timing = animate.gen_timing.quadratic({ duration = 100, unit = "total" }),
}
animate.setup({
cursor = animation,
scroll = { enable = false },
resize = animation,
open = animation,
close = animation,
})

View File

@ -1,7 +0,0 @@
require("neotest").setup({
adapters = {
require("neotest-python")({
dap = { justMyCode = false },
}),
},
})

View File

@ -3,16 +3,29 @@ local null_ls = require("null-ls")
null_ls.setup({
sources = {
-- Code actions
require("none-ls-shellcheck.code_actions"),
null_ls.builtins.code_actions.shellcheck,
null_ls.builtins.code_actions.statix,
-- Completion
null_ls.builtins.completion.spell,
-- Diagnostics
null_ls.builtins.diagnostics.checkmake,
null_ls.builtins.diagnostics.deadnix,
null_ls.builtins.diagnostics.dotenv_linter,
null_ls.builtins.diagnostics.fish,
require("none-ls-shellcheck.diagnostics"),
null_ls.builtins.diagnostics.shellcheck,
null_ls.builtins.diagnostics.statix,
null_ls.builtins.diagnostics.trail_space,
null_ls.builtins.diagnostics.yamllint,
},
})
-- disable (c)spell initially
null_ls.disable("spell")
-- make sources toggle able
require("which-key").register({
n = {
name = "null-ls",
s = {
function()
null_ls.toggle("spell")
end,
"spell",
},
},
}, { prefix = "<leader>t" })

View File

@ -2,6 +2,14 @@ local cmp = require("cmp")
local luasnip = require("luasnip")
require("luasnip.loaders.from_vscode").lazy_load()
local has_words_before = function()
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then
return false
end
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_text(0, line - 1, 0, line - 1, col, {})[1]:match("^%s*$") == nil
end
cmp.setup({
formatting = {
format = require("lspkind").cmp_format({
@ -9,7 +17,7 @@ cmp.setup({
maxwidth = 50, -- prevent the popup from showing more than provided characters
ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead
symbol_map = {
-- Copilot = "",
Codeium = "",
},
}),
},
@ -23,55 +31,34 @@ cmp.setup({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<S-CR>"] = cmp.mapping.abort(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
if cmp.visible() and has_words_before() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
["<C-n>"] = cmp.mapping(function(fallback)
if luasnip.choice_active() then
luasnip.change_choice(1)
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, { "i", "s" }),
["<C-p>"] = cmp.mapping(function(fallback)
if luasnip.choice_active() then
luasnip.change_choice(-1)
elseif luasnip.locally_jumpable(-1) then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sources = cmp.config.sources({
{ priority = 1, name = "async_path" },
{ priority = 1, name = "buffer" },
{ priority = 1, name = "spell" },
{ priority = 2, name = "nvim_lsp" },
-- { priority = 3, name = "copilot" },
{ priority = 3, name = "nvim_lsp_signature_help" },
{ priority = 4, name = "luasnip" },
{ priority = 4, name = "vimtex" },
}),
sources = {
{ name = "async_path", priority = 1 },
{ name = "buffer", priority = 1 },
{ name = "luasnip", priority = 2 },
{ name = "codeium", priority = 3 },
{ name = "nvim_lsp", priority = 3 },
},
})
-- Set configuration for specific filetype.
@ -133,97 +120,3 @@ cmp.event:on(
},
})
)
local pickers = require("telescope.pickers")
local finders = require("telescope.finders")
local conf = require("telescope.config").values
local actions = require("telescope.actions")
local action_state = require("telescope.actions.state")
local all_sources = vim.deepcopy(cmp.get_config().sources)
local find = function(sources, name)
for k, source in ipairs(sources) do
if source.name == name then
return k
end
end
return nil
end
local is_active = function(name)
local active_sources = cmp.get_config().sources
local index = find(active_sources, name)
return index ~= nil
end
local enable_source = function(name, force)
if force or not is_active(name) then
local source_index = find(all_sources, name)
if source_index ~= nil then
local active_sources = cmp.get_config().sources
local source = all_sources[source_index]
table.insert(active_sources, 1, source)
cmp.setup({ sources = active_sources })
end
end
end
local disable_source = function(identifier)
if type(identifier) == "string" then
identifier = find(all_sources, identifier)
end
local active_sources = cmp.get_config().sources
table.remove(active_sources, identifier)
end
local toggle_sources = function(name)
local active_sources = cmp.get_config().sources
local index = find(active_sources, name)
if index ~= nil then
disable_source(index)
else
enable_source(name, true)
end
end
-- our picker function: sources
local sources_picker = function(opts)
opts = opts or {}
pickers
.new(opts, {
prompt_title = "sources",
finder = finders.new_table({
results = vim.tbl_map(function(source)
return source.name
end, all_sources),
entry_maker = function(entry)
return {
value = entry,
display = function(tbl)
local name = tbl["ordinal"]
local active = is_active(name)
return string.format("%s %s", name, active and "" or "")
end,
ordinal = entry,
}
end,
}),
sorter = conf.generic_sorter(opts),
attach_mappings = function(prompt_bufnr, _)
actions.select_default:replace(function()
actions.close(prompt_bufnr)
local selection = action_state.get_selected_entry()
toggle_sources(selection["value"])
end)
return true
end,
})
:find()
end
-- autocommand for sources_picker
vim.api.nvim_create_user_command("CmpToggle", sources_picker, {})
-- disable sources by default
-- disable_source("codeium")

View File

@ -21,89 +21,98 @@ capabilities.didChangeWatchedFiles = {
local lspconfig = require("lspconfig")
local on_attach_def = function(client, bufnr)
require("which-key").add({
{ "<leader>c", buffer = bufnr, group = "code" },
{
"<leader>cr",
require("which-key").register({
K = {
function()
return ":IncRename " .. vim.fn.expand("<cword>")
end,
buffer = bufnr,
desc = "Rename",
expr = true,
replace_keycodes = false,
},
{
"<leader>ti",
function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
end,
buffer = bufnr,
desc = "LSP inlay hints",
},
{
"<leader>tl",
function()
lsp_lines.toggle()
if vim.diagnostic.is_disabled() then
vim.diagnostic.enable()
else
vim.diagnostic.disable()
local winid = require("ufo").peekFoldedLinesUnderCursor()
if not winid then
vim.lsp.buf.hover()
end
end,
buffer = bufnr,
desc = "LSP lines",
"Hover",
},
{ "K", vim.lsp.buf.hover, buffer = bufnr, desc = "Hover" },
{ "[d", vim.diagnostic.goto_prev, buffer = bufnr, desc = "Previous diagnostic" },
{ "]d", vim.diagnostic.goto_next, buffer = bufnr, desc = "Next diagnostic" },
{ "gD", vim.lsp.buf.declaration, buffer = bufnr, desc = "Goto declaration" },
{ "gI", "<cmd>Telescope lsp_implementations<cr>", buffer = bufnr, desc = "Goto implementation" },
{ "gK", vim.lsp.buf.signature_help, buffer = bufnr, desc = "Signature help" },
{
"gd",
function()
require("telescope.builtin").lsp_definitions({ reuse_win = true })
end,
buffer = bufnr,
desc = "Goto definition",
["<leader>"] = {
l = {
name = "lsp",
d = { vim.diagnostic.open_float, "Open diagnostic window" },
c = { require("actions-preview").code_actions, "Code action", mode = { "v", "n" } },
r = {
function()
return ":IncRename " .. vim.fn.expand("<cword>")
end,
"Rename",
expr = true,
},
f = {
function()
vim.lsp.buf.format({ async = true })
end,
"Format (lsp)",
mode = { "n", "v" },
},
},
t = {
l = {
function()
lsp_lines.toggle()
if vim.diagnostic.is_disabled() then
vim.diagnostic.enable()
else
vim.diagnostic.disable()
end
end,
"LSP lines",
},
i = {
function()
vim.lsp.inlay_hint(bufnr, nil)
end,
"LSP inlay hints",
},
},
},
{ "gr", "<cmd>Telescope lsp_references<cr>", buffer = bufnr, desc = "Goto references" },
{
"gt",
g = {
d = {
function()
require("telescope.builtin").lsp_definitions({ reuse_win = true })
end,
"Goto definition",
},
t = {
function()
require("telescope.builtin").lsp_type_definitions({ reuse_win = true })
end,
"Goto type defininition",
},
r = { "<cmd>Telescope lsp_references<cr>", "Goto references" },
D = { vim.lsp.buf.declaration, "Goto declaration" },
I = { "<cmd>Telescope lsp_implementations<cr>", "Goto implementation" },
K = { vim.lsp.buf.signature_help, "Signature help" },
},
["["] = {
d = { vim.diagnostic.goto_prev, "Previous diagnostic" },
},
["]"] = {
d = { vim.diagnostic.goto_next, "Next diagnostic" },
},
}, { buffer = bufnr, silent = true })
function()
require("telescope.builtin").lsp_type_definitions({ reuse_win = true })
end,
buffer = bufnr,
desc = "Goto type definition",
},
{
"<leader>cc",
require("actions-preview").code_actions,
buffer = bufnr,
desc = "Code action",
mode = { "n", "v" },
},
{
"<leader>cf",
function()
vim.lsp.buf.format({ async = true })
end,
buffer = bufnr,
desc = "Format (lsp)",
mode = { "n", "v" },
},
})
if client.server_capabilities.inlayHintProvider then
local slow_lsp_servers = {
"rust_analyzer",
}
local timeout = vim.tbl_contains(slow_lsp_servers, client.name, {}) and 500 or 0
vim.defer_fn(function()
vim.lsp.inlay_hint.enable(true, { bufnr })
vim.lsp.inlay_hint(bufnr, true)
end, timeout)
end
require("lsp_signature").on_attach({
bind = true, -- This is mandatory, otherwise border config won't get registered.
handler_opts = {
border = "rounded",
},
}, bufnr)
end
local lspconfig_default_options = {
@ -125,64 +134,16 @@ end
local servers = {
"bashls",
"gleam",
"gopls",
"nixd",
"pylsp",
"ruff",
"templ",
"ruff_lsp",
"typst_lsp",
"gopls",
}
for _, lsp in ipairs(servers) do
lspconfig_setup(lsp, {})
end
lspconfig_setup("elixirls", {
cmd = { "elixir-ls" },
})
lspconfig_setup("nil_ls", {
settings = {
flake = {
autoArchive = true,
autoEvalInputs = true,
nixpkgsInputName = "nixpkgs",
},
},
})
lspconfig_setup("nixd", {
settings = {
nixd = {
nixpkgs = {
expr = "import <nixpkgs> { }",
},
options = {
nixos = {
expr = '(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.nixos-desktop.options',
},
["flake-parts"] = {
expr = '(builtins.getFlake ("git+file://" + toString ./.)).debug.options',
},
["flake-parts2"] = {
expr = '(builtins.getFlake ("git+file://" + toString ./.)).currentSystem.options',
},
},
},
},
})
-- Add templ filetype
vim.filetype.add({ extension = { templ = "templ" } })
lspconfig_setup("htmx", {
filetypes = { "html", "templ" },
})
lspconfig_setup("tailwindcss", {
filetypes = { "templ", "astro", "javascript", "typescript", "react" },
init_options = { userLanguages = { templ = "html" } },
})
lspconfig_setup("rust_analyzer", {
settings = {
["rust-analyzer"] = {

View File

@ -1 +1,10 @@
require("nvim-treesitter.configs").setup()
require("nvim-treesitter.configs").setup({
sync_install = false,
auto_install = false,
highlight = {
enable = true,
},
context_commentstring = {
enable = true,
},
})

View File

@ -0,0 +1,22 @@
vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]
local builtin = require("statuscol.builtin")
require("statuscol").setup({
segments = {
{
sign = { name = { ".*" }, auto = true },
click = "v:lua.ScSa",
},
{
text = { builtin.lnumfunc },
click = "v:lua.ScLa",
},
{
sign = { name = { "GitSigns" }, auto = true },
click = "v:lua.ScSa",
},
{
text = { builtin.foldfunc, "" },
click = "v:lua.ScFa",
},
},
})

View File

@ -2,50 +2,62 @@ vim.o.timeout = true
vim.o.timeoutlen = 500
-- Delete
require("which-key").add({
{ "<leader>d", group = "delete" },
{ "<leader>db", "<cmd>bd<cr>", desc = "Delete buffer" },
{ "<leader>dw", "<C-w>c", desc = "Delete window" },
})
require("which-key").register({
d = {
name = "delete",
b = { "<cmd>bd<cr>", "Delete buffer" },
w = { "<C-w>c", "Delete window" },
},
}, { prefix = "<leader>" })
-- buffer
require("which-key").add({
{ "[b", "<cmd>bprevious<cr>", desc = "Previous buffer" },
{ "]b", "<cmd>bnext<cr>", desc = "Next buffer" },
require("which-key").register({
["["] = {
b = { "<cmd>bprevious<cr>", "Previous buffer" },
},
["]"] = {
b = { "<cmd>bnext<cr>", "Next buffer" },
},
})
-- window
require("which-key").add({
{ "<leader>w", group = "window" },
{ "<leader>w-", "<C-w>s", desc = "Split window vertically" },
{ "<leader>ww", "<C-w>w", desc = "Switch window" },
{ "<leader>w|", "<C-w>v", desc = "Split window horizontally" },
})
require("which-key").register({
w = {
name = "window",
["|"] = { "<C-w>v", "Split window horizontally" },
["-"] = { "<C-w>s", "Split window vertically" },
w = { "<C-w>w", "Switch window" },
},
}, { prefix = "<leader>" })
-- better descriptions for navigation
require("which-key").add({
{ "<leader>c", group = "code" },
{ "<leader>f", group = "file/find" },
{ "<leader>g", group = "git" },
{ "<leader>s", group = "search" },
{ "<leader>t", group = "toggle" },
{ "[", group = "prev" },
{ "]", group = "next" },
{ "g", group = "goto" },
require("which-key").register({
["<leader>"] = {
f = { name = "file/find" },
g = { name = "git" },
l = { name = "lsp" },
o = { name = "org" },
s = { name = "search" },
t = { name = "toggle" },
x = { name = "diagnostics/quickfix" },
},
["["] = { name = "prev" },
["]"] = { name = "next" },
g = { name = "goto" },
})
-- Clear search with <esc>
require("which-key").add({
{ "<esc>", "<cmd>noh<cr><esc>", desc = "Escape and clear hlsearch", mode = { "i", "n" } },
require("which-key").register({
["<esc>"] = { "<cmd>noh<cr><esc>", "Escape and clear hlsearch", mode = { "n", "i" } },
})
-- better indenting
require("which-key").add({
{ "<", "<gv", desc = "Shift left", mode = "v" },
{ ">", ">gv", desc = "Shift right", mode = "v" },
})
require("which-key").register({
["<"] = { "<gv", "Shift left" },
[">"] = { ">gv", "Shift right" },
}, { mode = "v" })
-- better yank in visual mode
require("which-key").add({
{ "y", "ygv<esc>", desc = "Yank", mode = "v" },
})
require("which-key").register({
y = { "ygv<esc>", "Yank" },
}, { mode = "v" })

View File

@ -1,6 +1,6 @@
local telekasten = require("telekasten")
telekasten.setup({
home = vim.fn.expand("~/Documents/Nextcloud/Notes/zettelkasten"),
home = vim.fn.expand("~/Nextcloud/Notes/zettelkasten"),
auto_set_filetype = false,
image_subdir = "assets",
})

View File

@ -1,46 +0,0 @@
local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local isn = ls.indent_snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local events = require("luasnip.util.events")
local ai = require("luasnip.nodes.absolute_indexer")
local extras = require("luasnip.extras")
local l = extras.lambda
local rep = extras.rep
local p = extras.partial
local m = extras.match
local n = extras.nonempty
local dl = extras.dynamic_lambda
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local conds = require("luasnip.extras.expand_conditions")
local postfix = require("luasnip.extras.postfix").postfix
local types = require("luasnip.util.types")
local parse = require("luasnip.util.parser").parse_snippet
local ms = ls.multi_snippet
local k = require("luasnip.nodes.key_indexer").new_key
local def_template = [[
def {fname}({args}) do
{final}
end
]]
local def = s(
"def",
fmt(def_template, {
fname = i(1, "fname"),
args = i(2),
final = i(3),
}, { priority = 1001 })
)
return {
def,
}

View File

@ -1,120 +0,0 @@
local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local isn = ls.indent_snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local events = require("luasnip.util.events")
local ai = require("luasnip.nodes.absolute_indexer")
local extras = require("luasnip.extras")
local l = extras.lambda
local rep = extras.rep
local p = extras.partial
local m = extras.match
local n = extras.nonempty
local dl = extras.dynamic_lambda
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local conds = require("luasnip.extras.expand_conditions")
local postfix = require("luasnip.extras.postfix").postfix
local types = require("luasnip.util.types")
local parse = require("luasnip.util.parser").parse_snippet
local ms = ls.multi_snippet
local k = require("luasnip.nodes.key_indexer").new_key
local matches = require("luasnip.extras.postfix").matches
local case_template = [[
case {expression} {{
{pattern1} -> {result1}
{pattern2} -> {result2}{final}
}}
]]
local dot_case = postfix({ filetype = "gleam", trig = ".case", match_pattern = matches.line }, {
d(1, function(_, parent)
return sn(
1,
fmt(case_template, {
expression = t(parent.env.POSTFIX_MATCH),
pattern1 = i(1, "pattern"),
result1 = i(2, "todo"),
pattern2 = i(3, "_"),
result2 = i(4, "todo"),
final = i(0),
})
)
end),
})
local case = s(
{ filetype = "gleam", trig = "case" },
fmt(case_template, {
expression = i(1),
pattern1 = i(2),
result1 = i(3, "todo"),
pattern2 = i(4, "_"),
result2 = i(5, "todo"),
final = i(0),
})
)
local fn_template = [[
fn {name}({args}) -> {rtype} {{
{body}
}}
]]
local fn = s(
{ filetype = "gleam", trig = "fn" },
fmt(fn_template, {
name = i(1),
args = i(2),
rtype = i(3),
body = i(0),
})
)
local pfn = s(
{ filetype = "gleam", trig = "pfn" },
fmt("pub " .. fn_template, {
name = i(1),
args = i(2),
rtype = i(3),
body = i(0),
})
)
local type_template = [[
type {name} {{
{body}
}}
]]
local type = s(
{ filetype = "gleam", trig = "type" },
fmt(type_template, {
name = i(1),
body = i(0),
})
)
local ptype = s(
{ filetype = "gleam", trig = "ptype" },
fmt("pub " .. type_template, {
name = i(1),
body = i(0),
})
)
return {
case,
dot_case,
fn,
pfn,
type,
ptype,
}

View File

@ -1,138 +0,0 @@
local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local isn = ls.indent_snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local events = require("luasnip.util.events")
local ai = require("luasnip.nodes.absolute_indexer")
local extras = require("luasnip.extras")
local l = extras.lambda
local rep = extras.rep
local p = extras.partial
local m = extras.match
local n = extras.nonempty
local dl = extras.dynamic_lambda
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local conds = require("luasnip.extras.expand_conditions")
local postfix = require("luasnip.extras.postfix").postfix
local types = require("luasnip.util.types")
local parse = require("luasnip.util.parser").parse_snippet
local ms = ls.multi_snippet
local k = require("luasnip.nodes.key_indexer").new_key
local pe = s(
"pe",
fmt("<%= {final} %>", {
final = i(1),
}, { priority = 1001 })
)
local ln = s(
"ln",
fmt(
[[
<.link navigate={{~p"{path}"}}">{final}</.link>
]],
{ path = i(1, "/"), final = i(2) },
{ priority = 1001 }
)
)
local lp = s(
"lp",
fmt(
[[
<.link patch={{~p"{path}"}}">{final}</.link>
]],
{ path = i(1, "/"), final = i(2) },
{ priority = 1001 }
)
)
local if_ = s(
"if",
fmt("<%= if {condition} do %>{final}<% end %>", { condition = i(1, "condition"), final = i(2) }, { priority = 1001 })
)
local ife = s(
"ife",
fmt(
[[
<%= if {condition} do %>
{when}
<% else %>
{final}
<% end %>"
]],
{ condition = i(1, "condition"), when = i(2), final = i(3) },
{ priority = 1001 }
)
)
local for_ = s(
"for",
fmt(
[[
<%= for {item} <- {list} do %>
{final}
<% end %>
]],
{ item = i(1, "item"), list = i(2, "items"), final = i(3) },
{ priority = 1001 }
)
)
local lc =
s("lc", fmt("<.live_component module={{{module}}} id={{{id}}} />", { module = i(1), id = i(2) }, { priority = 1001 }))
local slot = s(
"slot",
fmt("<:slot>{final}</:slot>", {
final = i(1),
}, { priority = 1001 })
)
local socketp = s(
"socketp",
fmt(
[[
socket =
socket
|> {final}
]],
{ final = i(1) },
{ priority = 1001 }
)
)
local fl = s(
"fl",
fmt(
[[
<{elem} :for={{{item} <- {list}}} class="{class}">
{final}
</{elem}>
]],
{ elem = i(1, "div"), item = i(2, "item"), list = i(3, "items"), class = i(4), final = i(5) },
{ priority = 1001, repeat_duplicates = true }
)
)
return {
pe,
ln,
lp,
if_,
ife,
for_,
lc,
slot,
socketp,
fl,
}

View File

@ -1,242 +0,0 @@
local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local isn = ls.indent_snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local events = require("luasnip.util.events")
local ai = require("luasnip.nodes.absolute_indexer")
local extras = require("luasnip.extras")
local l = extras.lambda
local rep = extras.rep
local p = extras.partial
local m = extras.match
local n = extras.nonempty
local dl = extras.dynamic_lambda
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local conds = require("luasnip.extras.expand_conditions")
local postfix = require("luasnip.extras.postfix").postfix
local types = require("luasnip.util.types")
local parse = require("luasnip.util.parser").parse_snippet
local ms = ls.multi_snippet
local k = require("luasnip.nodes.key_indexer").new_key
local arg_template = [[
{arg}: {type}
]]
local function pyarg()
return sn(
nil,
fmt(arg_template, {
arg = i(1, "arg"),
type = i(2, "Any"),
})
)
end
local function pyargs(_, _, _, user_args)
local choices = {
sn(nil, i(1)),
sn(nil, {
not user_args and t(", ") or t(""),
d(1, pyarg),
d(2, pyargs, { user_args = { false } }),
}),
}
-- switch order for first call
if user_args then
local fst, snd = unpack(choices)
choices = { snd, fst }
end
return sn(nil, c(1, choices))
end
local def_template = [[
def {fname}({args}) -> {rtype}:
"""
{docs}
"""
{final}
]]
local def = s(
"def",
fmt(def_template, {
fname = i(1, "fname"),
args = d(2, pyargs, nil, { user_args = { true } }),
rtype = i(3, "None"),
docs = i(4, "Documentation"),
final = i(5, "pass"),
}, { priority = 1001 })
)
local defs_template = [[
def {mname}(self, {args}) -> {rtype}:
"""
{docs}
"""
{final}
]]
local defs = s(
"defs",
fmt(defs_template, {
mname = i(1, "mname"),
args = d(2, pyargs, nil, { user_args = { true } }),
rtype = i(3, "None"),
docs = i(4, "Documentation"),
final = i(5, "pass"),
}, { priority = 1001 })
)
local enum_template = [[
for {i}, {value} in enumerate({iter}):
{final}
]]
local dot_enum = postfix(".enum", {
d(1, function(_, parent)
return sn(
1,
fmt(enum_template, {
i = i(1, "i"),
value = i(2, "value"),
iter = t(parent.env.POSTFIX_MATCH),
final = i(3, "pass"),
})
)
end),
})
local enum = s(
"enum",
fmt(enum_template, {
i = i(1, "i"),
value = i(2, "value"),
iter = i(3, "iter"),
final = i(4, "pass"),
})
)
local for_template = [[
for {item} in {iter}:
{final}
]]
local dot_for = postfix(".for", {
d(1, function(_, parent)
return sn(
1,
fmt(for_template, {
item = i(1, "item"),
iter = t(parent.env.POSTFIX_MATCH),
final = i(2, "pass"),
})
)
end),
})
local items_template = [[
for {key}, {value} in {iter}:
{final}
]]
local dot_items = postfix(".items", {
d(1, function(_, parent)
return sn(
1,
fmt(items_template, {
key = i(1, "key"),
value = i(2, "value"),
iter = t(parent.env.POSTFIX_MATCH),
final = i(3, "pass"),
})
)
end),
})
local try_template = [[
try:
{raises}
except {exception} as {ename}:
{final}
]]
local dot_try = postfix(".try", {
d(1, function(_, parent)
return sn(
1,
fmt(try_template, {
raises = t(parent.env.POSTFIX_MATCH),
exception = i(1, "Exception"),
ename = i(2, "e"),
final = i(3, "pass"),
})
)
end),
})
local parr = s(
"parr",
fmt(
[[
:param {name}: {description}
:type {name}: {type}
]],
{
name = i(1, "name"),
description = i(2, "description"),
type = i(3, "type"),
},
{
repeat_duplicates = true,
}
)
)
local retr = s(
"retr",
fmt(
[[
:return: {description}
:rtype: {rtype}
]],
{
description = i(1, "description"),
rtype = i(2, "rtype"),
}
)
)
local raisr = s(
"raisr",
fmt(
[[
:raises {exception}: {description}
]],
{
exception = i(1, "Exception"),
description = i(2, "description"),
}
)
)
return {
def,
defs,
dot_enum,
dot_for,
dot_items,
dot_try,
enum,
parr,
retr,
raisr,
}

View File

@ -1,68 +1,42 @@
{ pkgs, inputs, lib, ... }:
{ lib, pkgs, ... }:
with builtins;
{
config.home-manager.users.moritz.programs.neovim.lazy.plugins = [
(
let
nvim-treesitter = pkgs.vimPlugins.nvim-treesitter;
parserDir = pkgs.symlinkJoin {
name = "tresitter-grammars-all";
paths = nvim-treesitter.withAllGrammars.dependencies;
};
in
{
plugin = nvim-treesitter;
event = [ "BufReadPost" "BufNewFile" ];
opts = {
sync_install = false;
auto_install = false;
highlight = {
enable = true;
disable = [ "latex" ];
config.home-manager.users.moritz.programs.neovim.lazy.plugins = with pkgs.vimPlugins; [
{
plugin = nvim-treesitter;
event = [ "BufReadPost" "BufNewFile" ];
conf =
let
parserDir = pkgs.symlinkJoin {
name = "tresitter-grammars-all";
paths = lib.attrValues (lib.filterAttrs (_: builtins.isAttrs) nvim-treesitter-parsers);
};
textobjects =
{
select =
{
enable = true;
# Automatically jump forward to textobj, similar to targets.vim
lookahead = false;
keymaps = {
# You can use the capture groups defined in textobjects.scm
"af" = {
query = "@function.outer";
desc = "Select outer part of a function region";
};
"if" = {
query = "@function.inner";
desc = "Select inner part of a function region";
};
"ac" = {
query = "@class.outer";
desc = "Select outer part of a class region";
};
"ic" = {
query = "@class.inner";
desc = "Select inner part of a class region";
};
};
};
};
};
conf =
/* lua */ ''
in
readFile ./lua/nvim-treesitter.lua + ''
vim.opt.runtimepath:append("${parserDir}")
local final_opts = vim.tbl_deep_extend("keep", opts, { parser_install_dir = "${parserDir}" })
require('nvim-treesitter.configs').setup(final_opts)
require'nvim-treesitter.configs'.setup {
parser_install_dir = "${parserDir}",
}
'';
priority = 100;
dependencies = [
{ plugin = pkgs.vimPlugins.nvim-treesitter-textobjects; }
{ plugin = pkgs.vimPlugins.nvim-ts-context-commentstring; opts = { }; }
];
}
)
dependencies = [
{ plugin = nvim-ts-context-commentstring; }
];
}
{
plugin = nvim-treesitter-textsubjects;
event = [ "BufReadPost" "BufNewFile" ];
conf = readFile ./lua/nvim-treesitter-textsubjects.lua;
}
{
plugin = nvim-treesitter-context;
event = [ "BufReadPost" "BufNewFile" ];
opts = { };
}
{
plugin = hmts-nvim;
ft = [ "nix" ];
}
];
}

View File

@ -1,84 +1,47 @@
{ pkgs, lib, inputs, ... }:
{ pkgs, ... }:
let
inherit (lib) readFile;
in
with builtins;
{
config.home-manager.users.moritz.programs.neovim.lazy.plugins = [
config.home-manager.users.moritz.programs.neovim.lazy.plugins = with pkgs.vimPlugins; [
{
plugin = pkgs.vimPlugins.which-key-nvim;
plugin = which-key-nvim;
lazy = false;
conf = readFile ./lua/which-key-nvim.lua;
}
{
plugin = pkgs.vimPlugins.catppuccin-nvim;
plugin = catppuccin-nvim;
conf = readFile ./lua/catppuccin-nvim.lua;
lazy = false;
priority = 99;
}
{
plugin = pkgs.vimPlugins.todo-comments-nvim;
dependencies = [{ plugin = pkgs.vimPlugins.plenary-nvim; }];
plugin = todo-comments-nvim;
event = [ "BufReadPost" "BufNewFile" ];
dependencies = [{ plugin = plenary-nvim; }];
opts = { };
}
{
plugin = pkgs.vimPlugins.dressing-nvim;
plugin = statuscol-nvim;
event = [ "VeryLazy" ];
conf = readFile ./lua/statuscol-nvim.lua;
}
{
plugin = smartcolumn-nvim;
event = [ "BufReadPost" "BufNewFile" ];
opts = {
colorcolumn = "120";
disabled_filetypes = [ "help" "text" "markdown" "dashboard" ];
};
}
{
plugin = dressing-nvim;
event = [ "VeryLazy" ];
}
{
plugin = pkgs.vimPlugins.gitsigns-nvim;
plugin = gitsigns-nvim;
event = [ "BufReadPost" "BufNewFile" ];
conf = readFile ./lua/gitsigns-nvim.lua;
dependencies = [{ plugin = pkgs.vimPlugins.which-key-nvim; }];
}
{
plugin = pkgs.vimUtils.buildVimPlugin {
pname = "hawtkeys-nvim";
version = lib.my.mkVersionInput inputs.hawtkeys-nvim;
src = inputs.hawtkeys-nvim;
};
cmd = [ "Hawtkeys" "HawtkeysAll" "HawtkeysDupes" ];
opts = { };
dependencies = [
{ plugin = pkgs.vimPlugins.plenary-nvim; }
{ plugin = pkgs.vimPlugins.nvim-treesitter; }
];
}
{
plugin = pkgs.vimPlugins.zen-mode-nvim;
keys = [
{ key = "<leader>tz"; cmd = "<cmd>ZenMode<cr>"; desc = "Zen mode"; }
];
conf = /* lua */ ''
require("zen-mode").setup({
plugins = {
tmux = {
enabled = true,
},
},
})
'';
dependencies = [
{
plugin = pkgs.vimPlugins.twilight-nvim;
keys = [
{ key = "<leader>tZ"; cmd = "<cmd>Twilight<cr>"; desc = "Twilight mode"; }
];
conf = /* lua */ ''
require("twilight").setup({
context = 20,
expand = { -- for treesitter, we we always try to expand to the top-most ancestor with these types
"function",
"function_definition",
"if_statement",
"method",
"method_definition",
"table",
},
})
'';
}
];
dependencies = [{ plugin = which-key-nvim; }];
}
];
}

View File

@ -4,13 +4,11 @@
, ...
}:
with lib;
let
inherit (lib) range filterAttrs attrNames foldl' head tail mkOption mkEnableOption intersectLists genAttrs flip getAttr;
inherit (lib.types) listOf enum package;
cfg = config.my.programs.python;
pythonVersions = map (version: "3${toString version}") (range 8 13);
pythonVersions = map (version: "3${toString version}") (range 8 11);
enabledVersions = filterAttrs (_: value: value.enable) cfg.versions;
pythonPackages = version: attrNames pkgs."python${version}Packages";
@ -25,7 +23,7 @@ let
enable = mkEnableOption (toString version);
pythonPackages = mkOption {
default = [ ];
type = listOf (enum (pythonPackages version));
type = with types; listOf (enum (pythonPackages version));
};
};
in
@ -34,11 +32,15 @@ in
versions = genAttrs pythonVersions versionOpts;
defaultPackages = mkOption {
default = [ ];
type = listOf (enum commonPackages);
type = with types; listOf (enum commonPackages);
};
extraPackages = mkOption {
default = [ ];
type = listOf package;
default = with pkgs; [
poetry
ruff
python310Packages.python-lsp-server
];
type = with types; listOf package;
};
};

View File

@ -1,293 +0,0 @@
{ config
, lib
, pkgs
, ...
}:
let
inherit (lib) mkEnableOption mkIf mkOption types;
cfg = config.my.programs.river;
in
{
options.my.programs.river = {
enable = mkEnableOption "river";
keyboardLayouts = mkOption {
type = types.listOf types.str;
description = "list of keyboard layouts";
default = [ "us" "de" ];
};
nvidiaSupport = mkEnableOption "nvidiaSupport";
};
config = mkIf cfg.enable {
programs.river.enable = true;
my = {
programs = {
wallpaper.enable = true;
kitty.enable = true;
tofi.enable = true;
};
wallpapers.enable = true;
services = {
dunst.enable = true;
wallpaper = {
enable = true;
target = "river-session.target";
};
spotify-player.target = "river-session.target";
};
};
home-manager.users.moritz = {
home.packages = with pkgs; [
rivercarro
];
services.kanshi = {
enable = true;
systemdTarget = "river-session.target";
};
wayland.windowManager.river = {
enable = true;
settings = {
border-width = 2;
declare-mode = [
"locked"
"normal"
"passthrough"
];
map = {
normal = {
"Super Q" = "close";
"Super Return" = "spawn kitty";
"Super R" = ''spawn 'exec $(tofi-run --fuzzy-match=true)' '';
"Super W" = ''spawn "pkill -USR1 waybar"'';
"Super+Shift R" = "spawn ~/.config/river/init";
# Focus view
"Super J" = "focus-view next";
"Super K" = "focus-view previous";
# swap the focused view
"Super+Shift J" = "swap next";
"Super+Shift K" = "swap previous";
# focus output
"Super Period" = "focus-output next";
"Super Comma" = "focus-output previous";
# send to output
"Super+Shift Period" = "send-to-output next";
"Super+Shift Comma" = "send-to-output previous";
# bump in layout stack
"Super Z" = "zoom";
# lock screen
"Super+Alt L" = ''spawn "loginctl lock-session"'';
} //
# tags
(
let
numbers = lib.range 1 9;
toTag = num: "$((1 << (${toString num} - 1)))";
mkMappings = num:
let
numStr = toString num;
tag = toTag num;
in
[
# Super+Control+[1-9] to toggle focus of tag [0-8]
{ name = "Super ${numStr}"; value = "set-focused-tags ${tag}"; }
# Super+Shift+Control+[1-9] to toggle tag [0-8] of focused view
{ name = "Super+Shift ${numStr}"; value = "toggle-view-tags ${tag}"; }
];
mappings = lib.flatten (map mkMappings numbers);
in
lib.listToAttrs mappings
);
};
map-pointer = {
normal = {
"Super BTN_LEFT" = "move-view";
"Super BTN_RIGHT" = "resize-view";
"Super BTN_MIDDLE" = "toggle-float";
};
};
attach-mode = "bottom";
default-layout = "rivercarro";
focus-follows-cursor = "normal";
hide-cursor = {
timeout = "1500";
when-typing = "enabled";
};
set-cursor-warp = "on-focus-change";
keyboard-layout = "-options grp:win_space_toggle,caps:escape ${lib.concatStringsSep "," cfg.keyboardLayouts}";
};
extraConfig = /* bash */ ''
rivercarro_pid="$(pidof rivercarro)"
if [[ -z $rivercarro_pid ]]; then
rivercarro -inner-gaps 4 -outer-gaps 4 &
fi
'';
};
# add waybar as a status bar
programs.waybar = {
enable = true;
package = pkgs.waybar.overrideAttrs (old: {
patches = old.patches or [ ] ++ [
(pkgs.fetchpatch {
url = "https://gitlab.archlinux.org/archlinux/packaging/packages/waybar/-/raw/0306af03fcb6de6aee1e288f42b0bf1b223513bd/a544f4b2cdcf632f1a4424b89f6e3d85ef5aaa85.patch";
sha256 = "sha256-S/1oUj9Aj6BElNTsDY8CTcKtS1j7Gl54JFgCywH05pg=";
})
];
});
# start using systemd service
systemd = {
enable = true;
target = "river-session.target";
};
settings = {
mainBar = {
start_hidden = true;
layer = "top";
position = "top";
height = 20;
modules-left = [ "river/tags" ];
modules-center = [ "river/window" ];
modules-right = [ "network" "memory" "cpu" "battery" "clock" ];
};
};
style = lib.readFile ./style.css;
};
# lock screen after timeout
programs.swaylock = {
enable = true;
settings = {
color = "000000";
};
};
services.swayidle = {
enable = true;
events = [
{
event = "before-sleep";
command = "${lib.getExe pkgs.swaylock} -fF";
}
{
event = "lock";
command = "${lib.getExe pkgs.swaylock} -fF";
}
];
timeouts =
let
lockTimeout = 10;
in
[
{
timeout = lockTimeout * 60 - 10;
command = "${pkgs.libnotify}/bin/notify-send 'Locking screen!'";
}
{
timeout = lockTimeout * 60 + 10;
command = "${pkgs.systemd}/bin/loginctl lock-session";
}
];
systemdTarget = "river-session.target";
};
};
# 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
pamixer # pulse audio cli
playerctl # control media playback
slurp # region select for wayland (for screensharing)
wdisplays # manage monitors
wl-clipboard # clipboard tool for wayland
];
# additional environment variables
environment.sessionVariables =
{
XDG_CURRENT_DESKTOP = "river";
XDG_SESSION_TYPE = "wayland";
XDG_SESSION_DESKTOP = "river";
QT_AUTO_SCREEN_SCALE_FACTOR = "1";
QT_QPA_PLATFORM = "wayland;xcb";
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
QT_QPA_PLATFORMTHEME = "qt5ct";
_JAVA_AWT_WM_NONEREPARENTING = "1";
} // (lib.optionalAttrs cfg.nvidiaSupport
{
GBM_BACKEND = "nvidia-drm";
GDK_BACKEND = "wayland";
LIBVA_DRIVER_NAME = "nvidia";
MOZ_ENABLE_WAYLAND = "1";
WLR_DRM_DEVICES = "/dev/dri/card0";
WLR_DRM_NO_ATOMIC = "1";
WLR_NO_HARDWARE_CURSORS = "1";
XDG_CURRENT_DESKTOP = "river";
_GL_GSYNC_ALLOWED = "0";
__GLX_VENDOR_LIBRARY_NAME = "nvidia";
__GL_VRR_ALLOWED = "0";
});
services = {
dbus.enable = true;
# use pipewire (needed for screensharing)
pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
displayManager = {
autoLogin = {
enable = true;
user = "moritz";
};
defaultSession = "river";
};
xserver = {
enable = true;
displayManager.lightdm.enable = true;
};
};
security.rtkit.enable = true;
home-manager.users.moritz.systemd.user.services =
let
units = [ "waybar" ];
mkAfter = _: {
Unit = {
After = [ "river-session.target" ];
Wants = [ "river-session.target" ];
};
};
in
lib.genAttrs units mkAfter;
systemd.user.services =
let
units = [ "pipewire" "xdg-desktop-portal" "wireplumber" ];
mkAfter = _: {
after = [ "river-session.target" ];
wants = [ "river-session.target" ];
};
in
lib.genAttrs units mkAfter;
};
}

View File

@ -1,339 +0,0 @@
* {
/* `otf-font-awesome` is required to be installed for icons */
font-family: FontAwesome, Roboto, Helvetica, Arial, sans-serif;
font-size: 13px;
}
window#waybar {
background-color: rgba(43, 48, 59, 0.5);
border-bottom: 3px solid rgba(100, 114, 125, 0.5);
color: #ffffff;
transition-property: background-color;
transition-duration: .5s;
}
window#waybar.hidden {
opacity: 0.2;
}
/*
window#waybar.empty {
background-color: transparent;
}
window#waybar.solo {
background-color: #FFFFFF;
}
*/
window#waybar.termite {
background-color: #3F3F3F;
}
window#waybar.chromium {
background-color: #000000;
border: none;
}
button {
/* Use box-shadow instead of border so the text isn't offset */
box-shadow: inset 0 -3px transparent;
/* Avoid rounded borders under each button name */
border: none;
border-radius: 0;
}
/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */
button:hover {
background: inherit;
box-shadow: inset 0 -3px #ffffff;
}
/* you can set a style on hover for any module like this */
#pulseaudio:hover {
background-color: #a37800;
}
#workspaces button {
padding: 0 5px;
background-color: transparent;
color: #ffffff;
}
#workspaces button:hover {
background: rgba(0, 0, 0, 0.2);
}
#workspaces button.focused {
background-color: #64727D;
box-shadow: inset 0 -3px #ffffff;
}
#workspaces button.urgent {
background-color: #eb4d4b;
}
#mode {
background-color: #64727D;
box-shadow: inset 0 -3px #ffffff;
}
#clock,
#battery,
#cpu,
#memory,
#disk,
#temperature,
#backlight,
#network,
#pulseaudio,
#wireplumber,
#custom-media,
#tray,
#mode,
#idle_inhibitor,
#scratchpad,
#power-profiles-daemon,
#mpd {
padding: 0 10px;
color: #ffffff;
}
#window,
#workspaces {
margin: 0 4px;
}
/* If workspaces is the leftmost module, omit left margin */
.modules-left > widget:first-child > #workspaces {
margin-left: 0;
}
/* If workspaces is the rightmost module, omit right margin */
.modules-right > widget:last-child > #workspaces {
margin-right: 0;
}
#clock {
background-color: #64727D;
}
#battery {
background-color: #ffffff;
color: #000000;
}
#battery.charging, #battery.plugged {
color: #ffffff;
background-color: #26A65B;
}
@keyframes blink {
to {
background-color: #ffffff;
color: #000000;
}
}
/* Using steps() instead of linear as a timing function to limit cpu usage */
#battery.critical:not(.charging) {
background-color: #f53c3c;
color: #ffffff;
animation-name: blink;
animation-duration: 0.5s;
animation-timing-function: steps(12);
animation-iteration-count: infinite;
animation-direction: alternate;
}
#power-profiles-daemon {
padding-right: 15px;
}
#power-profiles-daemon.performance {
background-color: #f53c3c;
color: #ffffff;
}
#power-profiles-daemon.balanced {
background-color: #2980b9;
color: #ffffff;
}
#power-profiles-daemon.power-saver {
background-color: #2ecc71;
color: #000000;
}
label:focus {
background-color: #000000;
}
#cpu {
background-color: #2ecc71;
color: #000000;
}
#memory {
background-color: #9b59b6;
}
#disk {
background-color: #964B00;
}
#backlight {
background-color: #90b1b1;
}
#network {
background-color: #2980b9;
}
#network.disconnected {
background-color: #f53c3c;
}
#pulseaudio {
background-color: #f1c40f;
color: #000000;
}
#pulseaudio.muted {
background-color: #90b1b1;
color: #2a5c45;
}
#wireplumber {
background-color: #fff0f5;
color: #000000;
}
#wireplumber.muted {
background-color: #f53c3c;
}
#custom-media {
background-color: #66cc99;
color: #2a5c45;
min-width: 100px;
}
#custom-media.custom-spotify {
background-color: #66cc99;
}
#custom-media.custom-vlc {
background-color: #ffa000;
}
#temperature {
background-color: #f0932b;
}
#temperature.critical {
background-color: #eb4d4b;
}
#tray {
background-color: #2980b9;
}
#tray > .passive {
-gtk-icon-effect: dim;
}
#tray > .needs-attention {
-gtk-icon-effect: highlight;
background-color: #eb4d4b;
}
#idle_inhibitor {
background-color: #2d3436;
}
#idle_inhibitor.activated {
background-color: #ecf0f1;
color: #2d3436;
}
#mpd {
background-color: #66cc99;
color: #2a5c45;
}
#mpd.disconnected {
background-color: #f53c3c;
}
#mpd.stopped {
background-color: #90b1b1;
}
#mpd.paused {
background-color: #51a37a;
}
#language {
background: #00b093;
color: #740864;
padding: 0 5px;
margin: 0 5px;
min-width: 16px;
}
#keyboard-state {
background: #97e1ad;
color: #000000;
padding: 0 0px;
margin: 0 5px;
min-width: 16px;
}
#keyboard-state > label {
padding: 0 5px;
}
#keyboard-state > label.locked {
background: rgba(0, 0, 0, 0.2);
}
#scratchpad {
background: rgba(0, 0, 0, 0.2);
}
#scratchpad.empty {
background-color: transparent;
}
#privacy {
padding: 0;
}
#privacy-item {
padding: 0 5px;
color: white;
}
#privacy-item.screenshare {
background-color: #cf5700;
}
#privacy-item.audio-in {
background-color: #1ca000;
}
#privacy-item.audio-out {
background-color: #0069d4;
}
#tags button {
color: black;
}
#tags button.occupied {
color: white;
}
#tags button.focused {
background-color: grey;
}

View File

@ -12,8 +12,10 @@ in
options.my.programs.sway.enable = mkEnableOption "sway";
config = lib.mkIf cfg.enable {
hardware.opengl.enable = true;
hardware.opengl = {
enable = true;
driSupport = true;
};
environment.loginShellInit = ''
if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
exec sway

View File

@ -7,7 +7,8 @@ let
tmux-switch = pkgs.writeShellApplication {
name = "tmux-switch";
runtimeInputs = with pkgs; [ tmux ];
text = /* bash */ ''
text = ''
#!/usr/bin/env bash
if [[ -z ''${TMUX+x} ]]; then
tmux attach -t "$1"
else
@ -18,7 +19,7 @@ let
tmux-sessionizer = pkgs.writeFishApplication {
name = "ts";
runtimeInputs = with pkgs; [ tmux findutils coreutils procps fd tmux-new gawk ];
runtimeInputs = with pkgs; [ tmux findutils coreutils procps fd tmux-switch ];
text = readFile ./tmux-sessionizer/script.fish;
completions = readFile ./tmux-sessionizer/completions.fish;
};
@ -30,17 +31,6 @@ let
completions = readFile ./tmux-attach/completions.fish;
};
tmux-new = pkgs.writeFishApplication {
name = "tn";
runtimeInputs = with pkgs; [ tmux ];
text = /* fish */ ''
if ! tmux has-session -t $argv[1] 2> /dev/null
tmux new-session -ds $argv[1] -c $argv[2]
end
tmux-switch $argv[1]
'';
};
in
{
options.my.programs.tmux = {
@ -70,8 +60,6 @@ in
home-manager.users.moritz.home.packages = [
tmux-sessionizer
tmux-attach
tmux-switch
tmux-new
];
home-manager.users.moritz.programs = {
tmux = {
@ -109,7 +97,7 @@ in
if ! fish_is_root_user && test "$TERM_PROGRAM" != 'vscode' && ${insideVariableMissing}
if test -z $tmux_autostarted
set -x tmux_autostarted true
tn home ~
ts
end
end
'';

View File

@ -1,4 +1,4 @@
set selected (tmux list-sessions -F '#{session_name}' 2>/dev/null | fzf --query "$argv")
set selected (tmux list-sessions -F '#{session_name}' 2>/dev/null | fzf $argv)
if not test -n "$selected"
exit 1
end

14
modules/programs/tmux/tmux-sessionizer/script.fish Executable file → Normal file
View File

@ -1,10 +1,10 @@
#!/usr/bin/env fish
set pipe (mktemp --dry-run)
mkfifo $pipe
fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec-batch dirname {} | tee $pipe >/dev/null &
fd . ~/ --min-depth 1 --max-depth 3 --type d --exec-batch realpath {} | tee $pipe >/dev/null &
set selected (cat $pipe | awk '!seen[$0]++' | fzf --query "$argv")
fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec dirname {} | tee $pipe >/dev/null &
fd . ~/ --min-depth 1 --max-depth 3 --type d | tee $pipe >/dev/null &
set selected (cat $pipe | fzf $argv)
rm -f "$pipe"
set selected_name (basename $selected 2>/dev/null | string replace "." "_")
@ -13,4 +13,8 @@ if not test -n "$selected_name"
exit 1
end
tn "$selected_name" "$selected"
if ! tmux has-session -t $selected_name 2> /dev/null
tmux new-session -ds $selected_name -c $selected
end
tmux-switch $selected_name

View File

@ -1,44 +0,0 @@
{ config
, lib
, pkgs
, ...
}:
with lib;
let
cfg = config.my.programs.tofi;
configText =
let
settingsStrings = mapAttrsToList (name: value: "${name} = ${value}") cfg.settings;
in
concatLines settingsStrings;
in
{
options.my.programs.tofi = {
enable = mkEnableOption "tofi";
settings = mkOption {
type = with types; attrsOf str;
default = { };
};
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
(lib.mkIf config.networking.networkmanager.enable networkmanager_dmenu)
# (lib.mkIf config.hardware.bluetooth.enable rofi-bluetooth)
# rofi-power-menu
];
home-manager.users.moritz = {
home.packages = with pkgs; [ tofi ];
xdg = {
enable = true;
configFile."tofi/config".text = configText;
configFile."networkmanager-dmenu/config.ini".text = ''
[dmenu]
dmenu_command = tofi
'';
};
};
};
}

View File

@ -8,14 +8,7 @@ let
script = pkgs.writeShellApplication {
name = "wallpaper";
runtimeInputs = with pkgs; [
findutils
coreutils
feh
swaybg
fzf
(viu.override { withSixel = true; })
];
runtimeInputs = with pkgs; [ findutils coreutils feh swaybg fzf viu ];
text = builtins.readFile ./wallpaper.sh;
};
in

View File

@ -1,6 +1,5 @@
{ config
, lib
, pkgs
, ...
}: {
## System security tweaks
@ -70,7 +69,6 @@
# SSH
services.openssh = {
package = pkgs.master.openssh; # HACK: to fix CVE-2024-6387
settings = {
# Disable ssh password login
PasswordAuthentication = lib.mkDefault false;

View File

@ -1,27 +0,0 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.my.services.ollama;
in
{
options.my.services.ollama = {
enable = mkEnableOption "ollama";
package = mkOption {
type = types.package;
default = pkgs.ollama;
};
};
config = mkIf cfg.enable {
systemd.user.services.ollama = {
after = [ "network.target" ];
serviceConfig = {
Type = "simple";
Restart = "on-failure";
RestartSec = "1s";
ExecStart = "${getExe cfg.package} serve";
};
};
};
}

View File

@ -15,7 +15,7 @@ in
};
avahi = {
enable = true;
nssmdns4 = true;
nssmdns = true;
};
};
};

View File

@ -30,10 +30,6 @@ in
type = types.package;
default = pkgs.spotify-player;
};
target = mkOption {
type = types.str;
default = "graphical-session.target";
};
};
config = mkIf cfg.enable {
@ -48,8 +44,9 @@ in
}
];
systemd.user.services.spotify-player = {
after = [ cfg.target "network.target" ];
wantedBy = [ cfg.target ];
after = [ "graphical-session.target" "network.target" ];
partOf = [ "graphical-session.target" ];
wantedBy = [ "graphical-session.target" ];
serviceConfig = {
Type = "forking";
Restart = "always";

View File

@ -1,5 +1,4 @@
{ config
, inputs
, lib
, pkgs
, ...
@ -13,7 +12,7 @@ in
options.my.services.timers.enable = mkEnableOption "timers";
options.my.services.timers.package = mkOption {
type = types.package;
inherit (inputs.timers.packages.${pkgs.system}) default;
default = pkgs.timers;
};
config = lib.mkIf cfg.enable {

View File

@ -10,17 +10,12 @@ in
type = types.str;
default = "30m";
};
target = mkOption {
type = types.str;
default = "graphical-session.target";
};
};
config = mkIf cfg.enable {
systemd.user.services.wallpaper = {
script = "${getExe config.my.programs.wallpaper.package} -r -v";
wantedBy = [ cfg.target ];
after = [ cfg.target ];
wantedBy = [ "graphical-session.target" ];
serviceConfig = {
Restart = "always";
RuntimeMaxSec = cfg.frequency;

62
overlays/builders.nix Normal file
View File

@ -0,0 +1,62 @@
_:
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;
};
}

4
overlays/default.nix Normal file
View File

@ -0,0 +1,4 @@
{ lib, ... }@args:
lib.composeManyExtensions
(lib.my.mapModules' (file: import file args) ./.)

16
overlays/fixes.nix Normal file
View File

@ -0,0 +1,16 @@
{ lib, ... }:
final: prev: {
# python-poetry/poetry#5929
poetry = final.symlinkJoin {
name = "poetry";
paths = [ prev.poetry ];
postBuild =
let
regex = "s/'([a-z]*[[:blank:]][a-z]*)''/\1'/g";
in
''
${lib.getExe final.gnused} -i -E "${regex}" "$out/share/fish/vendor_completions.d/poetry.fish"
'';
};
}

5
overlays/lib.nix Normal file
View File

@ -0,0 +1,5 @@
{ lib, ... }:
_: _: {
inherit lib;
}

14
overlays/packages.nix Normal file
View File

@ -0,0 +1,14 @@
{ inputs, lib, ... }:
final: prev:
{
agenix = inputs.agenix.packages.${prev.system}.default;
hyprpaper = inputs.hyprpaper.packages.${prev.system}.default;
nix-super = inputs.nix-super.packages.${prev.system}.default;
rofi-wayland = prev.rofi-wayland.overrideAttrs (_: {
src = inputs.rofi-wayland;
version = lib.my.mkVersionInput inputs.rofi-wayland;
});
timers = inputs.timers.packages.${prev.system}.default;
hyprland = inputs.hyprland.packages.${prev.system}.default;
}

61
overlays/vimPlugins.nix Normal file
View File

@ -0,0 +1,61 @@
{ inputs, lib }:
_: prev:
with lib.my;
{
vimPlugins = prev.vimPlugins // {
inherit (inputs.codeium-nvim.packages.${prev.system}.vimPlugins) codeium-nvim;
smartcolumn-nvim = prev.vimUtils.buildVimPluginFrom2Nix {
pname = "smartcolumn-nvim";
version = mkVersionInput inputs.smartcolumn-nvim;
src = inputs.smartcolumn-nvim;
};
telekasten-nvim = prev.vimUtils.buildVimPluginFrom2Nix {
pname = "telekasten-nvim";
version = mkVersionInput inputs.telekasten-nvim;
src = inputs.telekasten-nvim;
};
hmts-nvim = prev.vimUtils.buildVimPluginFrom2Nix {
pname = "hmts-nvim";
version = mkVersionInput inputs.hmts-nvim;
src = inputs.hmts-nvim;
};
actions-preview-nvim = prev.vimUtils.buildVimPluginFrom2Nix {
pname = "actions-preview-nvim";
version = mkVersionInput inputs.actions-preview-nvim;
src = inputs.actions-preview-nvim;
};
telescope-nvim = prev.vimPlugins.telescope-nvim.overrideAttrs (_: {
version = mkVersionInput inputs.telescope-nvim;
src = inputs.telescope-nvim;
});
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;
});
nvim-puppeteer = prev.vimUtils.buildVimPluginFrom2Nix {
pname = "nvim-puppeteer";
version = mkVersionInput inputs.nvim-puppeteer;
src = inputs.nvim-puppeteer;
};
guard-nvim = prev.vimUtils.buildVimPluginFrom2Nix {
pname = "guard-nvim";
version = mkVersionInput inputs.guard-nvim;
src = inputs.guard-nvim;
};
};
}

25
overlays/wayland.nix Normal file
View File

@ -0,0 +1,25 @@
_:
final: prev: {
neovide-hyprland = final.symlinkJoin {
name = "neovide-hyprland-${final.neovide.version}";
paths = [ final.neovide ];
nativeBuildInputs = [ final.makeWrapper ];
postBuild = ''
rm $out/bin/neovide
makeWrapper ${final.neovide}/bin/neovide $out/bin/neovide --set WINIT_UNIX_BACKEND x11
'';
meta = final.neovide.meta // {
mainProgram = "neovide";
};
};
logseq-wayland = prev.symlinkJoin {
name = "logseq-wayland";
paths = [ prev.logseq ];
nativeBuildInputs = [ prev.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/logseq \
--add-flags "--socket=wayland --enable-features=UseOzonePlatform --ozone-platform=wayland"
'';
};
}

Binary file not shown.

View File

@ -23,7 +23,6 @@ in
"wireguard-private-key.age".publicKeys = personal;
"webis.age".publicKeys = hosts-personal ++ [ scadspc25 moritz ];
"webis-ssh.age".publicKeys = hosts-personal ++ [ scadspc25 moritz ];
"root-password.age".publicKeys = personal;
"moritz-password.age".publicKeys = personal;
"exercism.age".publicKeys = personal;
"root-password.age".publicKeys = hosts-personal ++ [ moritz ];
"moritz-password.age".publicKeys = hosts-personal ++ [ moritz ];
}

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +0,0 @@
disabled = []
nix_version = '2.4'
ignore = ['.direnv' 'templates']

View File

@ -1 +0,0 @@
use nix

View File

@ -1,14 +0,0 @@
{ pkgs ? import <nixpkgs> { } }:
let
poetry2nix = import (fetchTarball "https://github.com/nix-community/poetry2nix/archive/master.tar.gz") { };
project =
poetry2nix.mkPoetryApplication {
projectDir = ./.;
preferWheels = true;
};
in
pkgs.mkShell {
inputsFrom = [ project ];
packages = [ pkgs.poetry ];
}

View File

@ -1 +0,0 @@
use flake

View File

@ -1,24 +0,0 @@
# Created by https://www.toptal.com/developers/gitignore/api/rust,direnv
# Edit at https://www.toptal.com/developers/gitignore?templates=rust,direnv
### direnv ###
.direnv
.envrc
### Rust ###
# Generated by Cargo
# will have compiled files and executables
debug/
target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
# Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
# End of https://www.toptal.com/developers/gitignore/api/rust,direnv

View File

@ -1,59 +0,0 @@
{
inputs = {
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "nixpkgs/nixos-unstable";
};
outputs = { self, crane, flake-utils, nixpkgs, ... }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
inherit (pkgs) lib;
pkgs = import nixpkgs { inherit system; };
fenix = inputs.fenix.packages.${system};
craneLib = crane.lib.${system}.overrideToolchain toolchain.toolchain;
mkSrc = extraPaths: with lib.fileset; let
root = ./.;
rustFiles = fromSource (craneLib.cleanCargoSource root);
fileset = union rustFiles (unions extraPaths);
in
toSource { inherit root fileset; };
## Customize here ##
toolchain = fenix.complete; # or fenix.stable;
stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv;
in
{
packages.default = craneLib.buildPackage {
inherit stdenv;
src = mkSrc [ ];
strictDeps = true;
buildInputs = [
# Add additional build inputs here
] ++ lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
];
# Additional environment variables can be set directly
# MY_CUSTOM_VAR = "some value";
};
devShells.default = pkgs.mkShell.override { inherit stdenv; }
{
nativeBuildInputs = with pkgs; [
# Add additional build inputs here
] ++ (with toolchain; [
cargo
clippy
rustfmt
rustc
fenix.rust-analyzer
]);
RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/library";
};
}
);
}