Try rewrite code to improve service configuration

This commit is contained in:
Danila Fedorin 2021-10-23 00:27:43 -07:00
parent 78c30ffc51
commit 30bd041431
2 changed files with 25 additions and 40 deletions

View File

@ -18,23 +18,11 @@
}; };
outputs = { self, blog-source, blog-source-localized, nixpkgs, flake-utils }: outputs = { self, blog-source, blog-source-localized, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem ( {
system: buildersFor = system: import ./lib.nix {
let inherit blog-source blog-source-localized;
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
blog = import ./default.nix { };
inherit blog-source blog-source-localized pkgs;
};
in
{
packages = {
english = blog.english;
"drafts/russian" = blog.drafts.russian;
"drafts/english" = blog.drafts.english;
};
defaultPackage = blog.english;
}
) // {
nixosModule = (import ./module.nix); nixosModule = (import ./module.nix);
}; };
} }

View File

@ -8,6 +8,7 @@ let
name = "blog-static"; name = "blog-static";
version = settings.source.rev; version = settings.source.rev;
src = settings.source; src = settings.source;
ssl = settings.ssl;
urlSub = urlSub =
let let
regexEscape = lib.escape [ "/" "(" ")" "[" "]" "+" "*" "\\" ]; regexEscape = lib.escape [ "/" "(" ")" "[" "]" "+" "*" "\\" ];
@ -28,31 +29,27 @@ let
(ruby.withPackages (ps: [ ps.nokogiri ])) (ruby.withPackages (ps: [ ps.nokogiri ]))
]; ];
}; };
wrapHost = ssl: host: (if ssl then "https" else "http") + "//${host}";
in in
{ lib = {
english = website { english = settings: website {
inherit (settings) drafts;
ssl = settings.ssl or false;
source = blog-source; source = blog-source;
path = "."; path = ".";
drafts = false; replaceUrl = {
}; from = "https://danilafe.com";
drafts = { to = wrapHost settings.ssl settings.host;
english = website {
source = blog-source;
path = ".";
drafts = true;
replaceUrl = {
from = "https://danilafe.com";
to = "http://drafts.danilafe.com";
};
};
russian = website {
source = blog-source-localized;
path = "ru";
drafts = true;
replaceUrl = {
from = "https://ru.danilafe.com";
to = "http://drafts.ru.danilafe.com";
};
}; };
}; };
} russian = settings: website {
inherit (settings) drafts;
ssl = settings.ssl or false;
source = blog-source-localized;
path = "ru";
replaceUrl = {
from = "https://ru.danilafe.com";
to = wrapHost settings.ssl settings.host;
};
};
};