nixos/kelder: Add amogus

This commit is contained in:
Jack O'Sullivan 2023-05-13 23:45:56 +01:00
parent e5ad65c4e1
commit 875cd4e27d
3 changed files with 149 additions and 77 deletions

View File

@ -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()

View File

@ -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" ];
};
};
}

View File

@ -9,6 +9,9 @@
inherit (lib) mkIf mkMerge mkForce;
in
{
imports = [ ./boot.nix ];
config = {
hardware = {
enableRedistributableFirmware = true;
cpu = {
@ -26,7 +29,7 @@
kernelParams = [ "intel_iommu=on" ];
initrd = {
availableKernelModules = [ "xhci_pci" "nvme" "ahci" "usbhid" "usb_storage" "sd_mod" ];
kernelModules = [ "dm-snapshot" ];
kernelModules = [ "dm-snapshot" "pcspkr" ];
};
};
@ -96,4 +99,5 @@
};
};
};
};
}