This commit is contained in:
serenity-F 2025-01-09 20:02:31 +10:00
parent 6c180bbb00
commit 38928b05ea
40 changed files with 94 additions and 249 deletions

113
core/modules/shared/audio.nix Executable file
View file

@ -0,0 +1,113 @@
## https://nixos.wiki/wiki/Category:Audio
## https://nixos.wiki/PipeWire
## https://github.com/musnix/musnix
## https://nixos.wiki/wiki/Audio_production
{
#boot.kernelModules = [ "snd-seq" "snd-rawmidi" ];
## Can't remember what this does,
## recommended to be enabled though
security = {
rtkit.enable = true;
# realtime audio priority (initially for JACK2)
pam.loginLimits = [
{
domain = "@audio";
item = "memlock";
type = "-";
value = "unlimited";
}
{
domain = "@audio";
item = "rtprio";
type = "-";
value = "99";
}
{
domain = "@audio";
item = "nofile";
type = "soft";
value = "99999";
}
{
domain = "@audio";
item = "nofile";
type = "hard";
value = "99999";
}
];
};
services.udev = {
extraRules = ''
KERNEL=="rtc0", GROUP="audio"
KERNEL=="hpet", GROUP="audio"
'';
};
## Musnix for audio production
musnix = {
enable = true;
rtcqs.enable = true;
rtirq.enable = true;
kernel.realtime = true;
};
## Pipewire baybee
services = {
## Not using pulse directly
pulseaudio = {
enable = false;
};
pipewire = {
enable = true;
jack.enable = true;
pulse.enable = true;
alsa = {
enable = true;
support32Bit = true;
};
## Low latency config
extraConfig = {
pipewire."92-low-latency" = {
"context.properties" = {
"default.clock.rate" = 48000;
"default.clock.quantum" = 150;
"default.clock.min-quantum" = 150;
"default.clock.max-quantum" = 150;
};
};
pipewire-pulse."92-low-latency" = {
stream.properties = {
node.latency = "150/48000";
resample.quality = 1;
};
context.modules = [{
name = "libpipewire-module-protocol-pulse";
args = {
pulse = {
default.req = "150/48000";
min.req = "150/48000";
max.req = "150/48000";
min.quantum = "150/48000";
max.quantum = "150/48000";
};
};
}];
};
};
};
};
}

14
core/modules/shared/default.nix Executable file
View file

@ -0,0 +1,14 @@
{ ... }:
{
imports = [
## Semi-modularised config
./sync.nix # Syncthing and gitwatch settings
./audio.nix # Musnix and ... audio ... config
./display.nix # Display configs
./regreet.nix # Login greeter config
./packages.nix # All system-level packages here
];
}

146
core/modules/shared/display.nix Executable file
View file

@ -0,0 +1,146 @@
{ pkgs, ... }:
{
boot = {
bootspec.enable = true;
consoleLogLevel = 0;
initrd.verbose = false;
kernelParams = [
"quiet"
"splash"
"vga=current"
#"loglevel=3"
"rd.systemd.show_status=false"
"rd.udev.log_level=3"
"udev.log_priority=3"
"boot.shell_on_fail"
];
loader = {
timeout = 30;
#grub = {
#theme = "${pkgs.minimal-grub-theme}";
#backgroundColor = "#000000";
#splashImage = "path/to/image";
#font = "${pkgs.spleen}/share/fonts/spleen-32x64";
#fontSize = 16;
#};
};
plymouth = {
enable = true;
#logo = pkgs.fetchurl {
#url = "https://nixos.org/logo/nixos-hires.png";
#hash = "1ivzgd7iz0i06y36p8m5w48fd8pjqwxhdaavc0pxs7w1g7mcy5si";
#};
#font = "${pkgs.spleen}/share/fonts/spleen-32x64";
theme = "circle";
themePackages = with pkgs;
[
(adi1090x-plymouth-themes.override {
selected_themes = [ "circle" ];
})
];
#extraConfig = '''';
};
};
xdg.mime.enable =
true; # may be unneeded here as already declared in `home/desktop/xdg-mime.nix`
services = {
xserver.enable = true; # xserver still needed for xwayland stuff
};
systemd.user.targets.sway = { # To start sway related services
description = "to start sway related services";
wants = [ "graphical-session.target" ];
after = [ "graphical-session.target" ];
};
environment = {
variables = { # environment variables, duh
XDG_SESSION_TYPE = "wayland";
XDG_CURRENT_DESKTOP = "sway";
};
systemPackages = with pkgs; [
xorg.xhost # i actually dont remember what this does
## Themes
minimal-grub-theme
colloid-kde
colloid-gtk-theme
adapta-gtk-theme
adapta-kde-theme
materia-theme
materia-theme-transparent
];
};
programs = {
xwayland = { # Standard(?) xwayland implementation
enable = true;
#package = [ ];
#defaultFontPath = "/run/current-system/sw/share/X11/fonts";
};
sway = { # enable sway window manager
enable = true;
package = pkgs.swayfx;
extraPackages = [ ];
wrapperFeatures = {
gtk = true;
base = true;
};
extraSessionCommands = ''
export SDL_VIDEODRIVER=wayland
export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
export XDG_CURRENT_DESKTOP=sway
export XDG_SESSION_TYPE=wayland
'';
};
};
## I put fonts here because i didn't know where tf else to put them lol
## duplicate to home-manager config ?
fonts = {
packages = with pkgs;
[ spleen terminus_font terminus_font_ttf nerd-fonts.symbols-only ]
++ builtins.filter lib.attrsets.isDerivation
(builtins.attrValues pkgs.nerd-fonts);
fontDir.enable = true;
fontconfig = {
defaultFonts = {
serif = [ "spleen-32x64" ];
sansSerif = [ "spleen-32x64" ];
monospace = [ "TerminusTTF" ];
};
};
};
## Dunno if i did this right, but possible needed for keyring/polkit stuff ?
security.pam.services.serenity.enableGnomeKeyring = true;
programs = {
gnome-disks.enable = true; # For when bimbo needs to manage disks
seahorse.enable = true; # GTK secrets management
droidcam.enable = true; # Use android device as a webcam
obs-studio = { # screen capture, recording, and sharing
enable = true;
enableVirtualCamera = true; # virtual webcam
plugins = with pkgs.obs-studio-plugins;
[
droidcam-obs # enables droidcam integration
];
};
};
services = {
libinput.enable = true; # don't think we NEED this tbh - unsure
gvfs.enable = true; # virtual filesystem, needed this for ... something
dbus.enable = true; # dbus is for ... unsure
upower.enable = true; # no clue
udisks2.enable = true; # disk management service
gnome.gnome-keyring.enable = true; # for sudo prompts and stuff
};
}

