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
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.rev;
src = fetchgit {
inherit url;
inherit (settings) rev sha256;
};
version = settings.source.rev;
src = settings.source;
urlSub =
let
regexEscape = lib.escape [ "/" "(" ")" "[" "]" "+" "*" "\\" ];
@ -35,13 +32,13 @@ let
in
{
english = website {
inherit rev sha256;
source = blog-source;
path = ".";
drafts = false;
};
drafts = {
english = website {
inherit rev sha256;
source = blog-source;
path = ".";
drafts = true;
replaceUrl = {
@ -50,8 +47,7 @@ in
};
};
russian = website {
rev = localizationRev;
sha256 = localizationSha256;
source = blog-source-localized;
path = "ru";
drafts = true;
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 }:
let
version = "0489d47b191ecf8501787355b948801506e7c70f";
src = fetchFromGitHub {
owner = "DanilaFe";
repo = "pegasus";
rev = version;
sha256 = "097m7l16byis07xlg97wn5hdsz9k6c3h1ybzd2i7xhkj24kx230s";
};
in
{ pegasus-source, stdenv, crystal, fetchFromGitHub }:
crystal.buildCrystalPackage {
pname = "pegasus";
inherit version;
inherit src;
src = pegasus-source;
version = pegasus-source.rev;
format = "crystal";
# Programs don't do so well when running --help
installCheckPhase = "";
crystalBinaries.pegasus.src = "src/pegasus.cr";
crystalBinaries.pegasus-dot.src = "src/tools/dot/pegasus_dot.cr";