Skip to content

Commit

Permalink
move over to official homepage module early
Browse files Browse the repository at this point in the history
  • Loading branch information
yomaq committed Mar 28, 2024
1 parent 903e3e9 commit 415bf26
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 149 deletions.
2 changes: 1 addition & 1 deletion modules/containers/lychee.nix
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ in
tags = ["tag:generichttps"];
};

yomaq.homepage.groups.services.utilities = [{
yomaq.homepage.groups.services.services = [{
Lychee = {
icon = "si-affinityphoto";
href = "https://${hostName}-${NAME}.${tailnetName}.ts.net";
Expand Down
2 changes: 1 addition & 1 deletion modules/hosts/adGuardHome/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ in
enable = true;
allowDHCP = true;
};
yomaq.homepage.groups.services.utilities = [{
yomaq.homepage.groups.services.services = [{
DNS = {
icon = "si-adguard";
href = "{{HOMEPAGE_VAR_ADGUARD_IP}}";
Expand Down
5 changes: 2 additions & 3 deletions modules/hosts/glances/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ in
};
};


yomaq.glances.package = pkgs.unstable.glances;
services.static-web-server = {
enable = true;
root = "${dontBackup}/lastUpdate/";
};

system.activationScripts = lib.mkIf (inputs.self ? rev) {lastUpdate.text = ''
echo "{\"date\": \"$(date +"%a %m/%d %H:%M")\"," > ${dontBackup}/lastUpdate/lastUpdate.html
echo "\"commit\": \"${inputs.self.shortRev}\"}" >> ${dontBackup}/lastUpdate/lastUpdate.html
echo "{\"date\": \"$(date +"%a %m/%d %H:%M")\", \"commit\": \"${inputs.self.shortRev}\"}" > ${dontBackup}/lastUpdate/lastUpdate.html
'';
};

Expand Down
74 changes: 25 additions & 49 deletions modules/hosts/homepage/ImportFromFlake/nixos.nix
Original file line number Diff line number Diff line change
@@ -1,70 +1,50 @@
{ config, lib, pkgs, inputs, modulesPath, ... }:
let
cfg = config.yomaq.homepage;
settingsFormat = pkgs.formats.yaml { };
listOfHosts = lib.attrNames inputs.self.nixosConfigurations;
mergeConfig = configKey: lib.mkMerge (map (hostname: lib.mkIf (inputs.self.nixosConfigurations."${hostname}".config.yomaq.homepage."${configKey}" != null)
mergeConfig = configKey: lib.mkMerge (map (hostname: lib.mkIf (inputs.self.nixosConfigurations."${hostname}".config.yomaq.homepage."${configKey}" != [])
inputs.self.nixosConfigurations."${hostname}".config.yomaq.homepage."${configKey}") listOfHosts);
mergeServiceGroups = configKey: lib.mkMerge (map (hostname: lib.mkIf (inputs.self.nixosConfigurations."${hostname}".config.yomaq.homepage.groups.services."${configKey}" != [])
inputs.self.nixosConfigurations."${hostname}".config.yomaq.homepage.groups.services."${configKey}") listOfHosts);
mergeBookmarksGroups = configKey: lib.mkMerge (map (hostname: lib.mkIf (inputs.self.nixosConfigurations."${hostname}".config.yomaq.homepage.groups.bookmarks"${configKey}" != [])
inputs.self.nixosConfigurations."${hostname}".config.yomaq.homepage.groups.bookmarks"${configKey}") listOfHosts);
in
{
options.yomaq.homepage = {
settings = lib.mkOption {
default = null;
type = lib.types.nullOr (lib.types.submodule {
freeformType = (pkgs.formats.yaml { }).type;
});
};
widgets = lib.mkOption {
default = null;
type = lib.types.nullOr (lib.types.listOf (lib.types.submodule {
freeformType = (pkgs.formats.yaml { }).type;
}));
bookmarks = lib.mkOption {
inherit (settingsFormat) type;
default = [ ];
};
services = lib.mkOption {
default = null;
type = lib.types.nullOr (lib.types.listOf (lib.types.submodule {
freeformType = (pkgs.formats.yaml { }).type;
}));
inherit (settingsFormat) type;
default = [ ];
};
bookmarks = lib.mkOption {
default = null;
type = lib.types.nullOr (lib.types.listOf (lib.types.submodule {
freeformType = (pkgs.formats.yaml { }).type;
}));
widgets = lib.mkOption {
inherit (settingsFormat) type;
default = [ ];
};
settings = lib.mkOption {
inherit (settingsFormat) type;
default = { };
};
};
options.yomaq.homepage.groups = {
services = {
favorites =lib.mkOption {
default = null;
type = lib.types.nullOr (lib.types.listOf (lib.types.submodule {
freeformType = (pkgs.formats.yaml { }).type;
}));
};
utilities =lib.mkOption {
default = null;
type = lib.types.nullOr (lib.types.listOf (lib.types.submodule {
freeformType = (pkgs.formats.yaml { }).type;
}));
services =lib.mkOption {
inherit (settingsFormat) type;
default = [];
};
};
bookmarks = {
favorites =lib.mkOption {
default = null;
type = lib.types.nullOr (lib.types.listOf (lib.types.submodule {
freeformType = (pkgs.formats.yaml { }).type;
}));
};
utilities =lib.mkOption {
default = null;
type = lib.types.nullOr (lib.types.listOf (lib.types.submodule {
freeformType = (pkgs.formats.yaml { }).type;
}));
inherit (settingsFormat) type;
default = [];
};
};
};
config = lib.mkIf config.yomaq.homepage-dashboard.enable {
yomaq.homepage-dashboard = {
listenPort = 3000;
settings = mergeConfig "settings";
widgets = mergeConfig "widgets";
services = mergeConfig "services";
Expand All @@ -86,14 +66,10 @@ in
### Empty lists will break the config
### Also add the layout for the group below.
services = [
{ Services = lib.mkMerge (map (hostname: lib.mkIf (inputs.self.nixosConfigurations."${hostname}".config.yomaq.homepage.groups.services.utilities != null)
inputs.self.nixosConfigurations."${hostname}".config.yomaq.homepage.groups.services.utilities) listOfHosts);}
{ Services = mergeServiceGroups "services"; }
];
bookmarks = [
# { favorites = lib.mkMerge (map (hostname: lib.mkIf (inputs.self.nixosConfigurations."${hostname}".config.yomaq.homepage.groups.bookmarks.favorites != null)
# inputs.self.nixosConfigurations."${hostname}".config.yomaq.homepage.groups.bookmarks.favorites) listOfHosts);}
# { utilities = lib.mkMerge (map (hostname: lib.mkIf (inputs.self.nixosConfigurations."${hostname}".config.yomaq.homepage.groups.bookmarks.utilities != null)
# inputs.self.nixosConfigurations."${hostname}".config.yomaq.homepage.groups.bookmarks.utilities) listOfHosts);}
# { favorites = mergeServiceGroups "favorites"; }
];
widgets = [
{datetime = {
Expand Down
Loading

0 comments on commit 415bf26

Please sign in to comment.