118
core/modules/shared/packages.nix Executable file
View file

@ -0,0 +1,118 @@
{ pkgs, ... }:
{
imports = [ ];
## Activation Scripts
## - these run after using `sudo nixos-rebuild switch`
system.activationScripts.diff = {
supportsDryActivation = true; # prints diff of the store
text = ''
${pkgs.nvd}/bin/nvd --nix-bin-dir=${pkgs.nix}/bin diff \
/run/current-system "$systemConfig"
echo "Rebuild completed successfully <3"
''; # also prints a cute message
};
## Nixpkgs Settings
nixpkgs = {
config = {
allowUnfree = true;
## Place insecure packages here
permittedInsecurePackages = [ "olm-3.2.16" ];
};
## Overlays - BROKEN FOR NOW
overlays = [
## to use overlays exported from other flakes:
#neovim-nightly-overlay.overlays.default
## or define it inline, for example:
#(final: prev: {
#hi = final.hello.overrideAttrs (oldAttrs: {
#patches = [ ./change-hello-to-hi.patch ];
#});
#})
];
};
## System-level Programs
programs = {
neovim = { enable = true; }; # Neovim declared here too, just in case
fish = { enable = true; }; # A catgirl's favourite shell - NEEDS OWN NIX MODULE
git = { enable = true; }; # version control
nh = { # NixOS CLI helper
enable = true;
flake = "/home/serenity/flakes/nixdots";
};
gnupg.agent = { # For handling encryption keys
enable = true;
enableSSHSupport = true;
#pinentryPackage = [ ];
};
};
environment = {
## Environment Variables
variables = { # sets neovim to default editor in other apps
EDITOR = "nvim";
VISUAL = "nvim";
SYSTEMD_EDITOR = "nvim";
};
# Install a stub ELF loader to print an informative
# error message in the event that a user attempts
# to run an ELF binary not compiled for NixOS.
stub-ld.enable = true;
## System-level Packages
systemPackages = with pkgs; [
## Nix specific tools
nix-tree # Dependency tree viewer for nix store
nix-init # Generate nix packages from URLs
nix-index # Database for nixpkgs
nix-prefetch # provides info on a url
nix-output-monitor # Shows extra information on nix commands
## Filsesystem utilities
ddrutility # Set of tools for HDD rescure
exfatprogs # ExFAT filesystem
btrfs-progs # BTRFS filesystem
ntfs3g # NTFS filesystem
#scrounge-ntfs # NTFS data recovery
## CLI tools & utilities
fd # Find, but faster
bc # Calculator
nvd # For nixos-rebuild summary
zip # What it says on the tin
btop # System metrics and process viewer
tldr # Simpler manual pages
wget # Retrieves files over HTTP, HTTPS, and FTP
curl # Pulls data from a URL
bash # Terminal shell
file # Shows type of files
tree # Tree view of directory structure
unzip # What it says on the tin
gnupg # Create encryption keys
s-tui # Metrics and stress testing
udiskie # Disk automount
busybox # Utilities
ripgrep # Searches files for a given input
killall # Kills all
usbutils # USB utils
pciutils # PCI utils
moreutils # Woah, even more utils
libsecret # Library for storing and retrieving secrets
git-crypt # Transparent file encryption in git
undervolt # Utility to change CPU settings
android-tools # Commands for interfacing with android devices
smartmontools # Tools for monitoring HDD health
magic-wormhole # Direct file sharing
];
};
}

