This repository has been archived by the owner on Aug 13, 2022. It is now read-only.
forked from styx-static/styx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
84 lines (73 loc) · 3.23 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{
description = "The purely functional static site generator in Nix expression language.";
inputs.utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
inputs.flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
outputs = { self, utils, nixpkgs, ... }:
# utils.lib.eachDefaultSystem (system:
utils.lib.eachSystem [
"x86_64-linux" "i686-linux""aarch64-linux"
# "x86_64-darwin" "aarch64-darwin"
](system:
let
pkgs = (import nixpkgs { inherit system; }).extend (_: _: { inherit styx; });
styx = pkgs.callPackage ./derivation.nix { };
inherit (import ./src/default.nix { inherit pkgs; }) lib;
main-tests = import ./tests/main.nix { inherit pkgs lib; };
lib-tests = import ./tests/lib.nix { inherit pkgs lib; };
report = pkgs.writeScriptBin "testresult" "${lib.getExe pkgs.bat} ${lib-tests.report} ${lib-tests.coverage}";
showcase = pkgs.writeScriptBin "showcase-site" "xdg-open ${main-tests.showcase-site}/index.html";
update-doc = let
library-doc = import ./scripts/library-doc.nix { inherit pkgs lib; };
themes-doc = import ./scripts/themes-doc.nix { inherit pkgs lib; };
in pkgs.writeScriptBin "update-doc" ''
repoRoot="$(git rev-parse --show-toplevel)"
target="$(readlink -f -- "$repoRoot/src/doc/")"
if ! cmp "${themes-doc}/themes-generated.adoc" "$target/styx-themes-generated.adoc"
then
cp ${themes-doc}/themes-generated.adoc $target/styx-themes-generated.adoc --no-preserve=all
cp ${themes-doc}/imgs/* $target/imgs/ --no-preserve=all
echo "Themes documentation updated!"
fi
if ! cmp "${library-doc}/library-generated.adoc" "$target/library-generated.adoc"
then
cp ${library-doc}/library-generated.adoc $target/library-generated.adoc --no-preserve=all
echo "Library documentation updated!"
fi
'';
update-themes = pkgs.writeScriptBin "update-themes" ''
repoRoot="$(git rev-parse --show-toplevel)"
target="$(readlink -f -- "$repoRoot/themes/versions.nix")"
source="$(readlink -f -- "$repoRoot/themes/revs.csv")"
touch "$target"
echo "{" > "$target"
while IFS=, read owner theme rev
do
hash="$(${lib.getExe pkgs.nix-prefetch-git} --url "https://github.com/$owner/styx-theme-$theme.git" --rev "$rev" --no-deepClone --quiet | jq -r '.sha256')"
cat <<EOF >> "$target"
$theme = {
owner = "$owner";
repo = "styx-theme-$theme";
rev = "$rev";
sha256 = "$hash";
};
EOF
done < "$source"
echo "}" >> "$target"
'';
in
{
packages = { inherit styx report showcase update-doc update-themes; default = styx;};
hydraJobs = { inherit styx; };
inherit lib;
checks = with (utils.lib.check-utils system);
main-tests // {
lib-tests = isEqual "lib-tests-${toString lib-tests.success}" "lib-tests-1";
# doc-test = isEqual "
};
}
);
}