Start working on converting to Nix flakes.

This commit is contained in:
Danila Fedorin 2021-01-05 06:44:58 +00:00
parent 28fcd6e254
commit b3ecef1dcc
3 changed files with 62 additions and 23 deletions

View File

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

49
flake.nix Normal file
View File

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