80
core/modules/shared/regreet.nix Executable file
View file

@ -0,0 +1,80 @@
{ pkgs, ... }:
let
swayConfig = pkgs.writeText "greetd-sway-config" ''
# `-l` activates layer-shell mode. Notice that `swaymsg exit` will run after gtkgreet.
exec "${pkgs.greetd.gtkgreet}/bin/gtkgreet -l; swaymsg exit"
bindsym Mod4+shift+e exec swaynag \
-t warning \
-m 'What do you want to do?' \
-b 'Poweroff' 'systemctl poweroff' \
-b 'Reboot' 'systemctl reboot'
'';
in
{
services = {
## Eventual login greeter/display manager,
## wayland native. ReGreet on top of greetd.
greetd = {
enable = true;
#package = [ ];
restart = true;
settings = {
default_session = {
command = "${pkgs.sway}/bin/sway --config ${swayConfig}";
};
};
};
};
environment = {
etc."greetd/environments".text = ''
sway
fish
'';
};
## ReGreet specific configuration and theme
programs.regreet = {
enable = true;
#package = [ ];
#cageArgs = [ "-s" "-m" "last" ];
#settings = { };
font = {
name = "Spleen-32x64";
size = 10;
package = pkgs.spleen;
};
theme = {
name = "adwaita-dark";
package = pkgs.adw-gtk3;
};
#extraCss = "";
iconTheme = {
name = "Flat-Remix-Grey-Darkest";
package = pkgs.flat-remix-icon-theme;
};
cursorTheme = {
name = "Bibata-Modern-Classic";
package = pkgs.bibata-cursors;
};
};
}

108
core/modules/shared/sync.nix Executable file
View file

@ -0,0 +1,108 @@
# https://github.com/gitwatch/gitwatch
# https://nixos.wiki/wiki/Syncthing
{ pkgs, primaryUser, homeDir, ... }:
{
environment = {
systemPackages = with pkgs; [
gitwatch # automatic git versioning
syncthing # standard syncthing package
#syncthing-tray # tray applet for syncthing
];
};
services = {
## Gitwatch
gitwatch = {
Keyring = { # keyring backup, dont have a nextcloud (yet)
enable = true;
user = "${primaryUser}";
path = "${homeDir}/Keyring/";
remote = "git@codeberg.org:serenity-F/keyring.git";
};
Notes = { # notes backup, not paying for obsidian backup (lol)
enable = true;
user = "${primaryUser}";
path = "${homeDir}/Notes/";
remote = "git@codeberg.org:serenity-F/notes.git";
};
};
## Syncthing
syncthing = {
enable = true; # easy toggle
dataDir = "${homeDir}"; # defaults to primaryUser's homedir
openDefaultPorts = true; # opens the default firewall ports
configDir =
"${homeDir}/.config/syncthing"; # defaults to primaryUser's homedir
user = "${primaryUser}"; # uses primaryUser to run the service
group = "users"; # runs in the users group
#guiAddress = "0.0.0.0:8384"; # default web address for the GUI
settings = {
## WebApp GUI
user = "serenity";
#password = "password";
## Syncthing Folders
overrideFolders = true; # force these folder on activation
folders = {
"Keyring" = { # folder for password/secrets vault
enable = true; # easy toggle - OFF for now
id = "k158k-hvzk3";
path = "${homeDir}/Keyring"; # defaults to primaryUser's homedir
devices = [
"Hecate"
#"Persephone"
];
#versioning = { # versioning, for added redundancy
# disabled for now as we have versioning through git
#type = "simple"; # nothing fancy, keeps x number of copies
#params = { keep = "3"; }; # number of copies to keep
#};
};
"Notes" = { # folder for organisation/notes vault
enable = true; # easy toggle
id = "h0ay3-l8snk";
path = "${homeDir}/Notes"; # defaults to primaryUser's homedir
devices = [
"Hecate"
#"Persephone"
];
#versioning = { # versioning, for added redundancy
# disabled for now as we have versioning through git
#type = "simple"; # nothing fancy, keeps x number of copies
#params = { keep = "3"; }; # number of copies to keep
#};
};
};
## Syncthing Devices
overrideDevices = true; # force these devices on activation
devices =
{ # all syncthing devices listed - 'boilerplate' for other hosts
#"Orcus".id = "REALLY-LONG-ORCUS-SYNCTHING-KEY-HERE"; # disabled for testing
#"Hades".id = "REALLY-LONG-HADES-SYNCTHING-KEY-HERE"; # disabled for testing
"Hecate".id = "36WUSM4-HFYOGWP-33JHBPI-WR2TXXE-ZX3PFMB-QH6BMXM-DQ523ZF-FD7M3AI";
#"Persephone".id = "REALLY-LONG-PERSEPHONE-SYNCTHING-KEY-HERE"; # disabled for testing
};
};
};
};
systemd.services = {
syncthing = {
environment.STNODEFAULTFOLDER =
"true"; # prevents the `Sync` folder from being created on activation
};
};
}