default.nix (1630B)
1 { 2 lib, 3 options, 4 config, 5 pkgs, 6 ... 7 }: 8 { 9 options.modules.newsraft = { 10 enable = lib.mkOption { 11 description = "Whether to enable Newsraft."; 12 default = false; 13 type = lib.types.bool; 14 }; 15 feeds = lib.mkOption { 16 description = "For each section name, its list of feeds."; 17 default = { }; 18 type = 19 lib.types.submodule { 20 options = { 21 name = lib.mkOption { 22 description = "The name of the feed."; 23 type = lib.types.uniq lib.types.str; 24 }; 25 url = lib.mkOption { 26 description = "The URL of the feed."; 27 type = lib.types.uniq lib.types.str; 28 }; 29 }; 30 } 31 |> lib.types.listOf 32 |> lib.types.attrsOf; 33 }; 34 }; 35 36 config = lib.mkIf config.modules.newsraft.enable { 37 home = { 38 packages = [ pkgs.newsraft ]; 39 file = { 40 ".config/newsraft/config".text = '' 41 # Empty configuration as of now. 42 ''; 43 ".config/newsraft/feeds".text = 44 config.modules.newsraft.feeds 45 |> builtins.mapAttrs ( 46 section: feeds: '' 47 @ ${section} 48 ${ 49 ( 50 feeds 51 |> builtins.map ( 52 { name, url }: 53 '' 54 ${url} "${name}" 55 '' 56 ) 57 |> builtins.concatStringsSep "\n" 58 ) 59 } 60 '' 61 ) 62 |> builtins.attrValues 63 |> builtins.concatStringsSep "\n"; 64 }; 65 }; 66 }; 67 }