From 4ca6cff3373f07f50fd17d55d9ba8cf03a9babda Mon Sep 17 00:00:00 2001 From: serenity-F Date: Tue, 25 Mar 2025 17:09:02 +1000 Subject: [PATCH] moderat tidy up of `home.nix` --- core/default.nix | 3 - core/hosts/hades/default.nix | 1 + core/hosts/hades/network.nix | 58 ++++++++----------- home/programs/default.nix | 3 +- home/programs/multimedia/default.nix | 5 +- home/programs/music/default.nix | 21 +++++-- home/programs/music/production.nix | 15 +++-- .../automount => programs/sync}/default.nix | 49 ++++++---------- home/programs/sync/postActivation.nix | 31 ++++++++++ home/programs/syncthing/default.nix | 14 ----- home/scripts/automount/postActivation.nix | 17 ------ home/scripts/default.nix | 8 ++- 12 files changed, 110 insertions(+), 115 deletions(-) rename home/{scripts/automount => programs/sync}/default.nix (52%) create mode 100644 home/programs/sync/postActivation.nix delete mode 100755 home/programs/syncthing/default.nix delete mode 100644 home/scripts/automount/postActivation.nix diff --git a/core/default.nix b/core/default.nix index 31351cc..7db5c5b 100755 --- a/core/default.nix +++ b/core/default.nix @@ -12,9 +12,6 @@ ../home # user-level packages in ../home/programs/ ../secrets # secrets :shh: - ## Testing - ../home/scripts/automount/postActivation.nix - ]; ## Make sure this is set ! diff --git a/core/hosts/hades/default.nix b/core/hosts/hades/default.nix index 095f669..c67d625 100755 --- a/core/hosts/hades/default.nix +++ b/core/hosts/hades/default.nix @@ -11,6 +11,7 @@ ../../../core ## Host-specific core modules ../../../core/modules/zfs.nix + ../../../core/modules/sync.nix ../../../core/modules/gaming.nix ../../../core/modules/jellyfin.nix #../../../core/modules/bluetooth.nix diff --git a/core/hosts/hades/network.nix b/core/hosts/hades/network.nix index 318b95b..22a6f36 100755 --- a/core/hosts/hades/network.nix +++ b/core/hosts/hades/network.nix @@ -2,50 +2,41 @@ { - imports = [ - # ./file.nix - ]; - networking = { wireless.enable = false; nameservers = [ "127.0.0.1" "::1" ]; networkmanager = { enable = true; - dns = "none"; + dns = "none"; # handled by dnscrypt }; - - #nameservers = [ - #"1.1.1.1" - #]; - - #proxy = { - #default = "https://user:password@proxy:port/"; - #noProxy = "127.0.0.1, localhost, internal.domain"; - #}; - }; - ## i knooooowwwwwww i need a proper firewall config but im laaaazzyyyyyyyyyy + ## Rudimentary firewall config networking.firewall = { enable = true; - #checkReversePath = "loose"; - #allowedTCPPortRanges = [ { from = 1720; to = 1770; } ]; - #allowedUDPPortRanges = allowedTCPPortRanges; - #interfaces."DEVICENAME".allowedTCPPorts = [ - #22999 - #] + + ## Specific TCP ports to be opened allowedTCPPorts = [ 2234 # soulseek/nicotine-plus 8384 # syncthing - #21027 - #25565 ]; + + ## Specific UDP ports to be opened allowedUDPPorts = [ - #22000 - #21027 - #41641 - #51820 + 2234 # soulseek/nicotine-plus + 8834 # syncthing ]; + + ## Ranges for TCP and UDP ports to be opened + ## - disabled for now as network infrastructure is minimal + #allowedTCPPortRanges = [ { from = 1720; to = 1770; } ]; + #allowedUDPPortRanges = allowedTCPPortRanges; + + }; + + ## Systemd service for the dnscrypt config declared below + systemd.services.dnscrypt-proxy2.serviceConfig = { + StateDirectory = "dnscrypt-proxy"; }; services.dnscrypt-proxy2 = { @@ -55,16 +46,19 @@ require_dnssec = true; sources.public-resolvers = { + ## Where to get list of server addresses urls = [ "https://raw.githubusercontent.com/DNSCrypt/dnscrypt-resolvers/master/v3/public-resolvers.md" "https://download.dnscrypt.info/resolvers-list/v3/public-resolvers.md" ]; - cache_file = "/var/lib/dnscrypt-proxy2/public-resolvers.md"; + ## key and cachefile to verify servers and authenticity minisign_key = "RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3"; + cache_file = "/var/lib/dnscrypt-proxy2/public-resolvers.md"; }; - # You can choose a specific set of servers from https://github.com/DNSCrypt/dnscrypt-resolvers/blob/master/v3/public-resolvers.md + ## Select a specific server, or a set of servers from the link below + ## - https://github.com/DNSCrypt/dnscrypt-resolvers/blob/master/v3/public-resolvers.md server_names = [ "mullvad-doh" "mullvad-adblock-doh" @@ -78,8 +72,4 @@ }; }; - systemd.services.dnscrypt-proxy2.serviceConfig = { - StateDirectory = "dnscrypt-proxy"; - }; - } diff --git a/home/programs/default.nix b/home/programs/default.nix index b3c27ce..58113b6 100755 --- a/home/programs/default.nix +++ b/home/programs/default.nix @@ -12,6 +12,7 @@ ./web ./git ./obs + ./sync ./chat ./yazi ./btop @@ -20,9 +21,7 @@ ./music ./fetch ./kitty - ./syncthing ./multimedia - ./music/production.nix ]; diff --git a/home/programs/multimedia/default.nix b/home/programs/multimedia/default.nix index c08f193..1eae810 100644 --- a/home/programs/multimedia/default.nix +++ b/home/programs/multimedia/default.nix @@ -2,7 +2,10 @@ { - imports = [ ./homestuck.nix ./lookingGlass.nix ]; + imports = [ + ./lookingGlass.nix # for GPU passthrough on virtual machines + ./homestuck.nix # a small module to add a .desktop entry for The unofficial Homestuck Collection + ]; home = { packages = with pkgs; [ diff --git a/home/programs/music/default.nix b/home/programs/music/default.nix index 5ca4bd9..73817e1 100644 --- a/home/programs/music/default.nix +++ b/home/programs/music/default.nix @@ -1,17 +1,30 @@ +# # Chore: pick an offline music player already lol +## Requirements: +## - have last.fm support +## - match other UI styles +## - handle large amounts of FLAC/HiRes audio +## - optionally support metadata editing + { pkgs, ... }: { + imports = [ + ./production.nix # programs for creation of music :D + ]; + home = { packages = with pkgs; [ - ## Media | Chore: Pick a music player + ## Utilities + puddletag # Music metadata editing + + ## Music players + spotify # corpo trash strawberry # QT music player - #lollypop # GTK music player - spotify # Corpo music streaming + #lollypop # GTK/Gnome native music player #pragha # Music player #tauon # Music player - puddletag # Music metadata editing ]; }; diff --git a/home/programs/music/production.nix b/home/programs/music/production.nix index 266fcd3..f98ae5c 100644 --- a/home/programs/music/production.nix +++ b/home/programs/music/production.nix @@ -8,19 +8,17 @@ ## Misc. Tools metronome # GTK metronome - ## Text based programmatic music production - supercollider-with-plugins - - ## Visual node based audio production - bespokesynth # Modular synth and sequencer - vcv-rack # Analogue modular synth emulator - puredata # Programmatic synth and sequencer - ## Digital Audio Workstations audacity # Audio editing and DAW reaper # Digital audio workstation ardour # Digital Audio Workstation + ## Modular and programmatic music production + supercollider-with-plugins + bespokesynth # Modular synth and sequencer + vcv-rack # Analogue modular synth emulator + puredata # Programmatic synth and sequencer + ## Models and synths neural-amp-modeler-lv2 # Guitar amp emulator #cardinal # vcv-rack but as an open source VST @@ -31,6 +29,7 @@ }; ## Neovim plugins for Supercollider synth + ## - full nvim environment for supercollider is WIP programs.nixvim.extraPlugins = with pkgs.vimPlugins; [ nvim-treesitter-parsers.supercollider ]; diff --git a/home/scripts/automount/default.nix b/home/programs/sync/default.nix similarity index 52% rename from home/scripts/automount/default.nix rename to home/programs/sync/default.nix index a1d9615..2c67d35 100755 --- a/home/scripts/automount/default.nix +++ b/home/programs/sync/default.nix @@ -10,39 +10,21 @@ # need to set up auto luks unlock with sops-nix ## Provides LUKS key for Asphodel - environment.etc."crypttab".text = '' - data /dev/disk/by-uuid/45f5f6ad-a676-4bc1-ad4b-e3e26b5697f4 ${config.sops.secrets.Asphodel-key.path} - ''; + #environment.etc."crypttab".text = '' + #data /dev/disk/by-uuid/45f5f6ad-a676-4bc1-ad4b-e3e26b5697f4 ${config.sops.secrets.Asphodel-key.path} + #''; + ## Mounts Asphodel to typical media location - fileSystems."/run/media/${primaryUser}/Asphodel".device = - "/dev/mapper/Asphodel"; + #fileSystems."/run/media/${primaryUser}/Asphodel".device = "/dev/mapper/Asphodel"; - home = { + home.file = { # Files and directories to copy to ${homeDir} - ## Directories to copy to /home/${username/} - file = { - - ## Path to automount disks to - #"Disks" = { - #source = ./Disks; - #target = "${disksPath}"; - #recursive = true; - #}; - - ## (current) Flake path - #"flakes/nixdots" = { - #source = ../../../../nixdots; - #recursive = true; - #}; - - ## (future) Flake path - #"SerenityOS" = { - #source = ./SerenityOS; - #target = "${flakePath}"; - #recursive = true; - #}; - - }; + ## Example format for home.file + #"Foo" = { # Name for the copied file + #source = ./Foo; # Source is relative to this file + #target = "Desired/Path/To/Foo"; # Target path for Foo within ${homeDir} + #recursive = true; # Unsure if necessary for most things + #}; }; @@ -59,6 +41,13 @@ #}; }; + ## Syncthing program service + syncthing = { + enable = true; + tray.enable = true; + #guiAddress = "home.syncthing"; + }; + }; } diff --git a/home/programs/sync/postActivation.nix b/home/programs/sync/postActivation.nix new file mode 100644 index 0000000..9496095 --- /dev/null +++ b/home/programs/sync/postActivation.nix @@ -0,0 +1,31 @@ +{ inputs, outputs, lib, config, pkgs, primaryUser, homeDir, flakePath, disksPath +, ... }: + +{ + + ## Work in progress - to fix/configure: + ## - automatically copy flake repo to desired path + ## - automatically copy sync directories to to desired paths + ## - expand script with a try/catch block to provide output for failed links + ## - expand script to only run if desired directories are NOT already linked + + ## To utilise this script place the following option into some system-level module + imports = [ ../home/scripts/automount/postActivation.nix ]; + + ## Runs after using `sudo nixos-rebuild switch --flake .#` + system.activationScripts.disksLink = { + supportsDryActivation = false; + ## Prints status of run commmand with a cute message if successful + text = '' + cd ~ && ln -s Disks /run/media/${primaryUser}/* + echo "Current variables required are:" + echo "primaryUser - ${primaryUser}" + echo "homeDir - ${homeDir}" + echo "current paths linked are:" + echo "flakePath - ${flakePath}" + echo "disksPath - ${disksPath}" + echo "<3" + ''; + }; + +} diff --git a/home/programs/syncthing/default.nix b/home/programs/syncthing/default.nix deleted file mode 100755 index 4895880..0000000 --- a/home/programs/syncthing/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ - - services = { - - syncthing = { - enable = false; - #tray.enable = true; - #guiAddress = "home.syncthing"; - - }; - - }; - -} diff --git a/home/scripts/automount/postActivation.nix b/home/scripts/automount/postActivation.nix deleted file mode 100644 index de09d33..0000000 --- a/home/scripts/automount/postActivation.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ pkgs, flakePath, disksPath, primaryUser, ... }: - -{ - - imports = [ ]; - - ## Runs after using `sudo nixos-rebuild switch --flake .#` - system.activationScripts.disksLink = { - supportsDryActivation = false; - ## Prints status of run commmand with a cute message if successful - text = '' - cd ~ && ln -s Disks /run/media/${primaryUser}/* - echo "disksPaths linked successfully <3" - ''; - }; - -} diff --git a/home/scripts/default.nix b/home/scripts/default.nix index e3b6a88..6dc74a0 100755 --- a/home/scripts/default.nix +++ b/home/scripts/default.nix @@ -1,6 +1,10 @@ { ... }: { - imports = - [ ./automount ./startup.nix ./desktop.nix ./battery.nix ./nix-utils.nix ]; + imports = [ + ./startup.nix # Programs and scripts executed upon entering desktop environments + ./desktop.nix # Programs and scripts essential to operating desktop environments + ./battery.nix # Script for interfacing with batteries present on certain devices + ./nix-utils.nix # Programs and scripts for interacting with NixOS infrastructure + ]; }