diff options
| author | quentin@aristote.fr <quentin@aristote.fr> | 2023-08-27 17:01:55 +0200 |
|---|---|---|
| committer | quentin@aristote.fr <quentin@aristote.fr> | 2023-08-27 17:01:55 +0200 |
| commit | cb68af5842bead368f0671f81dc90b5e46b6d40b (patch) | |
| tree | 2b3071882e6504b2bc0fcca39f6d18a2278d3ae7 | |
| parent | 511d1466331c7d4ede2c7f025a08a488d43fe027 (diff) | |
devenv: nix: add formatter to emacs
| -rw-r--r-- | flake.nix | 23 | ||||
| -rw-r--r-- | modules/devenv/dotfiles.nix | 7 | ||||
| -rw-r--r-- | modules/devenv/integrations/emacs.nix | 8 | ||||
| -rw-r--r-- | modules/devenv/languages/nix.nix | 7 |
4 files changed, 30 insertions, 15 deletions
@@ -19,7 +19,13 @@ } @ inputs: flake-parts.lib.mkFlake {inherit inputs;} { imports = [flake-parts.flakeModules.easyOverlay devenv.flakeModule]; - systems = ["x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; + systems = [ + "x86_64-linux" + "i686-linux" + "x86_64-darwin" + "aarch64-linux" + "aarch64-darwin" + ]; flake = { devenvModules.personal = import ./modules/devenv; @@ -47,9 +53,7 @@ echo .devenv >> .gitignore ``` ''; - mkDevenvTemplate = path: { - inherit welcomeText path; - }; + mkDevenvTemplate = path: {inherit welcomeText path;}; devenv = mkDevenvTemplate ./templates/devenv/simple; devenvModular = mkDevenvTemplate ./templates/devenv/flake-parts; in { @@ -67,12 +71,17 @@ }: let flatten = let aux = path: attrs: - if lib.isAttrs attrs && ! lib.isDerivation attrs - then lib.foldlAttrs (prev: name: value: prev // aux (path ++ [name]) value) {} attrs + if lib.isAttrs attrs && !lib.isDerivation attrs + then + lib.foldlAttrs + (prev: name: value: prev // aux (path ++ [name]) value) {} + attrs else ( if lib.isDerivation attrs - then {"${lib.concatStringsSep "_" path}" = attrs;} + then { + "${lib.concatStringsSep "_" path}" = attrs; + } else {} ); in diff --git a/modules/devenv/dotfiles.nix b/modules/devenv/dotfiles.nix index 7f11194..ca3108c 100644 --- a/modules/devenv/dotfiles.nix +++ b/modules/devenv/dotfiles.nix @@ -14,8 +14,11 @@ in { gitignore = lib.mkEnableOption "" // { - default = true; - description = "Whether git should ignore this dotfile, typically if it is generated to contain absolute paths."; + description = '' + Whether git should ignore this dotfile, typically if it is + generated to contain absolute paths and is specific to this + project (and may not be ignored system-wide by the user). + ''; }; text = lib.mkOption { type = lib.types.lines; diff --git a/modules/devenv/integrations/emacs.nix b/modules/devenv/integrations/emacs.nix index b7f1e42..d002967 100644 --- a/modules/devenv/integrations/emacs.nix +++ b/modules/devenv/integrations/emacs.nix @@ -46,8 +46,8 @@ in { }; }; - config.dotfiles.".dir-locals.el" = lib.mkIf (cfg.dirLocals != {}) { - gitignore = lib.mkDefault true; - text = attrs2alist cfg.dirLocals; - }; + config.dotfiles.".dir-locals.el".text = + lib.mkIf (cfg.dirLocals != {}) + (attrs2alist + cfg.dirLocals); } diff --git a/modules/devenv/languages/nix.nix b/modules/devenv/languages/nix.nix index 6db3af4..efd76ce 100644 --- a/modules/devenv/languages/nix.nix +++ b/modules/devenv/languages/nix.nix @@ -18,12 +18,15 @@ in { packaging.enable = lib.mkEnableOption "tools for writing nix derivations"; }; - config = { - packages = lib.mkIf cfg.enable (with pkgs; [cfg.formatter deadnix] ++ lib.optionals cfg.packaging.enable [nix-prefetch-scripts nix-prefetch-github]); + config = lib.mkIf cfg.enable { + packages = with pkgs; [cfg.formatter deadnix] ++ lib.optionals cfg.packaging.enable [nix-prefetch-scripts nix-prefetch-github]; pre-commit.hooks = { deadnix.enable = lib.mkDefault true; "${cfg.formatter.pname}".enable = lib.mkDefault true; }; + + scripts."${cfg.formatter.pname}-emacs".exec = "${cfg.formatter.pname} " + lib.optionalString (cfg.formatter.pname == "alejandra") "--quiet" + " $@"; + emacs.dirLocals.nix-mode.nix-nixfmt-bin = ''"${cfg.formatter.pname}-emacs"''; }; } |
