From 536e20fdcea182735e10cef01faf4f777d515777 Mon Sep 17 00:00:00 2001 From: Daniel Thwaites Date: Sun, 20 Dec 2020 19:19:08 +0000 Subject: [PATCH] Add Vim module --- default.nix | 1 + modules/vim.nix | 35 +++++++++++++++++++++++++++++++++++ stylix/base16.nix | 22 ++++++++++++++++++++++ stylix/default.nix | 1 + 4 files changed, 59 insertions(+) create mode 100644 modules/vim.nix create mode 100644 stylix/base16.nix diff --git a/default.nix b/default.nix index 139c2989..025330ad 100644 --- a/default.nix +++ b/default.nix @@ -3,5 +3,6 @@ ./stylix/default.nix ./modules/console.nix + ./modules/vim.nix ]; } diff --git a/modules/vim.nix b/modules/vim.nix new file mode 100644 index 00000000..5f34073d --- /dev/null +++ b/modules/vim.nix @@ -0,0 +1,35 @@ +{ pkgs, config, ... }: + +let + base16-vim = pkgs.fetchFromGitHub { + owner = "chriskempson"; + repo = "base16-vim"; + rev = "6191622d5806d4448fa2285047936bdcee57a098"; + sha256 = "6FsT87qcl9GBxgxrPx2bPULIMA/O8TRxHaN49qMM4uM="; + }; + + themePlugin = pkgs.vimUtils.buildVimPlugin { + name = "stylix"; + + src = base16-vim; + data = config.lib.stylix.base16.json; + passAsFile = [ "data" ]; + + buildPhase = '' + mkdir -p $out/colors + ${pkgs.mustache-go}/bin/mustache $dataPath \ + $src/templates/default.mustache > $out/colors/base16-stylix.vim + ''; + }; + + vimOptions = { + plugins = [ themePlugin ]; + extraConfig = "colorscheme base16-stylix"; + }; + +in { + stylix.homeModule = { + programs.vim = vimOptions; + programs.neovim = vimOptions; + }; +} diff --git a/stylix/base16.nix b/stylix/base16.nix new file mode 100644 index 00000000..8b44cc1c --- /dev/null +++ b/stylix/base16.nix @@ -0,0 +1,22 @@ +# Used to build templates from http://chriskempson.com/projects/base16/ + +{ pkgs, config, ... }: + +{ + config.lib.stylix.base16 = rec { + json = builtins.toJSON (config.lib.stylix.colors // { + # Additional attributes only used for base16 + scheme-name = "Stylix"; + scheme-slug = "stylix"; + scheme-author = "Stylix"; + }); + + buildTemplate = name: templatePath: + pkgs.runCommand "base16-${name}" + { + inherit json templatePath; + passAsFile = [ "json" ]; + } + "${pkgs.mustache-go}/bin/mustache $jsonPath $templatePath > $out"; + }; +} diff --git a/stylix/default.nix b/stylix/default.nix index 90fea24e..81ead8c6 100644 --- a/stylix/default.nix +++ b/stylix/default.nix @@ -4,6 +4,7 @@ with lib; { imports = [ + ./base16.nix ./colors.nix ./fonts.nix ./home-manager.nix