From bb87af513601da2054f004b7ec1f0e702d7fd063 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Mon, 6 May 2024 15:30:10 -0500 Subject: [PATCH] completely rework rune system --- hosts/algiz/default.nix | 1 + hosts/algiz/system.nix | 7 +--- hosts/mannaz/default.nix | 1 + hosts/mannaz/system.nix | 6 --- hosts/othalan/system.nix | 15 +------ lib/default.nix | 2 - lib/extended.nix | 8 ---- modules/oizys.nix | 2 + modules/runes/default.nix | 69 +++++++++++++++++++++++++++++++-- pkgs/oizys/oizys-go/default.nix | 1 - 10 files changed, 72 insertions(+), 40 deletions(-) diff --git a/hosts/algiz/default.nix b/hosts/algiz/default.nix index 3335d3a..4958a14 100644 --- a/hosts/algiz/default.nix +++ b/hosts/algiz/default.nix @@ -13,6 +13,7 @@ "node" # for docker langservers "python" ]; + rune.motd = enabled; docker = enabled; backups = enabled; diff --git a/hosts/algiz/system.nix b/hosts/algiz/system.nix index bea7601..a52922f 100644 --- a/hosts/algiz/system.nix +++ b/hosts/algiz/system.nix @@ -1,10 +1,5 @@ -{ lib, enabled, ... }: +{ enabled, ... }: { - users.motd = lib.mkRune { - number = "6"; - rune = "algiz"; - }; - services.resolved = enabled; services.fail2ban = { diff --git a/hosts/mannaz/default.nix b/hosts/mannaz/default.nix index 8b48ed1..352e401 100644 --- a/hosts/mannaz/default.nix +++ b/hosts/mannaz/default.nix @@ -5,6 +5,7 @@ oizys = { desktop = enabled; nix-ld = enabled; + rune.motd = enabled; }; # Enable the X11 windowing system. diff --git a/hosts/mannaz/system.nix b/hosts/mannaz/system.nix index 3c219fa..5ea6b8e 100644 --- a/hosts/mannaz/system.nix +++ b/hosts/mannaz/system.nix @@ -2,15 +2,9 @@ config, pkgs, enabled, - mkRune, ... }: { - users.motd = mkRune { - number = "2"; - rune = "mannaz"; - }; - # Use the systemd-boot EFI boot loader. boot.loader = { systemd-boot = enabled; diff --git a/hosts/othalan/system.nix b/hosts/othalan/system.nix index 81232bc..3fa1306 100644 --- a/hosts/othalan/system.nix +++ b/hosts/othalan/system.nix @@ -1,9 +1,4 @@ -{ - pkgs, - enabled, - mkRune, - ... -}: +{ pkgs, enabled, ... }: { networking.networkmanager = enabled; services.printing = enabled; @@ -28,14 +23,6 @@ environment.systemPackages = with pkgs; [ pamixer ]; - services.getty = { - greetingLine = mkRune { - rune = "othalan"; - runeKind = "ascii"; - }; - helpLine = ""; - }; - networking.hostName = "othalan"; time.timeZone = "US/Central"; diff --git a/lib/default.nix b/lib/default.nix index 3cdf74a..b4f35ee 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -16,7 +16,6 @@ let mkDefaultOizysModule mkOizysModule enabled - mkRune ; inherit (lib.filesystem) listFilesRecursive; @@ -46,7 +45,6 @@ rec { mkDefaultOizysModule mkOizysModule enabled - mkRune ; }; }; diff --git a/lib/extended.nix b/lib/extended.nix index e53e045..4a064e3 100644 --- a/lib/extended.nix +++ b/lib/extended.nix @@ -7,7 +7,6 @@ let mkOption types ; - runes = import ../modules/runes; in rec { enabled = { @@ -38,13 +37,6 @@ rec { isNixFile = path: hasSuffix ".nix" path; mkIfIn = name: list: prev.mkIf (builtins.elem name list); - mkRune = - { - rune, - number ? "6", - runeKind ? "braille", - }: - "[1;3${number}m\n" + runes.${rune}.${runeKind} + "\n"; mkOizysModule = config: attr: content: { options.oizys.${attr}.enable = mkEnableOption "enable ${attr} support"; diff --git a/modules/oizys.nix b/modules/oizys.nix index 9b773cb..fc4bc90 100644 --- a/modules/oizys.nix +++ b/modules/oizys.nix @@ -5,7 +5,9 @@ in { imports = with self.nixosModules; [ users + runes nix + cli dev nvim diff --git a/modules/runes/default.nix b/modules/runes/default.nix index daa4cbc..a36bdb5 100644 --- a/modules/runes/default.nix +++ b/modules/runes/default.nix @@ -1,5 +1,68 @@ { - othalan = import ./othalan.nix; - algiz = import ./algiz.nix; - mannaz = import ./mannaz.nix; + pkgs, + config, + lib, + ... +}: +let + inherit (lib) + types + mkOption + mkIf + mkEnableOption + ; + runes = { + othalan = import ./othalan.nix; + algiz = import ./algiz.nix; + mannaz = import ./mannaz.nix; + }; + mkRune = + { + rune, + number ? "6", + runeKind ? "braille", + }: + "[1;3${number}m\n" + runes.${rune}.${runeKind} + "\n"; + cfg = config.oizys.rune; +in +{ + options.oizys = { + rune = { + enable = mkOption { + type = types.bool; + default = true; + }; + motd.enable = mkEnableOption "set rune for MOTD"; + name = mkOption { + default = config.networking.hostName; + type = types.either (types.enum (builtins.attrNames runes)) types.str; + description = "Name of rune (probabaly matches hostname)"; + }; + kind = mkOption { + type = + with types; + either (enum [ + "ascii" + "braille" + ]) str; + default = "ascii"; + }; + }; + }; + + config = + mkIf cfg.enable { + environment.etc.issue = { + source = pkgs.writeText "issue" (mkRune { + rune = cfg.name; + runeKind = cfg.kind; + }); + }; + } + // mkIf cfg.motd.enable { + users.motd = mkRune { + number = "2"; # todo: autogenerate based on hostname? + rune = cfg.name; + }; + }; } diff --git a/pkgs/oizys/oizys-go/default.nix b/pkgs/oizys/oizys-go/default.nix index 08b4280..6d0d710 100644 --- a/pkgs/oizys/oizys-go/default.nix +++ b/pkgs/oizys/oizys-go/default.nix @@ -1,5 +1,4 @@ { - installShellFiles, buildGoModule, lib,