diff options
| author | aristote <quentin.aristote@irif.fr> | 2025-07-29 15:25:11 +0200 |
|---|---|---|
| committer | aristote <quentin.aristote@irif.fr> | 2025-07-29 15:25:11 +0200 |
| commit | fc019d789523ce5f89436b8dbc458cf3b79abf43 (patch) | |
| tree | ec56fd1b1ed9fc75096c0b09db48a152975e4d53 /modules/devenv/dotfiles.nix | |
| parent | a3d19bc509d9f39fb41256cd55d2bd7706de202f (diff) | |
reformat everything with nixfmt
Diffstat (limited to 'modules/devenv/dotfiles.nix')
| -rw-r--r-- | modules/devenv/dotfiles.nix | 84 |
1 files changed, 43 insertions, 41 deletions
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 + ) + ); } |
