From d08d5a6c9ab70b4efb7e6d725bc3cb36165c972e Mon Sep 17 00:00:00 2001 From: Bit Borealis Date: Tue, 25 Jul 2023 14:38:50 +0000 Subject: [PATCH] TAKE THAT NIX --- home.nix | 93 +++------------------------------------ modules/neovim-config.nix | 2 + 2 files changed, 8 insertions(+), 87 deletions(-) diff --git a/home.nix b/home.nix index 8d95cfd..f984399 100644 --- a/home.nix +++ b/home.nix @@ -1,89 +1,6 @@ -{ config, pkgs, lib, ... }: with builtins; -# find a way to make this let in statement not here, but in modules/neovim-config.nix -let - mkSettings = s: - concatStringsSep - "\n" - (attrValues - (mapAttrs - (k: v: - if typeOf v == "bool" then - if v then "set ${k}" else "set no${k}" - else - "set ${k}=${toString v}") - s - ) - ); - boolToString = b: if b then "true" else "false"; - toLuaTable = as: - "{" + - ( concatStringsSep - ", " - ( filter - (attr: !isNull attr) - ( attrValues - ( mapAttrs - (k: v: if v then "${k}=true" else null) - as - ) - ) - ) - ) + - "}"; - mkMapping = { - mode, - binding, - command, - nowait?false, - silent?false, - unique?false, - expr?false - }: - "vim.api.nvim_set_keymap(${toJSON mode}, ${toJSON binding}, ${toJSON command}, ${toLuaTable {inherit nowait silent unique expr;}})"; - mkMappings = - m: - "lua << END-OF-KEYBINDS\n" + - (concatStringsSep "\n" (map mkMapping m)) + - "\nEND-OF-KEYBINDS"; - mkRuntimes = rs: - if rs == [] then "" else - "set runtimepath+=" + - ( concatStringsSep - "," - (map (rt: "${rt}") rs) - ); - mkVimHeader = h: "\"\"\"\"\"\"\"\" ${h} \"\"\"\"\"\"\"\"\""; - mkVimSection = section: - (concatStringsSep "\n\n\n" - (filter - (v: !isNull v) - (attrValues - (mapAttrs - (k: v: if "" == v then null else (mkVimHeader k) + "\n" + v) - section - ) - ) - ) - ); - mkVimSections = sections: concatStringsSep "\n\n\n" (map mkVimSection sections); - mkConfig = { settings?{}, mappings?[], runtimes?[], extra?"" }: - mkVimSections [ - {"ADDITIONAL RUNTIME DIRS" = mkRuntimes runtimes;} - {"SETTINGS" = mkSettings settings;} - {"KEY BINGINGS" = mkMappings mappings;} - {"MANUAL SETTINGS" = extra;} - ]; - - # Via https://gist.github.com/nat-418/d76586da7a5d113ab90578ed56069509 - fromGitHub = ref: repo: pkgs.vimUtils.buildVimPluginFrom2Nix { - pname = "${lib.strings.sanitizeDerivationName repo}"; - version = ref; - src = builtins.fetchGit { - url = "https://github.com/${repo}.git"; - ref = ref; - }; - }; -in +{ config, pkgs, lib, ... }: +with builtins; +with import ./modules/neovim-config.nix { inherit pkgs lib fromGitHub; }; { # Home Manager needs a bit of information about you and the paths it should # manage. @@ -115,6 +32,7 @@ in gimp lollypop skim + telegram-desktop picard syncthing armcord @@ -128,17 +46,18 @@ in apostrophe warp syncplay + virt-manager mpv wl-clipboard adw-gtk3 ] ++ ( with pkgs.gnome; [ - gnome-boxes gnome-tweaks dconf-editor ] ++ ( with pkgs.gnomeExtensions; [ night-theme-switcher rounded-window-corners appindicator + gsconnect ])); diff --git a/modules/neovim-config.nix b/modules/neovim-config.nix index 51dd75c..d82bf42 100644 --- a/modules/neovim-config.nix +++ b/modules/neovim-config.nix @@ -1,3 +1,5 @@ +{ pkgs, lib, fromGitHub }: with builtins; +rec { mkSettings = s: concatStringsSep