From e8a2567cef4851c051db12532d17f76486fdbe37 Mon Sep 17 00:00:00 2001 From: mat ess Date: Sat, 27 Aug 2022 14:42:04 -0400 Subject: [PATCH] Move theme config to separate file --- flake.nix | 19 ++++++------------- nix/theme.nix | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 nix/theme.nix diff --git a/flake.nix b/flake.nix index 8f9b0c3..6aec350 100644 --- a/flake.nix +++ b/flake.nix @@ -12,11 +12,6 @@ }; 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; } { imports = [ ]; systems = inputs.nixpkgs.lib.systems.flakeExposed; @@ -25,6 +20,10 @@ inherit (pkgs) callPackage; optimize-images = callPackage ./nix/optimize-images.nix { }; inherit (callPackage ./nix/fonts.nix { }) copyFonts linkFonts; + inherit (callPackage ./nix/theme.nix { + theme = inputs.apollo; + themeEnabled = false; + }) copyTheme linkTheme; in { packages.default = with pkgs; stdenv.mkDerivation { @@ -32,10 +31,7 @@ version = "2022-08-21"; src = ./.; nativeBuildInputs = [ optimize-images zola ]; - configurePhase = lib.optionalString themeEnabled '' - mkdir -p themes/${themeName} - cp -r ${theme}/* themes/${themeName} - '' + copyFonts; + configurePhase = copyTheme + copyFonts; buildPhase = '' optimize-images zola build @@ -47,10 +43,7 @@ }; devShells.default = with pkgs; mkShell { packages = [ flyctl optimize-images zola ]; - shellHook = lib.optionalString themeEnabled '' - mkdir -p themes - ln -snf "${theme}" "themes/${themeName}" - '' + linkFonts; + shellHook = linkTheme + linkFonts; }; packages.docker = callPackage ./nix/docker.nix { site = self'.packages.default; }; apps.deploy.program = diff --git a/nix/theme.nix b/nix/theme.nix new file mode 100644 index 0000000..b04cd6f --- /dev/null +++ b/nix/theme.nix @@ -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}" + ''; +}