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,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;
};
};
};