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 }:
flake-utils.lib.eachDefaultSystem (
system:
let
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;
}
) // {
{
buildersFor = system: import ./lib.nix {
inherit blog-source blog-source-localized;
pkgs = import nixpkgs { inherit system; };
};
nixosModule = (import ./module.nix);
};
}

View File

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