Move theme config to separate file

pull/1/head
mat ess 2022-08-27 14:42:04 -04:00
parent c8dd5a2df4
commit e8a2567cef
2 changed files with 20 additions and 13 deletions

View File

@ -12,11 +12,6 @@
}; };
outputs = { self, flake-parts, ... }@inputs: outputs = { self, flake-parts, ... }@inputs:
let
themeEnabled = false;
theme = inputs.apollo;
themeName = ((builtins.fromTOML (builtins.readFile "${theme}/theme.toml")).name);
in
flake-parts.lib.mkFlake { inherit self; } { flake-parts.lib.mkFlake { inherit self; } {
imports = [ ]; imports = [ ];
systems = inputs.nixpkgs.lib.systems.flakeExposed; systems = inputs.nixpkgs.lib.systems.flakeExposed;
@ -25,6 +20,10 @@
inherit (pkgs) callPackage; inherit (pkgs) callPackage;
optimize-images = callPackage ./nix/optimize-images.nix { }; optimize-images = callPackage ./nix/optimize-images.nix { };
inherit (callPackage ./nix/fonts.nix { }) copyFonts linkFonts; inherit (callPackage ./nix/fonts.nix { }) copyFonts linkFonts;
inherit (callPackage ./nix/theme.nix {
theme = inputs.apollo;
themeEnabled = false;
}) copyTheme linkTheme;
in in
{ {
packages.default = with pkgs; stdenv.mkDerivation { packages.default = with pkgs; stdenv.mkDerivation {
@ -32,10 +31,7 @@
version = "2022-08-21"; version = "2022-08-21";
src = ./.; src = ./.;
nativeBuildInputs = [ optimize-images zola ]; nativeBuildInputs = [ optimize-images zola ];
configurePhase = lib.optionalString themeEnabled '' configurePhase = copyTheme + copyFonts;
mkdir -p themes/${themeName}
cp -r ${theme}/* themes/${themeName}
'' + copyFonts;
buildPhase = '' buildPhase = ''
optimize-images optimize-images
zola build zola build
@ -47,10 +43,7 @@
}; };
devShells.default = with pkgs; mkShell { devShells.default = with pkgs; mkShell {
packages = [ flyctl optimize-images zola ]; packages = [ flyctl optimize-images zola ];
shellHook = lib.optionalString themeEnabled '' shellHook = linkTheme + linkFonts;
mkdir -p themes
ln -snf "${theme}" "themes/${themeName}"
'' + linkFonts;
}; };
packages.docker = callPackage ./nix/docker.nix { site = self'.packages.default; }; packages.docker = callPackage ./nix/docker.nix { site = self'.packages.default; };
apps.deploy.program = apps.deploy.program =

14
nix/theme.nix Normal file
View File

@ -0,0 +1,14 @@
{ lib, theme, themeEnabled }:
let
themeName = ((builtins.fromTOML (builtins.readFile "${theme}/theme.toml")).name);
in
{
copyTheme = lib.optionalString themeEnabled ''
mkdir -p themes/${themeName}
cp -r ${theme}/* themes/${themeName}
'';
linkTheme = lib.optionalString themeEnabled ''
mkdir -p themes
ln -snf "${theme}" "themes/${themeName}"
'';
}