1
0
mirror of https://github.com/kmein/niveum synced 2026-03-22 04:41:07 +01:00

5 Commits

Author SHA1 Message Date
a744ed593b home-assistant: enable bluetooth 2024-07-10 12:57:19 +02:00
c9a83021a9 ful: host openapi test server 2024-07-10 12:57:07 +02:00
bea8f8c150 chore: update 2024-07-10 12:56:55 +02:00
c1bdb5e422 i3: delay unicode paste 2024-07-10 10:39:45 +02:00
6e82ef3b5a move back to zaatar 2024-07-10 10:27:30 +02:00
12 changed files with 207 additions and 128 deletions

View File

@@ -180,10 +180,10 @@ in {
colors = let
background = config.lib.stylix.colors.withHashtag.base00;
in {
unfocused = {
border = lib.mkForce background;
childBorder = lib.mkForce background;
};
# unfocused = {
# border = lib.mkForce background;
# childBorder = lib.mkForce background;
# };
};
keybindings =
lib.listToAttrs (map (x: lib.nameValuePair "${modifier}+Shift+${toString x}" "move container to workspace ${toString x}") (lib.range 1 9))
@@ -234,7 +234,7 @@ in {
"${modifier}+p" = "exec rofi-pass";
"${modifier}+Shift+p" = "exec rofi-pass --insert";
"${modifier}+u" = "exec ${niveumPackages.unicodmenu}/bin/unicodmenu";
"${modifier}+Shift+u" = "exec ${pkgs.writers.writeDash "last-unicode" ''${pkgs.xdotool}/bin/xdotool type "$(${pkgs.gawk}/bin/awk 'END{print $1}' ~/.cache/unicodmenu)"''}";
"${modifier}+Shift+u" = "exec ${pkgs.writers.writeDash "last-unicode" ''${pkgs.xdotool}/bin/xdotool type --delay 1000 "$(${pkgs.gawk}/bin/awk 'END{print $1}' ~/.cache/unicodmenu)"''}";
"${modifier}+F7" = "exec ${pkgs.writers.writeDash "showkeys-toggle" ''
if ${pkgs.procps}/bin/pgrep screenkey; then

75
flake.lock generated
View File

@@ -12,11 +12,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1716561646,
"narHash": "sha256-UIGtLO89RxKt7RF2iEgPikSdU53r6v/6WYB0RW3k89I=",
"lastModified": 1720546205,
"narHash": "sha256-boCXsjYVxDviyzoEyAk624600f3ZBo/DKtUdvMTpbGY=",
"owner": "ryantm",
"repo": "agenix",
"rev": "c2fc0762bbe8feb06a2e59a364fa81b3a57671c9",
"rev": "de96bd907d5fbc3b14fc33ad37d1b9a3cb15edc6",
"type": "github"
},
"original": {
@@ -154,15 +154,15 @@
"base16-vim": {
"flake": false,
"locked": {
"lastModified": 1663659192,
"narHash": "sha256-uJvaYYDMXvoo0fhBZUhN8WBXeJ87SRgof6GEK2efFT0=",
"owner": "chriskempson",
"lastModified": 1716150083,
"narHash": "sha256-ZMhnNmw34ogE5rJZrjRv5MtG3WaqKd60ds2VXvT6hEc=",
"owner": "tinted-theming",
"repo": "base16-vim",
"rev": "3be3cd82cd31acfcab9a41bad853d9c68d30478d",
"rev": "6e955d704d046b0dc3e5c2d68a2a6eeffd2b5d3d",
"type": "github"
},
"original": {
"owner": "chriskempson",
"owner": "tinted-theming",
"repo": "base16-vim",
"type": "github"
}
@@ -522,11 +522,11 @@
]
},
"locked": {
"lastModified": 1716736833,
"narHash": "sha256-rNObca6dm7Qs524O4st8VJH6pZ/Xe1gxl+Rx6mcWYo0=",
"lastModified": 1720042825,
"narHash": "sha256-A0vrUB6x82/jvf17qPCpxaM+ulJnD8YZwH9Ci0BsAzE=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "a631666f5ec18271e86a5cde998cba68c33d9ac6",
"rev": "e1391fb22e18a36f57e6999c7a9f966dc80ac073",
"type": "github"
},
"original": {
@@ -961,11 +961,11 @@
},
"nixpkgs-unstable_2": {
"locked": {
"lastModified": 1717349865,
"narHash": "sha256-L2c9eFbDDJ+JXoDOs1wS5PAFzpNbNZlDwkik6ZQjeCc=",
"lastModified": 1720600445,
"narHash": "sha256-C5l91ZzB3M1WnunJEbQgOZBjB+o6IwhgoCKqCs3CqdI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "61c9a947dc4e36bef442007f7203f102b7e9ed0b",
"rev": "3a9671961fd9481564092656e1ccb5f8fdf2ded4",
"type": "github"
},
"original": {
@@ -1054,11 +1054,11 @@
},
"nixpkgs_7": {
"locked": {
"lastModified": 1717144377,
"narHash": "sha256-F/TKWETwB5RaR8owkPPi+SPJh83AQsm6KrQAlJ8v/uA=",
"lastModified": 1720386169,
"narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "805a384895c696f802a9bf5bf4720f37385df547",
"rev": "194846768975b7ad2c4988bdb82572c00222c0d7",
"type": "github"
},
"original": {
@@ -1210,11 +1210,11 @@
},
"nur_2": {
"locked": {
"lastModified": 1717346712,
"narHash": "sha256-QjFwg6M1dBj+2DhTvDOhvvybvSxXK0fJn1FuqbWhi1o=",
"lastModified": 1720599945,
"narHash": "sha256-7g4dA58n7SLnyc/Iy6eboxb4KTtcxdXBh5pYZ9VJFgU=",
"owner": "nix-community",
"repo": "NUR",
"rev": "8587d6c2d6bef3775387336a8456702789cbfb0b",
"rev": "2b1c51b160c4514bae6d4e57dafbce695ada9d38",
"type": "github"
},
"original": {
@@ -1292,11 +1292,11 @@
},
"retiolum_2": {
"locked": {
"lastModified": 1715540413,
"narHash": "sha256-K2JRa9OrnA1ypL4CWJpe6/23EM5nqY6YF3MkATTW7jA=",
"lastModified": 1719907580,
"narHash": "sha256-arE8H5HXoPwcjQXnUH1pmnh2pi37+5hXjo4UPpYJ7FY=",
"ref": "refs/heads/master",
"rev": "e847829a0d491fa85e6a083ed634d461e5779d5c",
"revCount": 340,
"rev": "7e5194b7aba337bc06b5a33738284ef98eef6cbf",
"revCount": 342,
"type": "git",
"url": "https://git.thalheim.io/Mic92/retiolum"
},
@@ -1377,19 +1377,16 @@
},
"rust-overlay_2": {
"inputs": {
"flake-utils": [
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1717294752,
"narHash": "sha256-QhlS52cEQyx+iVcgrEoCnEEpWUA6uLdmeLRxk935inI=",
"lastModified": 1720577957,
"narHash": "sha256-RZuzLdB/8FaXaSzEoWLg3au/mtbuH7MGn2LmXUKT62g=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "b46857a406d207a1de74e792ef3b83e800c30e08",
"rev": "a434177dfcc53bf8f1f348a3c39bfb336d760286",
"type": "github"
},
"original": {
@@ -1443,11 +1440,11 @@
]
},
"locked": {
"lastModified": 1701811923,
"narHash": "sha256-t9yJn8/K5d+p8vwRNjX3hG5lq40pc8MPR2QlbXM/lCc=",
"lastModified": 1718229935,
"narHash": "sha256-WvnKr7sB8DiCVc5e0odYgeX119RmtpX8RYtyQVyVgyo=",
"owner": "kmein",
"repo": "scripts",
"rev": "3ba064bdedeedd4ad524f91b9fac9caf38386f17",
"rev": "cebd116b9e8ef98a71af7090155fb72508435cb0",
"type": "github"
},
"original": {
@@ -1505,11 +1502,11 @@
]
},
"locked": {
"lastModified": 1717268716,
"narHash": "sha256-hKM/D6Ni3+Ihvmy8pF+rOFgIqhphOEHUWqxJd+5ZV6Y=",
"lastModified": 1719525570,
"narHash": "sha256-xSO/H67GAHEW0siD2PHoO/e97MbROL3r3s5SpF6A6Dc=",
"owner": "danth",
"repo": "stylix",
"rev": "3befd5d693a2669dc7d2086b57298838ff71f24b",
"rev": "1ff9d37d27377bfe8994c24a8d6c6c1734ffa116",
"type": "github"
},
"original": {
@@ -1693,11 +1690,11 @@
"voidrice_2": {
"flake": false,
"locked": {
"lastModified": 1716485119,
"narHash": "sha256-ZVqQNyjzibAhUYuUkyH481iTjnIo0R8+cJT8ln2Ui1Q=",
"lastModified": 1717360847,
"narHash": "sha256-fqWdhRsy/BIf343TAqOJ2l/+3Wd/6/FQvk5WoR1vMiE=",
"owner": "Lukesmithxyz",
"repo": "voidrice",
"rev": "c95a16916d5c71288e5e49a78d0621943c89a682",
"rev": "475e4abb4084008198f1d9a23de6450e02b074a9",
"type": "github"
},
"original": {

View File

@@ -205,6 +205,7 @@
agenix.nixosModules.default
inputs.self.nixosModules.passport
inputs.self.nixosModules.panoptikon
inputs.self.nixosModules.htgen
retiolum.nixosModules.retiolum
nur.nixosModules.nur
{

Submodule secrets updated: 0fe64633ae...a4e26dd9df

View File

@@ -1,6 +1,7 @@
{
config,
pkgs,
lib,
...
}: let
inherit (import ../../lib) kieran retiolumAddresses restic;
@@ -74,7 +75,7 @@ in {
systemd.services.servant = {
enable = true;
environment.PORT = toString 18987;
environment.VIRTUAL_HOST = "openapiaiapi.kmein.de";
environment.VIRTUAL_HOST = "https://openapiaiapi.kmein.de";
serviceConfig.ExecStart = pkgs.writers.writeHaskell "server" {
libraries = with pkgs.haskellPackages; [
servant
@@ -94,9 +95,33 @@ in {
serviceConfig.Group = "servant";
};
services.htgen.openapi-conversion = {
port = 18988;
script = ''. ${pkgs.writers.writeDash "openapi-conversion" ''
case "$Method $Request_URI" in
"GET /openapi-3.1.json")
schema=$(mktemp -d)
trap 'rm -rf $schema' EXIT
${pkgs.wget}/bin/wget http://127.0.0.1:${toString 18987}/openapi.json -O "$schema"/openapi.json
cat "$schema"/openapi.json >&2
PATH=${lib.makeBinPath [pkgs.bashInteractive pkgs.nodejs]} ${pkgs.nodejs}/bin/npx --yes openapi-format "$schema"/openapi.json --convertTo "3.1" -o "$schema"/openapi-new.json
printf 'HTTP/1.1 200 OK\r\n'
printf 'Content-Type: %s\r\n' "$(${pkgs.file}/bin/file -ib "$schema"/openapi-new.json)"
printf 'Server: %s\r\n' "$Server"
printf 'Connection: close\r\n'
printf 'Content-Length: %d\r\n' $(${pkgs.coreutils}/bin/wc -c < "$schema"/openapi-new.json)
printf '\r\n'
cat "$schema"/openapi-new.json
exit
;;
esac
''}'';
};
services.nginx.virtualHosts."openapiaiapi.kmein.de" = {
enableACME = true;
forceSSL = true;
locations."/openapi-3.1.json".proxyPass = "http://127.0.0.1:${toString 18988}";
locations."/".proxyPass = "http://127.0.0.1:${toString 18987}";
};

View File

@@ -3,22 +3,15 @@
pkgs,
...
}: let
inherit (import ../../lib) retiolumAddresses restic;
inherit (import ../../lib) retiolumAddresses;
in {
imports = [
./hardware-configuration.nix
./home-assistant.nix
./backup.nix
./atuin.nix
../../configs/spacetime.nix
../../configs/sshd.nix
../../configs/printing.nix
../../configs/monitoring.nix
../../configs/tmux.nix
../../configs/retiolum.nix
../../configs/nix.nix
../../configs/admin-essentials.nix
../../configs/wpa_supplicant.nix
];
age.secrets = {
@@ -34,40 +27,47 @@ in {
owner = "tinc-retiolum";
group = "tinc-retiolum";
};
restic = {
file = ../../secrets/restic.age;
mode = "400";
owner = "restic";
group = "restic";
};
console.keyMap = "de";
i18n.defaultLocale = "de_DE.UTF-8";
services.xserver = {
layout = "de";
libinput.enable = true;
};
users.users.xenos = {
name = "xenos";
password = "xenos";
isNormalUser = true;
extraGroups = ["networkmanager"];
};
services.xserver = {
enable = true;
desktopManager.pantheon.enable = true;
displayManager = {
lightdm = {
enable = true;
greeters.pantheon.enable = true;
};
autoLogin = {
enable = true;
user = "xenos";
};
};
};
boot.plymouth.enable = true;
services.restic.backups.niveum = {
initialize = true;
inherit (restic) repository;
timerConfig = {
OnCalendar = "daily";
RandomizedDelaySec = "1h";
};
passwordFile = config.age.secrets.restic.path;
paths = [
"/var/lib/moodle-dl"
"/var/lib/containers/storage/volumes/home-assistant"
config.services.postgresqlBackup.location
];
};
services.logind = {
lidSwitch = "ignore";
lidSwitchDocked = "ignore";
lidSwitchExternalPower = "ignore";
suspendKey = "ignore";
suspendKeyLongPress = "ignore";
hibernateKey = "ignore";
hibernateKeyLongPress = "ignore";
};
services.illum.enable = true;
environment.systemPackages = [
pkgs.libreoffice
pkgs.gimp
pkgs.inkscape
pkgs.firefox
pkgs.audacity
pkgs.pidgin
pkgs.git
];
networking = {
useDHCP = false;

View File

@@ -1,39 +0,0 @@
{config, ...}: let
port = 8123;
inherit (import ../../lib) restic;
volumeName = "home-assistant";
in {
networking.firewall.allowedTCPPorts = [port];
services.nginx.virtualHosts."home.kmein.r" = {
locations."/" = {
proxyPass = "http://127.0.0.1:${toString port}";
};
};
services.restic.backups.niveum = {
initialize = true;
inherit (restic) repository;
timerConfig = {
OnCalendar = "daily";
RandomizedDelaySec = "1h";
};
passwordFile = config.age.secrets.restic.path;
paths = [
"/var/lib/containers/storage/volumes/${volumeName}"
];
};
virtualisation.oci-containers = {
backend = "podman";
containers.homeassistant = {
volumes = ["${volumeName}:/config"];
environment.TZ = "Europe/Berlin";
image = "ghcr.io/home-assistant/home-assistant:stable";
extraOptions = [
"--network=host"
"--device=/dev/ttyACM0:/dev/ttyACM0" # Example, change this to match your own hardware
];
};
};
}

View File

@@ -91,5 +91,5 @@ in {
retiolum = retiolumAddresses.zaatar;
};
system.stateVersion = "22.05";
system.stateVersion = "23.11";
}

View File

@@ -22,16 +22,18 @@
fileSystems = {
"/" = {
device = "/dev/disk/by-label/nixos";
device = "/dev/disk/by-uuid/5dcaa7fe-08e7-46a6-ac93-b267eeb144eb";
fsType = "ext4";
};
"/boot" = {
device = "/dev/disk/by-label/boot";
device = "/dev/disk/by-uuid/CE3B-F4C6";
fsType = "vfat";
};
};
swapDevices = [{device = "/dev/disk/by-label/swap";}];
swapDevices =
[ { device = "/dev/disk/by-uuid/7b2a3e4c-e53f-4c53-b599-b6d6cff49f1f"; }
];
nix.settings.max-jobs = lib.mkDefault 4;
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";

View File

@@ -0,0 +1,93 @@
{config, pkgs, lib, ...}: let
port = 8123;
inherit (import ../../lib) restic;
volumeName = "home-assistant";
streams = import ../../lib/streams.nix {
di-fm-key = "%DI_FM_KEY%"; # TODO lib.strings.fileContents <secrets/di.fm/key>;
};
playlistDirectoryPath = "/var/lib/mpd/playlists";
in {
networking.firewall.allowedTCPPorts = [port];
services.nginx.virtualHosts."home.kmein.r" = {
locations."/" = {
proxyPass = "http://127.0.0.1:${toString port}";
};
};
services.restic.backups.niveum = {
initialize = true;
inherit (restic) repository;
timerConfig = {
OnCalendar = "daily";
RandomizedDelaySec = "1h";
};
passwordFile = config.age.secrets.restic.path;
paths = [
"/var/lib/containers/storage/volumes/${volumeName}"
];
};
age.secrets = {
di-fm-key.file = ../../secrets/di-fm-key.age;
};
systemd.services.mpd-playlists = {
before = ["podman-homeassistant.service"];
wantedBy = ["podman-homeassistant.service"];
script = let
tags = lib.lists.unique (lib.concatMap ({tags ? [], ...}: tags) streams);
tagStreams = tag: lib.filter ({tags ? [], ...}: lib.elem tag tags) streams;
makePlaylist = name: streams: pkgs.writeText "${name}.m3u" (lib.concatMapStringsSep "\n" (lib.getAttr "stream") streams);
playlistDirectory = pkgs.linkFarm "playlists" (
[
{
name = "all.m3u";
path = makePlaylist "all" streams;
}
]
++ map (tag: {
name = "${tag}.m3u";
path = makePlaylist tag (tagStreams tag);
})
tags
);
in ''
mkdir -p ${playlistDirectoryPath}
export DI_FM_KEY="$(cat "$CREDENTIALS_DIRECTORY/di-fm-key")"
rm -rf ${playlistDirectoryPath}
mkdir ${playlistDirectoryPath}
for m3u in $(ls ${playlistDirectory})
do
${pkgs.gnused}/bin/sed s/%DI_FM_KEY%/"$DI_FM_KEY"/g ${playlistDirectory}/"$m3u" > ${playlistDirectoryPath}/"$(basename "$m3u")"
done
'';
serviceConfig = {
LoadCredential = [
"di-fm-key:${config.age.secrets.di-fm-key.path}"
];
};
};
hardware.bluetooth.enable = true;
virtualisation.oci-containers = {
backend = "podman";
containers.homeassistant = {
volumes = [
"${volumeName}:/config"
"${playlistDirectoryPath}:/media"
"/run/dbus:/run/dbus:ro"
];
environment.TZ = "Europe/Berlin";
image = "ghcr.io/home-assistant/home-assistant:stable";
extraOptions = [
"--network=host"
"--device=/dev/ttyACM0:/dev/ttyACM0" # Example, change this to match your own hardware
];
};
};
}