Skip to content

Commit 7ef8985

Browse files
add mutable shortlinks
this allows mapping cleanly from the existing mutable links on nixos.org
1 parent aef7822 commit 7ef8985

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

default.nix

+18-8
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,36 @@ let
3131
# FIXME: This requires human interaction to update!
3232
# See ./CONTRIBUTING.md for details.
3333
# Using Nix from Nixpkgs could simplify handling, but would requires a bit more setup here
34-
releases = [
35-
"2.19"
36-
"2.18"
37-
"2.13"
38-
];
34+
releases = {
35+
latest = "2.19";
36+
rolling = "2.18";
37+
stable = "2.18";
38+
prev-stable = "2.13";
39+
};
3940
inputName = version: pkgs.lib.strings.replaceStrings [ "." ] [ "-" ] version;
4041
src = version: inputs."nix_${inputName version}";
4142
manual = version: (import (src version)).default.doc;
4243
copy = version: ''
4344
cp -Rf ${manual version}/share/doc/nix/manual/* $out/manual/nix/${version}
44-
# use upstream page redirects
45+
'';
46+
redirects = version: ''
4547
sed 's#^\(.*\) \(.*\) #/manual/nix/${version}\1 /manual/nix/${version}\2 #g' ${src version}/doc/manual/_redirects >> $out/_redirects
4648
'';
49+
shortlink = release: version: ''
50+
echo /manual/nix/${release} /manual/nix/${version} >> $out/_redirects
51+
'';
52+
versions = with pkgs.lib; lists.unique (attrsets.attrValues releases);
4753
in
54+
with pkgs.lib.attrsets;
4855
with pkgs.lib.strings;
4956
''
57+
mkdir -p $out
58+
cp -R build/html/* $out/
5059
# NOTE: the comma in the shell expansion makes it also work for singleton lists
5160
mkdir -p $out/manual/nix/{${concatStringsSep "," releases},}
52-
cp -R build/html/* $out/
53-
${concatStringsSep "\n" (map copy releases)}
61+
${concatStringsSep "\n" (map copy versions)}
62+
${concatStringsSep "\n" (map redirects versions)}
63+
${concatStringsSep "\n" (mapAttrsToList shortlink releases)}
5464
'';
5565
};
5666

0 commit comments

Comments
 (0)