Make module more general
This commit is contained in:
parent
97a064b5fc
commit
759f2b4bf1
|
@ -17,7 +17,7 @@
|
||||||
in {
|
in {
|
||||||
packages = forAllSystems (system: pkgs: {
|
packages = forAllSystems (system: pkgs: {
|
||||||
default = self.packages.${system}.gitea-theme-monokai;
|
default = self.packages.${system}.gitea-theme-monokai;
|
||||||
gitea-theme-monokai = pkgs.callPackage ./default.nix { };
|
gitea-theme-monokai = pkgs.callPackage ./themes/monokai { };
|
||||||
|
|
||||||
test-machine = let
|
test-machine = let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
|
@ -35,10 +35,10 @@
|
||||||
system.stateVersion = "23.11";
|
system.stateVersion = "23.11";
|
||||||
boot.isContainer = true;
|
boot.isContainer = true;
|
||||||
}
|
}
|
||||||
{
|
({pkgs, ... }: {
|
||||||
services.gitea.enable = true;
|
services.gitea.enable = true;
|
||||||
services.gitea-themes.monokai.enable = true;
|
services.gitea-themes."monokai" = pkgs.gitea-theme-monokai;
|
||||||
}
|
})
|
||||||
];
|
];
|
||||||
}).config.system.build.toplevel;
|
}).config.system.build.toplevel;
|
||||||
});
|
});
|
||||||
|
|
34
module.nix
34
module.nix
|
@ -1,22 +1,27 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.services.gitea-themes.monokai;
|
cfg = config.services.gitea-themes;
|
||||||
giteaCfg = config.services.gitea;
|
giteaCfg = config.services.gitea;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.services.gitea-themes.monokai = {
|
options.services.gitea-themes = lib.mkOption {
|
||||||
enable = lib.mkEnableOption "monokai theme for gitea";
|
description = ''
|
||||||
package = lib.mkPackageOption pkgs "gitea-theme-monokai" { };
|
Derivations containing gitea themes to install.
|
||||||
|
|
||||||
|
The theme should be named `theme-<name>.css`, and reside in `$out/share/gitea/public/assets/css/`.
|
||||||
|
'';
|
||||||
|
default = { };
|
||||||
|
type = with lib.types; attrsOf path;
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf (cfg.enable && giteaCfg.enable) {
|
config = lib.mkIf (cfg != { }) {
|
||||||
services.gitea.settings.ui.THEMES = lib.strings.concatStringsSep "," [
|
services.gitea.settings.ui.THEMES = lib.strings.concatStringsSep "," ([
|
||||||
"gitea"
|
"gitea"
|
||||||
"arc-green"
|
"arc-green"
|
||||||
"monokai"
|
] ++ lib.attrNames cfg);
|
||||||
];
|
|
||||||
|
|
||||||
systemd.services.install-gitea-theme-monokai = {
|
systemd.services.install-gitea-themes = {
|
||||||
|
description = "Install gitea themes in gitea's CUSTOM_DIR";
|
||||||
wantedBy = [ "gitea.service" ];
|
wantedBy = [ "gitea.service" ];
|
||||||
requiredBy = [ "gitea.service" ];
|
requiredBy = [ "gitea.service" ];
|
||||||
|
|
||||||
|
@ -25,13 +30,10 @@ in
|
||||||
User = giteaCfg.user;
|
User = giteaCfg.user;
|
||||||
Group = giteaCfg.group;
|
Group = giteaCfg.group;
|
||||||
};
|
};
|
||||||
script = ''
|
script = lib.concatMapStringsSep "\n" ({ name, value }: ''
|
||||||
mkdir -p "${giteaCfg.customDir}/public/assets/css"
|
install -Dm444 "${value}/share/gitea/public/assets/css/theme-${name}.css" -t "${giteaCfg.customDir}/public/assets/css/"
|
||||||
if ! [ -f "${giteaCfg.customDir}/public/assets/css/theme-monokai.css" ]; then
|
install -Dm444 "${value}/share/gitea/public/assets/css/theme-${name}.css" -t "${giteaCfg.customDir}/public/css/"
|
||||||
ln -s "${cfg.package}/share/gitea/public/assets/css/theme-monokai.css" "${giteaCfg.customDir}/public/assets/css/theme-monokai.css"
|
'') (lib.attrsToList cfg);
|
||||||
ln -s "${cfg.package}/share/gitea/public/css/theme-monokai.css" "${giteaCfg.customDir}/public/css/theme-monokai.css"
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,5 +6,5 @@ runCommand "gitea-monokai-theme" {
|
||||||
buildInputs = [ lessc ];
|
buildInputs = [ lessc ];
|
||||||
} ''
|
} ''
|
||||||
mkdir $out
|
mkdir $out
|
||||||
lessc ${./theme-monokai.less} $out/share/gitea/custom/public/assets/css/theme-monokai.css
|
lessc ${./theme-monokai.less} $out/share/gitea/public/assets/css/theme-monokai.css
|
||||||
''
|
''
|
Loading…
Reference in New Issue