From 0a32439a4cb4ba09fcd361079653914105f7ec8f Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Sat, 18 Mar 2023 08:16:25 +0100 Subject: [PATCH] add home-status.html --- flake.nix | 3 +- .../gui/home-manager/doom-emacs.nix | 2 +- nixos/machines/cream/packages.nix | 1 + nixos/machines/pepe/configuration.nix | 2 + nixos/machines/pepe/home-display.nix | 40 +++++++++++++++++++ nixos/system/desktop/yubikey.nix | 3 +- 6 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 nixos/machines/pepe/home-display.nix diff --git a/flake.nix b/flake.nix index d5d10cf..9692ddc 100644 --- a/flake.nix +++ b/flake.nix @@ -150,6 +150,7 @@ }; specialArgs = { inherit private_assets; + assets = ./nixos/assets; }; }; @@ -261,7 +262,7 @@ nixos-hardware.nixosModules.common-gpu-intel ]; home-manager.users.root = { - home.stateVersion = "22.11"; + home.stateVersion = "22.11"; imports = [ doom-emacs-nix.hmModule ]; diff --git a/nixos/components/gui/home-manager/doom-emacs.nix b/nixos/components/gui/home-manager/doom-emacs.nix index 389cdb2..38fbe55 100644 --- a/nixos/components/gui/home-manager/doom-emacs.nix +++ b/nixos/components/gui/home-manager/doom-emacs.nix @@ -4,7 +4,7 @@ home-manager.users.mainUser = { programs.doom-emacs = { enable = lib.mkDefault true; - doomPrivateDir = ../../../doom.d; + doomPrivateDir = ../../../../doom.d; extraConfig = '' ;; "monospace" means use the system default. However, the default is usually two ;; points larger than I'd like, so I specify size 12 here. diff --git a/nixos/machines/cream/packages.nix b/nixos/machines/cream/packages.nix index 8b7c18d..3a45e5f 100644 --- a/nixos/machines/cream/packages.nix +++ b/nixos/machines/cream/packages.nix @@ -104,6 +104,7 @@ in bitwarden sensu-go-cli + yq-go ]; diff --git a/nixos/machines/pepe/configuration.nix b/nixos/machines/pepe/configuration.nix index 2e87b93..c9ec45d 100644 --- a/nixos/machines/pepe/configuration.nix +++ b/nixos/machines/pepe/configuration.nix @@ -31,6 +31,8 @@ ./grafana.nix ./telegraf.nix + ./home-display.nix + ]; sops.defaultSopsFile = ../../secrets/pepe.yaml; diff --git a/nixos/machines/pepe/home-display.nix b/nixos/machines/pepe/home-display.nix new file mode 100644 index 0000000..b33f32f --- /dev/null +++ b/nixos/machines/pepe/home-display.nix @@ -0,0 +1,40 @@ +{ lib, pkgs, config, assets, ... }: +{ + + networking.firewall.allowedTCPPorts = [ 80 ]; + networking.firewall.allowedUDPPorts = [ 80 ]; + + services.nginx.virtualHosts."${config.networking.hostName}.private" = { + locations."= /home-status.html".alias = "/srv/home-status/index.html"; + }; + + systemd.services.home-status-refresh = { + enable = true; + script = + let + mustache = "${pkgs.mustache-go}/bin/mustache"; + jq = "${pkgs.jq}/bin/jq"; + index_html_template = refreshSeconds: pkgs.writeText "index_html.template" '' + + + {{ date }} + + ''; + in + + '' + ${jq} --raw-input '.' <(date +"%Y-%m-%d %H:%M";echo "hallo") \ + | ${jq} --slurp '{ date : .[0], test : .[1] }' \ + | ${mustache} ${index_html_template 60} > /srv/home-status/index.html + ''; + }; + + systemd.timers.home-status-refresh = { + enable = true; + # man systemd.time + timerConfig.OnCalendar = "minutely"; + wantedBy = [ "multi-user.target" ]; + }; + +} + diff --git a/nixos/system/desktop/yubikey.nix b/nixos/system/desktop/yubikey.nix index 25542da..7eefefc 100644 --- a/nixos/system/desktop/yubikey.nix +++ b/nixos/system/desktop/yubikey.nix @@ -50,8 +50,7 @@ # use for pam (sudo) # -------------------------- security.pam.u2f.enable = true; - security.pam.u2f.authFile = - toString config.sops.secrets.yubikey_u2fAuthFile.path; + security.pam.u2f.authFile = toString config.sops.secrets.yubikey_u2fAuthFile.path; sops.secrets.yubikey_u2fAuthFile = { }; }