From fc019d789523ce5f89436b8dbc458cf3b79abf43 Mon Sep 17 00:00:00 2001 From: aristote Date: Tue, 29 Jul 2025 15:25:11 +0200 Subject: reformat everything with nixfmt --- modules/devenv/dotfiles.nix | 84 +++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 41 deletions(-) (limited to 'modules/devenv/dotfiles.nix') diff --git a/modules/devenv/dotfiles.nix b/modules/devenv/dotfiles.nix index ca3108c..994b50f 100644 --- a/modules/devenv/dotfiles.nix +++ b/modules/devenv/dotfiles.nix @@ -2,24 +2,25 @@ config, lib, ... -}: let +}: +let cfg = config.dotfiles; - dotfilesToIgnore = lib.attrNames (lib.filterAttrs (_: {gitignore, ...}: gitignore) cfg); -in { + dotfilesToIgnore = lib.attrNames (lib.filterAttrs (_: { gitignore, ... }: gitignore) cfg); +in +{ options.dotfiles = lib.mkOption { - type = with lib.types; - # this cannot be a lazyAttrsOf, see https://nixos.org/manual/nixos/unstable/#sec-option-types-composed + type = + with lib.types; + # this cannot be a lazyAttrsOf, see https://nixos.org/manual/nixos/unstable/#sec-option-types-composed attrsOf (submodule { options = { - gitignore = - lib.mkEnableOption "" - // { - 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). - ''; - }; + gitignore = lib.mkEnableOption "" // { + 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; default = ""; @@ -29,31 +30,32 @@ in { }); }; - config.enterShell = - lib.mkIf (cfg != {}) - ('' - echo Installing dotfiles... - '' - + lib.concatStringsSep "\n" (lib.mapAttrsToList ( - name: { - text, - gitignore, - }: - # this has to be done here to avoid infinite recursion - let - content = - text - + lib.optionalString (name == ".gitignore" && dotfilesToIgnore != []) '' - ### dotfiles - ${lib.concatStringsSep "\n" dotfilesToIgnore} - ''; - in '' - ${ - if gitignore - then "ln --symbolic --force" - else "install --mode=644" - } "${builtins.toFile name content}" "${name}" - '' - ) - cfg)); + config.enterShell = lib.mkIf (cfg != { }) ( + '' + echo Installing dotfiles... + '' + + lib.concatStringsSep "\n" ( + lib.mapAttrsToList ( + name: + { + text, + gitignore, + }: + # this has to be done here to avoid infinite recursion + let + content = + text + + lib.optionalString (name == ".gitignore" && dotfilesToIgnore != [ ]) '' + ### dotfiles + ${lib.concatStringsSep "\n" dotfilesToIgnore} + ''; + in + '' + ${ + if gitignore then "ln --symbolic --force" else "install --mode=644" + } "${builtins.toFile name content}" "${name}" + '' + ) cfg + ) + ); } -- cgit v1.2.3