manual: Simplify

This commit is contained in:
Zhaofeng Li 2021-11-23 13:17:05 -08:00
parent ad124544f5
commit e2bad26be5

View file

@ -7,21 +7,15 @@ in
, metaOptionsMd ? notFound "meta options text" , metaOptionsMd ? notFound "meta options text"
, colmena ? null , colmena ? null
, version ? null # Full version (default: detected from colmena) # Full version
, unstable ? null # Whether this build is unstable (default: detected from version) , version ? if colmena != null then colmena.version else "unstable"
# Whether this build is unstable
, unstable ? version == "unstable" || lib.hasInfix "-" version
}: }:
let let
versionComp = apiVersion = builtins.concatStringsSep "." (lib.take 2 (lib.splitString "." version));
if version == null then
if colmena != null then colmena.version else "unstable"
else version;
unstableComp =
if unstable == null then versionComp == "unstable" || lib.hasInfix "-" versionComp
else unstable;
apiVersion = builtins.concatStringsSep "." (lib.take 2 (lib.splitString "." versionComp));
redirectTemplate = lib.escapeShellArg '' redirectTemplate = lib.escapeShellArg ''
<!doctype html> <!doctype html>
@ -38,10 +32,9 @@ let
''; '';
in stdenv.mkDerivation { in stdenv.mkDerivation {
inherit deploymentOptionsMd metaOptionsMd; inherit version deploymentOptionsMd metaOptionsMd;
pname = "colmena-manual" + (if unstableComp then "-unstable" else ""); pname = "colmena-manual" + (if unstable then "-unstable" else "");
version = versionComp;
src = nix-gitignore.gitignoreSource [] ./.; src = nix-gitignore.gitignoreSource [] ./.;
@ -49,11 +42,11 @@ in stdenv.mkDerivation {
outputs = [ "out" "redirectFarm" ]; outputs = [ "out" "redirectFarm" ];
COLMENA_VERSION = versionComp; COLMENA_VERSION = version;
COLMENA_UNSTABLE = unstableComp; COLMENA_UNSTABLE = unstable;
patchPhase = '' patchPhase = ''
if [ -z "${toString unstableComp}" ]; then if [ -z "${toString unstable}" ]; then
sed "s|@apiVersion@|${apiVersion}|g" book.stable.toml > book.toml sed "s|@apiVersion@|${apiVersion}|g" book.stable.toml > book.toml
fi fi
''; '';
@ -78,7 +71,7 @@ in stdenv.mkDerivation {
mkdir -p $redirectFarm mkdir -p $redirectFarm
subdir="/unstable" subdir="/unstable"
if [ -z "${toString unstableComp}" ]; then if [ -z "${toString unstable}" ]; then
subdir="/${apiVersion}" subdir="/${apiVersion}"
fi fi