Compare commits

..

1 Commits

Author SHA1 Message Date
7aeb03f813 Add code to properly link submodules. 2021-01-10 19:57:22 -08:00
5 changed files with 49 additions and 62 deletions

View File

@@ -7,6 +7,13 @@ cp -r $src/* .
# We have to manually edit the configuration.
sed -i "$urlSub" config.toml
# Run the submodule command in the source .git
# repo, amending the config.
cwdir=$(pwd)
cd $src
ruby $submodules >> $cwdir/config.toml
cd $cwdir
# Build site with Hugo
hugo $extraFlags

View File

@@ -1,12 +1,15 @@
{ blog-source, blog-source-localized, stdenv, lib, hugo, fetchgit, pkgs, nodejs, ruby }:
{ stdenv, lib, hugo, fetchgit, pkgs, nodejs, ruby }:
let
url = "https://dev.danilafe.com/Web-Projects/blog-static.git";
requiredPackages = import ./required-packages.nix { inherit pkgs nodejs; };
website = settings: stdenv.mkDerivation {
name = "blog-static";
version = settings.source.rev;
src = settings.source;
version = settings.rev;
src = fetchgit {
inherit url;
inherit (settings) rev sha256;
};
urlSub =
let
regexEscape = lib.escape [ "/" "(" ")" "[" "]" "+" "*" "\\" ];
@@ -32,13 +35,13 @@ let
in
{
english = website {
source = blog-source;
inherit rev sha256;
path = ".";
drafts = false;
};
drafts = {
english = website {
source = blog-source;
inherit rev sha256;
path = ".";
drafts = true;
replaceUrl = {
@@ -47,7 +50,8 @@ in
};
};
russian = website {
source = blog-source-localized;
rev = localizationRev;
sha256 = localizationSha256;
path = "ru";
drafts = true;
replaceUrl = {

19
blog/submodule-links.rb Normal file
View File

@@ -0,0 +1,19 @@
puts "[params]"
puts " [params.submoduleLinks]"
`git submodule status --recursive`.lines do |line|
hash, path = line[1..].split " "
next unless path.start_with? "code/"
code_path = path.delete_prefix "code/"
url = `git config --file .gitmodules --get 'submodule.#{path}.url'`.chomp.delete_suffix(".git")
safe_name = code_path.gsub(/\/|-|_/, "")
if url =~ /dev.danilafe.com/
file_url = "#{url}/src/commit/#{hash}"
else
raise "Submodule URL not in a known format!"
end
puts " [params.submoduleLinks.#{safe_name}]"
puts " path = #{code_path.dump}"
puts " url = #{file_url.dump}"
end

View File

@@ -1,49 +0,0 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
blog-source = {
flake = false;
url = "https://dev.danilafe.com/Web-Projects/blog-static.git";
type = "git";
submodules = true;
};
blog-source-localized = {
flake = false;
url = "https://dev.danilafe.com/Web-Projects/blog-static.git";
ref = "localization";
type = "git";
submodules = true;
};
pegasus-source = {
url = "github:DanilaFe/pegasus";
flake = false;
};
pupper-bot-source = {
url = "git+https://dev.danilafe.com/Crystal-Bots/joann-pupper-bot";
flake = false;
};
};
outputs = { self, pupper-bot-source, pegasus-source, blog-source, blog-source-localized, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs { inherit system; };
pegasus = pkgs.callPackage ./pegasus/default.nix {
inherit pegasus-source;
};
blog = pkgs.callPackage ./blog/default.nix {
inherit blog-source blog-source-localized;
};
in
{
packages = {
inherit pegasus;
blogEnglish = blog.english;
blogEnglishDrafts = blog.drafts.english;
blogRussianDrafts = blog.drafts.russian;
};
}
);
}

View File

@@ -1,12 +1,18 @@
{ pegasus-source, stdenv, crystal, fetchFromGitHub }:
{ stdenv, crystal, fetchFromGitHub }:
let
version = "0489d47b191ecf8501787355b948801506e7c70f";
src = fetchFromGitHub {
owner = "DanilaFe";
repo = "pegasus";
rev = version;
sha256 = "097m7l16byis07xlg97wn5hdsz9k6c3h1ybzd2i7xhkj24kx230s";
};
in
crystal.buildCrystalPackage {
pname = "pegasus";
src = pegasus-source;
version = pegasus-source.rev;
format = "crystal";
# Programs don't do so well when running --help
installCheckPhase = "";
inherit version;
inherit src;
crystalBinaries.pegasus.src = "src/pegasus.cr";
crystalBinaries.pegasus-dot.src = "src/tools/dot/pegasus_dot.cr";