contact info

This commit is contained in:
Daniel Langbein 2024-11-15 21:54:02 +01:00
parent 553a10c92d
commit 1b1f941528
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002

View File

@ -2,11 +2,47 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
# TODO: Once `lib.string.trim` is available in stable nix, remove the below.
# Copied from https://github.com/NixOS/nixpkgs/blob/5633bcff0c6162b9e4b5f1264264611e950c8ec7/lib/strings.nix#L362-L434
trim = trimWith {
start = true;
end = true;
};
trimWith =
{
start ? false,
end ? false,
}:
let
# Define our own whitespace character class instead of using
# `[:space:]`, which is not well-defined.
chars = " \t\r\n";
# To match up until trailing whitespace, we need to capture a
# group that ends with a non-whitespace character.
regex =
if start && end then
"[${chars}]*(.*[^${chars}])[${chars}]*"
else if start then
"[${chars}]*(.*)"
else if end then
"(.*[^${chars}])[${chars}]*"
else
"(.*)";
in
s:
let
# If the string was empty or entirely whitespace,
# then the regex may not match and `res` will be `null`.
res = lib.match regex s;
in
lib.optionalString (res != null) (lib.head res);
contact_name = "Daniel Langbein"; contact_name = "Daniel Langbein";
# The file `phone-number` contains only one line with our phone number, e.g. +49 0173 ... # The file `phone-number` contains only one line with our phone number, e.g. +49 0173 ...
# Be aware that the phone number will be written to the nix store in plaintext! # Be aware that the phone number will be written to the nix store in plaintext!
# TODO: strip the read string (no tailing newlines) # TODO: strip the read string (no tailing newlines)
contact_phone = (builtins.readFile ../secrets/phone-number); contact_phone = trim (builtins.readFile ../secrets/phone-number);
contact_mail = "daniel@systemli.org"; contact_mail = "daniel@systemli.org";
# https://wiki.nixos.org/wiki/Shell_Scripts # https://wiki.nixos.org/wiki/Shell_Scripts