Browse Source

Try rewrite code to improve service configuration

master
Danila Fedorin 10 months ago
parent
commit
30bd041431
  1. 22
      flake.nix
  2. 41
      lib.nix

22
flake.nix

@ -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);
};
}

41
default.nix → lib.nix

@ -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";
};
replaceUrl = {
from = "https://danilafe.com";
to = wrapHost settings.ssl settings.host;
};
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;
};
};
}
};
Loading…
Cancel
Save