diff options
| author | quentin@aristote.fr <quentin@aristote.fr> | 2023-08-26 23:28:27 +0200 |
|---|---|---|
| committer | quentin@aristote.fr <quentin@aristote.fr> | 2023-08-27 12:05:15 +0200 |
| commit | 2cb43216d3c2cbc6f40e0d6646abb9f31a1c40f7 (patch) | |
| tree | 05eb1717f529ae1f78a7c615ceb6e1980909efae /modules/devenv/integrations | |
| parent | e467ecaea03942161ba5b09a251deb31c5b9ba53 (diff) | |
devenv: add more modules
Diffstat (limited to 'modules/devenv/integrations')
| -rw-r--r-- | modules/devenv/integrations/default.nix | 3 | ||||
| -rw-r--r-- | modules/devenv/integrations/emacs.nix | 53 | ||||
| -rw-r--r-- | modules/devenv/integrations/gitignore.nix | 25 |
3 files changed, 81 insertions, 0 deletions
diff --git a/modules/devenv/integrations/default.nix b/modules/devenv/integrations/default.nix new file mode 100644 index 0000000..7fa74bd --- /dev/null +++ b/modules/devenv/integrations/default.nix @@ -0,0 +1,3 @@ +{ + imports = [./emacs.nix ./gitignore.nix]; +} diff --git a/modules/devenv/integrations/emacs.nix b/modules/devenv/integrations/emacs.nix new file mode 100644 index 0000000..b7f1e42 --- /dev/null +++ b/modules/devenv/integrations/emacs.nix @@ -0,0 +1,53 @@ +{ + config, + lib, + ... +}: let + cfg = config.emacs; + attrs2alist = value: + if lib.isAttrs value + then "(${lib.concatStringsSep "\n" (lib.mapAttrsToList (name: value: "(${name} . ${attrs2alist value})") value)})" + else + ( + if lib.isList value + then "(${lib.concatStringsSep " " value})" + else + ( + if lib.isBool value + then + ( + if value + then "t" + else "nil" + ) + else builtins.toString value + ) + ); +in { + options.emacs = { + enable = lib.mkEnableOption "emacs integration"; + dirLocals = lib.mkOption { + type = with lib.types; attrsOf (attrsOf str); + default = {}; + example = + # the first example from https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html + { + nil = { + indent-tabs-mode = true; + fill-column = 80; + mode = "auto-fill"; + }; + c-mode = { + c-file-style = ''"BSD"''; + subdirs = "nil"; + }; + "\"src/imported\"".nil.change-log-default-name = ''"ChangeLog.local"''; + }; + }; + }; + + config.dotfiles.".dir-locals.el" = lib.mkIf (cfg.dirLocals != {}) { + gitignore = lib.mkDefault true; + text = attrs2alist cfg.dirLocals; + }; +} diff --git a/modules/devenv/integrations/gitignore.nix b/modules/devenv/integrations/gitignore.nix new file mode 100644 index 0000000..ed0e61a --- /dev/null +++ b/modules/devenv/integrations/gitignore.nix @@ -0,0 +1,25 @@ +{ + config, + lib, + ... +}: let + cfg = config.gitignore; +in { + options.gitignore = { + extra = lib.mkOption { + type = lib.types.lines; + default = ""; + example = '' + *.my-file-extension + ''; + }; + }; + + config.dotfiles.gitignore = lib.mkIf (cfg.extra != "") { + gitignore = lib.mkDefault false; + text = '' + ## Miscellaneous + ${cfg.extra}; + ''; + }; +} |
