diff --git a/nixos/boxes/kelder/amogus_beep.py b/nixos/boxes/kelder/amogus_beep.py new file mode 100755 index 0000000..dfb1efa --- /dev/null +++ b/nixos/boxes/kelder/amogus_beep.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +import subprocess +import math + +# https://en.wikipedia.org/wiki/Piano_key_frequencies +def note_freq(n): + return math.pow(2, (n - 49) / 12) * 440 + +def gen_beep_command(notes, bpm): + cmd = ['beep'] + for i, (n, d) in enumerate(notes): + f = note_freq(n) + ms = (d / (bpm/60)) * 1000 + + cmd += ['-f', str(int(f)), '-l', str(int(ms))] + if i != len(notes) -1: + cmd.append('-n') + + return cmd + +# First 2 bars of https://musescore.com/user/5032516/scores/6519100 ;) +tempo = 94 +melody = [ + (52, 1/2), + (55, 1/2), + + (57, 1/2), + (58, 1/2), + (57, 1/2), + (55, 1/2), + + (52, 1+1/2), + + (50, 1/4), + (54, 1/4), + + (52, 1), +] + +def main(): + cmd = gen_beep_command(melody, tempo) + # print(' '.join(cmd)) + subprocess.check_call(cmd) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/nixos/boxes/kelder/boot.nix b/nixos/boxes/kelder/boot.nix new file mode 100644 index 0000000..26c31fe --- /dev/null +++ b/nixos/boxes/kelder/boot.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: { + boot.plymouth = { + enable = true; + }; + + systemd.services = { + amogus-beep = { + enable = true; + description = "amogus sus"; + before = [ "plymouth-quit.service" ]; + + path = with pkgs; [ beep ]; + serviceConfig = { + RemainAfterExit = true; + ExecStart = "${pkgs.python3}/bin/python ${./amogus_beep.py}"; + Type = "oneshot"; + }; + + wantedBy = [ "multi-user.target" ]; + }; + }; +} diff --git a/nixos/boxes/kelder/default.nix b/nixos/boxes/kelder/default.nix index d2b6be8..13ae521 100644 --- a/nixos/boxes/kelder/default.nix +++ b/nixos/boxes/kelder/default.nix @@ -9,90 +9,94 @@ inherit (lib) mkIf mkMerge mkForce; in { - hardware = { - enableRedistributableFirmware = true; - cpu = { - intel.updateMicrocode = true; - }; - }; + imports = [ ./boot.nix ]; - boot = { - loader = { - efi.canTouchEfiVariables = true; - timeout = 5; - }; - kernelPackages = pkgs.linuxKernel.packages.linux_6_1; - kernelModules = [ "kvm-intel" ]; - kernelParams = [ "intel_iommu=on" ]; - initrd = { - availableKernelModules = [ "xhci_pci" "nvme" "ahci" "usbhid" "usb_storage" "sd_mod" ]; - kernelModules = [ "dm-snapshot" ]; - }; - }; - - fileSystems = { - "/boot" = { - device = "/dev/disk/by-partuuid/cba48ae7-ad2f-1a44-b5c7-dcbb7bebf8c4"; - fsType = "vfat"; - }; - "/nix" = { - device = "/dev/ssd/nix"; - fsType = "ext4"; - }; - "/persist" = { - device = "/dev/ssd/persist"; - fsType = "ext4"; - neededForBoot = true; - }; - }; - - services = { - fstrim.enable = true; - lvm = { - boot.thin.enable = true; - dmeventd.enable = true; - }; - getty = { - greetingLine = ''Welcome to ${config.system.nixos.distroName} ${config.system.nixos.label} (\m) - \l''; - helpLine = "\nCall Jack for help."; - }; - }; - - networking = { - domain = lib.my.kelder.domain; - }; - - system.nixos.distroName = "KelderOS"; - - systemd = { - network = { - links = { - "10-et1g0" = { - matchConfig.MACAddress = "74:d4:35:e9:a1:73"; - linkConfig.Name = "et1g0"; - }; + config = { + hardware = { + enableRedistributableFirmware = true; + cpu = { + intel.updateMicrocode = true; }; - networks = { - "50-lan" = { - matchConfig.Name = "et1g0"; - DHCP = "yes"; + }; + + boot = { + loader = { + efi.canTouchEfiVariables = true; + timeout = 5; + }; + kernelPackages = pkgs.linuxKernel.packages.linux_6_1; + kernelModules = [ "kvm-intel" ]; + kernelParams = [ "intel_iommu=on" ]; + initrd = { + availableKernelModules = [ "xhci_pci" "nvme" "ahci" "usbhid" "usb_storage" "sd_mod" ]; + kernelModules = [ "dm-snapshot" "pcspkr" ]; + }; + }; + + fileSystems = { + "/boot" = { + device = "/dev/disk/by-partuuid/cba48ae7-ad2f-1a44-b5c7-dcbb7bebf8c4"; + fsType = "vfat"; + }; + "/nix" = { + device = "/dev/ssd/nix"; + fsType = "ext4"; + }; + "/persist" = { + device = "/dev/ssd/persist"; + fsType = "ext4"; + neededForBoot = true; + }; + }; + + services = { + fstrim.enable = true; + lvm = { + boot.thin.enable = true; + dmeventd.enable = true; + }; + getty = { + greetingLine = ''Welcome to ${config.system.nixos.distroName} ${config.system.nixos.label} (\m) - \l''; + helpLine = "\nCall Jack for help."; + }; + }; + + networking = { + domain = lib.my.kelder.domain; + }; + + system.nixos.distroName = "KelderOS"; + + systemd = { + network = { + links = { + "10-et1g0" = { + matchConfig.MACAddress = "74:d4:35:e9:a1:73"; + linkConfig.Name = "et1g0"; + }; + }; + networks = { + "50-lan" = { + matchConfig.Name = "et1g0"; + DHCP = "yes"; + }; }; }; }; - }; - my = { - user = { - config.name = "kontent"; + my = { + user = { + config.name = "kontent"; + }; + + #deploy.generate.system.mode = "boot"; + deploy.node.hostname = "10.16.9.21"; + secrets = { + key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOFvUdJshXkqmchEgkZDn5rgtZ1NO9vbd6Px+S6YioWi"; + }; + + server.enable = true; }; - - #deploy.generate.system.mode = "boot"; - deploy.node.hostname = "10.16.9.21"; - secrets = { - key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOFvUdJshXkqmchEgkZDn5rgtZ1NO9vbd6Px+S6YioWi"; - }; - - server.enable = true; }; }; };