diff --git a/modules/misc/news.nix b/modules/misc/news.nix index f6584383a..39527efea 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1143,6 +1143,13 @@ in A new module is available: 'services.ssh-agent' ''; } + + { + time = "2023-07-08T08:27:41+00:00"; + message = '' + A new modules is available: 'programs.darcs' + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index f6a15c020..6db9c29f3 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -70,6 +70,7 @@ let ./programs/chromium.nix ./programs/command-not-found/command-not-found.nix ./programs/comodoro.nix + ./programs/darcs.nix ./programs/dircolors.nix ./programs/direnv.nix ./programs/discocss.nix diff --git a/modules/programs/darcs.nix b/modules/programs/darcs.nix new file mode 100644 index 000000000..a2a45cba4 --- /dev/null +++ b/modules/programs/darcs.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.darcs; + +in { + meta.maintainers = with maintainers; [ chris-martin ]; + + options = { + programs.darcs = { + enable = mkEnableOption "darcs"; + + package = mkPackageOption pkgs "darcs" { }; + + author = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "Fred Bloggs " ]; + description = '' + If this list has a single entry, it will be used as the author + when you record a patch. If there are multiple entries, Darcs + will prompt you to choose one of them. + ''; + }; + + boring = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "^.idea$" ".iml$" "^.stack-work$" ]; + description = "File patterns to ignore"; + }; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + { home.packages = [ cfg.package ]; } + + (mkIf (cfg.author != [ ]) { + home.file.".darcs/author".text = + concatMapStrings (x: x + "\n") cfg.author; + }) + + (mkIf (cfg.boring != [ ]) { + home.file.".darcs/boring".text = + concatMapStrings (x: x + "\n") cfg.boring; + }) + + ]); +} diff --git a/tests/default.nix b/tests/default.nix index fb5afbc9d..738b158b2 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -68,6 +68,7 @@ import nmt { ./modules/programs/browserpass ./modules/programs/btop ./modules/programs/comodoro + ./modules/programs/darcs ./modules/programs/dircolors ./modules/programs/direnv ./modules/programs/emacs diff --git a/tests/modules/programs/darcs/author-expected.txt b/tests/modules/programs/darcs/author-expected.txt new file mode 100644 index 000000000..94be11277 --- /dev/null +++ b/tests/modules/programs/darcs/author-expected.txt @@ -0,0 +1,2 @@ +Real Person +Real Person diff --git a/tests/modules/programs/darcs/author.nix b/tests/modules/programs/darcs/author.nix new file mode 100644 index 000000000..26cfb469e --- /dev/null +++ b/tests/modules/programs/darcs/author.nix @@ -0,0 +1,17 @@ +{ pkgs, ... }: + +{ + config = { + programs.darcs = { + enable = true; + author = [ + "Real Person " + "Real Person " + ]; + }; + + nmt.script = '' + assertFileContent home-files/.darcs/author ${./author-expected.txt} + ''; + }; +} diff --git a/tests/modules/programs/darcs/boring-expected.txt b/tests/modules/programs/darcs/boring-expected.txt new file mode 100644 index 000000000..4a41138cd --- /dev/null +++ b/tests/modules/programs/darcs/boring-expected.txt @@ -0,0 +1,3 @@ +^.idea$ +.iml$ +^.stack-work$ diff --git a/tests/modules/programs/darcs/boring.nix b/tests/modules/programs/darcs/boring.nix new file mode 100644 index 000000000..ae02f18cf --- /dev/null +++ b/tests/modules/programs/darcs/boring.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: + +{ + config = { + programs.darcs = { + enable = true; + boring = [ "^.idea$" ".iml$" "^.stack-work$" ]; + }; + + nmt.script = '' + assertFileContent home-files/.darcs/boring ${./boring-expected.txt} + ''; + }; +} diff --git a/tests/modules/programs/darcs/default.nix b/tests/modules/programs/darcs/default.nix new file mode 100644 index 000000000..789841239 --- /dev/null +++ b/tests/modules/programs/darcs/default.nix @@ -0,0 +1,4 @@ +{ + darcs-author = ./author.nix; + darcs-boring = ./boring.nix; +}