File tree 5 files changed +53
-16
lines changed
5 files changed +53
-16
lines changed Original file line number Diff line number Diff line change @@ -10,14 +10,17 @@ If you do have a change worthy of a news entry then please add one in
10
10
[ ` news.nix ` ] ( https://github.com/nix-community/home-manager/blob/master/modules/misc/news.nix )
11
11
but you should follow some basic guidelines:
12
12
13
- - The entry timestamp should be in ISO-8601 format having \" +00:00 \"
14
- as time zone. For example, \" 2017-09-13T17:10:14+00:00 \" . A suitable
15
- timestamp can be produced by the command
13
+ - Use the included
14
+ [ ` create-news-entry.sh ` ] ( https://github.com/nix-community/home-manager/blob/master/modules/misc/news/create-news-entry.sh )
15
+ script to generate a news entry file:
16
16
17
17
``` shell
18
- $ date --iso-8601=second --universal
18
+ $ modules/misc/news/create-news-entry.sh
19
19
```
20
20
21
+ this will create a new file inside ` modules/misc/news` directory
22
+ with some placeholder information that you can edit.
23
+
21
24
- The entry condition should be as specific as possible. For example,
22
25
if you are changing or deprecating a specific option then you could
23
26
restrict the news to those users who actually use this option.
Original file line number Diff line number Diff line change 6
6
7
7
let
8
8
inherit ( builtins )
9
- concatStringsSep filter hasAttr isString length optionalString readFile
10
- replaceStrings sort split ;
9
+ concatStringsSep filter hasAttr isString length readFile replaceStrings sort
10
+ split ;
11
11
12
12
newsJson = builtins . fromJSON ( builtins . readFile newsJsonFile ) ;
13
13
Original file line number Diff line number Diff line change 45
45
id = lib . mkDefault ( builtins . hashString "sha256" config . message ) ;
46
46
} ;
47
47
} ) ;
48
+
49
+ isNixFile = n : v : v == "regular" && lib . hasSuffix ".nix" n ;
50
+ # builtins.attrNames return the values in alphabetical order
51
+ newsFiles =
52
+ builtins . attrNames ( lib . filterAttrs isNixFile ( builtins . readDir ./news ) ) ;
53
+ newsEntries =
54
+ builtins . map ( newsFile : import ( ./news + "/${ newsFile } " ) ) newsFiles ;
48
55
in {
49
56
meta . maintainers = [ lib . maintainers . rycee ] ;
50
57
96
103
news . json . output = pkgs . writeText "hm-news.json"
97
104
( builtins . toJSON { inherit ( cfg ) display entries ; } ) ;
98
105
99
- # Add news entries in chronological order (i.e., latest time
100
- # should be at the bottom of the list). The time should be
101
- # formatted as given in the output of
102
- #
103
- # date --iso-8601=second --universal
104
- #
105
- # On darwin (or BSD like systems) use
106
- #
107
- # date -u +'%Y-%m-%dT%H:%M:%S+00:00'
106
+ # DO NOT define new entries here, instead use the `./create-news-entry.sh`
107
+ # script and create an individual news file inside `news` sub-directory.
108
108
news . entries = [
109
109
{
110
110
time = "2021-06-02T04:24:10+00:00" ;
@@ -2231,6 +2231,6 @@ in {
2231
2231
See https://github.com/ivaaaan/smug for more information.
2232
2232
'' ;
2233
2233
}
2234
- ] ;
2234
+ ] ++ newsEntries ;
2235
2235
} ;
2236
2236
}
Original file line number Diff line number Diff line change
1
+ {
2
+ time = "2025-04-02T13:01:34+00:00" ;
3
+ condition = true ;
4
+ message = ''
5
+ A new way to define news is available.
6
+
7
+ Instead of editing the previous news.nix file, you can now define entries
8
+ using individual files. This should reduce the number of merge conflicts.
9
+ '' ;
10
+ }
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env nix-shell
2
+ #! nix-shell -I https://github.com/NixOS/nixpkgs/archive/05f0934825c2a0750d4888c4735f9420c906b388.tar.gz -i bash -p coreutils
3
+
4
+ DATE=" $( date --iso-8601=second --universal) "
5
+ FILENAME=" $( date --date=" $DATE " +" %Y-%m-%d_%H-%M-%S" ) .nix"
6
+ DIRNAME=" $( dirname -- " ${BASH_SOURCE[0]} " ) "
7
+
8
+ cd " $DIRNAME " || {
9
+ >&2 echo " Failed to change to the script directory: $DIRNAME "
10
+ exit 1
11
+ }
12
+
13
+ cat - << EOF > "$FILENAME "
14
+ {
15
+ time = "$DATE ";
16
+ condition = true;
17
+ message = ''
18
+ PLACEHOLDER
19
+ '';
20
+ }
21
+ EOF
22
+
23
+ echo " Successfully created a news file: $DIRNAME /$FILENAME "
24
+ echo " You can open the file above in your text editor and edit now."
You can’t perform that action at this time.
0 commit comments