Reorganized

This commit is contained in:
Jan-Bulthuis committed 2025-05-09 15:27:44 +02:00
1 parent c3c61ce654
commit 760815da50
145 files changed
-1444

No files matched your search

-60
View File
@@ -1,60 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.base;
in
{
options.modules.base = {
enable = mkEnableOption "base";
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
# Add base linux utilities
git
wget
curl
dig
procps
wireguard-tools
usbutils
pciutils
zip
unzip
];
modules = {
# Enable base modules
clean-tmp.enable = true;
neovim.enable = true;
systemd-boot.enable = true;
};
# TODO: Remove everything below, it is here out of convenience and should be elsewhere
# networking.nameservers = [
# "9.9.9.9"
# "149.112.112.112"
# ];
# programs.captive-browser.enable = true;
services.resolved = {
enable = true;
};
networking.firewall.enable = true;
modules.unfree.enable = true;
nix.settings.experimental-features = "nix-command flakes";
nixpkgs.hostPlatform = "x86_64-linux";
console.packages = [
pkgs.dina-psfu
];
console.font = "dina";
console.earlySetup = true;
boot.loader.timeout = 0;
};
}
-93
View File
@@ -1,93 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.base.desktop;
in
{
options.modules.base.desktop = {
enable = mkEnableOption "desktop";
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
# TODO: MOVE
quickemu # TODO: Reenable once building this is fixed
pdftk
# TODO: Move to USB module
# usbutils
# udiskie
# udisks
brightnessctl
wireshark
];
# Move to Realm module
security.krb5 = {
enable = true;
settings = {
libdefaults = {
rdns = false;
};
realms = {
"GEWISWG.GEWIS.NL" = {
kdc = [
"https://gewisvdesktop.gewis.nl/KdcProxy"
];
};
};
};
};
modules = {
# Enable base modules
base.enable = true;
fontconfig.enable = true;
nixgreety.enable = true;
pipewire.enable = true;
graphics.enable = true;
};
programs.dconf.enable = true;
services.libinput.enable = true;
networking.firewall = {
enable = true;
logRefusedConnections = true;
logRefusedPackets = true;
logReversePathDrops = true;
logRefusedUnicastsOnly = false;
};
programs.wireshark.enable = true;
machine.sudo-groups = [ "wireshark" ];
services.upower.enable = true; # For battery percentage in gnome
modules.unfree.allowedPackages = [
"nvidia-x11"
"nvidia-settings"
];
networking.firewall.allowedTCPPortRanges = [
{
from = 10000;
to = 11000;
}
];
networking.firewall.allowedUDPPortRanges = [
{
from = 10000;
to = 11000;
}
];
security.rtkit.enable = true;
security.polkit.enable = true;
# TODO: Move to USB module
# services.gvfs.enable = true;
services.udisks2.enable = true;
};
}
-23
View File
@@ -1,23 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.bluetooth;
in
{
options.modules.bluetooth = {
enable = mkEnableOption "bluetooth";
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ bluez ];
hardware.bluetooth.enable = true;
hardware.bluetooth.powerOnBoot = true;
};
}
-18
View File
@@ -1,18 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.clean-tmp;
in
{
options.modules.clean-tmp = {
enable = mkEnableOption "clean-tmp";
};
config = mkIf cfg.enable { boot.tmp.cleanOnBoot = true; };
}
-37
View File
@@ -1,37 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.silent-boot;
in
{
options.modules.silent-boot = {
enable = mkEnableOption "silent-boot";
};
config = mkIf cfg.enable {
boot = {
loader.timeout = 0;
consoleLogLevel = 0;
initrd.verbose = false;
initrd.checkJournalingFS = false;
kernelParams = [
"quiet"
"boot.shell_on_fail"
"loglevel=3"
"rd.systemd.show_status=false"
"rd.udev.log_level=3"
"udev.log_priority=3"
"video=efifb:nobgrt"
"bgrt_disable"
];
};
};
}
-24
View File
@@ -1,24 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.systemd-boot;
in
{
options.modules.systemd-boot = {
enable = mkEnableOption "systemd-boot";
};
config = mkIf cfg.enable {
boot.loader = {
systemd-boot.enable = true;
systemd-boot.editor = false;
efi.canTouchEfiVariables = true;
};
};
}
-18
View File
@@ -1,18 +0,0 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.modules.brightnessctl;
in
{
options.modules.brightnessctl = {
enable = mkEnableOption "brightnessctl";
};
config = mkIf cfg.enable { environment.systemPackages = [ pkgs.brightnessctl ]; };
}
-39
View File
@@ -1,39 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
{
imports = [
# Import modules
./base/default.nix
./base/desktop.nix
./bluetooth/default.nix
./boot/clean-tmp.nix
./boot/silent-boot.nix
./boot/systemd-boot.nix
./brightnessctl/default.nix
./fontconfig/default.nix
./graphics/default.nix
./grdp/default.nix
./greeter/greetd/default.nix
./greeter/greetd/nixgreety.nix
./greeter/greetd/tuigreet.nix
./greeter/ly/default.nix
./locale/default.nix
./neovim/default.nix
./networkmanager/default.nix
./power-saving/default.nix
./printing/default.nix
./sound/pipewire.nix
./spotifyd/default.nix
./ssh/default.nix
./users/default.nix
./unfree/default.nix
./vpn/tailscale.nix
./wifi/wpa_supplicant.nix
];
}
-27
View File
@@ -1,27 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.fontconfig;
in
{
options.modules.fontconfig = {
enable = mkEnableOption "fontconfig";
};
config = {
fonts.fontconfig.enable = cfg.enable;
fonts.enableDefaultPackages = false;
fonts.fontconfig.defaultFonts = {
serif = mkDefault [ ];
sansSerif = mkDefault [ ];
monospace = mkDefault [ ];
emoji = mkDefault [ ];
};
};
}
-39
View File
@@ -1,39 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.fontconfig;
in
{
options.modules.graphics = {
enable = mkEnableOption "graphics";
};
config = mkIf cfg.enable {
# TODO: Modularize further, especially modesetting should be its own module.
# Set up graphics
hardware.graphics.enable32Bit = true;
hardware.graphics.enable = true;
services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia = {
modesetting.enable = true;
powerManagement.enable = false;
powerManagement.finegrained = false;
open = false;
nvidiaSettings = true;
package = config.boot.kernelPackages.nvidiaPackages.beta;
prime = {
intelBusId = "PCI:0:2:0";
nvidiaBusId = "PCI:1:0:0";
offload = {
enable = true;
enableOffloadCmd = true;
};
};
};
};
}
-50
View File
@@ -1,50 +0,0 @@
{
config,
lib,
pkgs,
...
}:
with lib;
{
options.modules.grdp = {
enable = mkEnableOption "grdp";
};
config = mkIf config.modules.grdp.enable {
services.gnome.gnome-remote-desktop.enable = true;
environment.systemPackages = with pkgs; [
gnome-remote-desktop
gnome-control-center
gnome-session
gnome-shell
gnome-settings-daemon
gdm
];
systemd.services."gnome-remote-desktop".wantedBy = [ "graphical.target" ];
networking.firewall = {
allowedTCPPorts = [ 3389 ];
allowedUDPPorts = [ 3389 ];
};
services.xserver.displayManager.gdm.enable = true;
modules.greetd.enable = mkForce false;
# security.polkit.extraConfig = ''
# polkit.addRule(function(action, subject) {
# if (action.id == "org.gnome.controlcenter.remote-session-helper" &&
# subject.isInGroup("wheel")) {
# return polkit.Result.YES;
# }
# });'';
# programs.dconf.profiles.user.databases = [
# {
# settings = with lib.gvariant; {
# "org/gnome/desktop/remote-desktop/rdp" = {
# enable = true;
# view-only = false;
# };
# };
# }
# ];
};
}
-31
View File
@@ -1,31 +0,0 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.modules.greetd;
in
{
options.modules.greetd = {
enable = mkEnableOption "greetd";
command = mkOption {
type = types.str;
default = "";
description = "Command to run to show greeter.";
};
};
config = mkIf cfg.enable {
services.greetd = {
enable = true;
settings.default_session = {
command = cfg.command;
user = mkDefault "greeter";
};
};
};
}
-30
View File
@@ -1,30 +0,0 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.modules.nixgreety;
in
{
options.modules.nixgreety = {
enable = mkEnableOption "nixgreety";
};
config = mkIf cfg.enable {
# Enable greetd
modules.greetd = {
enable = true;
command = "${pkgs.nixgreety}/bin/nixgreety";
};
services.greetd.settings.default_session.user = "root";
environment.systemPackages = with pkgs; [
nixgreety
];
};
}
-37
View File
@@ -1,37 +0,0 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.modules.tuigreet;
in
{
options.modules.tuigreet = {
enable = mkEnableOption "tuigreet";
greeting = mkOption {
type = types.str;
default = "Hewwo! >_< :3";
description = "Greeting message to show.";
};
command = mkOption {
type = types.str;
default = "~/.initrc";
description = "Command to run after logging in.";
};
};
config = mkIf cfg.enable {
# Enable greetd
modules.greetd = {
enable = true;
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --remember --greeting \"${cfg.greeting}\" --time --cmd \"${cfg.command}\" --asterisks";
};
# Enable silent boot to prevent late log messages from messing up tuigreet
modules.silent-boot.enable = true;
};
}
-30
View File
@@ -1,30 +0,0 @@
{
config,
lib,
...
}:
with lib;
let
cfg = config.modules.ly;
in
{
options.modules.ly = {
enable = mkEnableOption "ly";
};
config = mkIf cfg.enable {
services.displayManager.ly = {
enable = true;
settings = {
animation = "matrix";
animation_refresh_ms = 32;
box_title = "Hewwo! >_< :3";
clear_password = true;
load = true;
save = true;
xinitrc = "null";
};
};
};
}
-14
View File
@@ -1,14 +0,0 @@
{
lib,
config,
pkgs,
...
}:
{
config = {
time.timeZone = "Europe/Amsterdam";
i18n.defaultLocale = "en_US.UTF-8";
console.keyMap = "us";
};
}
-23
View File
@@ -1,23 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.neovim;
in
{
options.modules.neovim = {
enable = mkEnableOption "neovim";
};
config = mkIf cfg.enable {
programs.neovim = {
enable = true;
defaultEditor = true;
};
};
}
-29
View File
@@ -1,29 +0,0 @@
{
lib,
config,
...
}:
with lib;
let
cfg = config.modules.networkmanager;
in
{
options.modules.networkmanager = {
enable = mkEnableOption "networkmanager";
};
config = mkIf cfg.enable {
machine.sudo-groups = [ "networkmanager" ];
networking = {
networkmanager = {
enable = true;
wifi.powersave = true;
};
firewall = {
# Fix for wireguard
checkReversePath = false;
};
};
};
}
-36
View File
@@ -1,36 +0,0 @@
{
lib,
config,
...
}:
with lib;
let
cfg = config.modules.power-saving;
in
{
options.modules.power-saving = {
enable = mkEnableOption "power-saving";
};
config = mkIf cfg.enable {
powerManagement.enable = true;
services.thermald.enable = true;
services.tlp = {
enable = true;
settings = {
CPU_SCALING_GOVERNOR_ON_AC = "performance";
CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
CPU_ENERGY_PERF_POLICY_ON_AC = "performance";
CPU_MIN_PERF_ON_AC = 0;
CPU_MAX_PERF_ON_AC = 100;
CPU_MIN_PERF_ON_BAT = 0;
CPU_MAX_PERF_ON_BAT = 20;
};
};
};
}
-27
View File
@@ -1,27 +0,0 @@
{
lib,
config,
...
}:
with lib;
let
cfg = config.modules.printing;
in
{
options.modules.printing = {
enable = mkEnableOption "printing";
};
config = mkIf cfg.enable {
services.printing = {
enable = true;
# drivers = with pkgs; [];
};
services.avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true;
};
};
}
-27
View File
@@ -1,27 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.pipewire;
in
{
options.modules.pipewire = {
enable = mkEnableOption "pipewire";
};
config = mkIf cfg.enable {
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
};
}
-64
View File
@@ -1,64 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.spotifyd;
in
{
options.modules.spotifyd = {
enable = mkEnableOption "spotifyd";
};
config = mkIf cfg.enable {
# User for spotifyd
users.users.mixer = {
group = "mixer";
};
users.groups.mixer = { };
# Spotifyd service
systemd.user.services.spotifyd = {
description = "SpotifyD Service";
wantedBy = [ "default.target" ];
after = [
"network.target"
"sound.target"
];
unitConfig = {
ConditionUser = "mixer"; # TODO: Allow user configuration
};
serviceConfig = {
ExecStart = "${pkgs.spotifyd}/bin/spotifyd --no-daemon --config-path /etc/spotifyd/spotifyd.conf";
Restart = "always";
RestartSec = 5;
};
};
# Set up config
environment.etc = {
"spotifyd/spotifyd.conf" = {
source = ./spotifyd.conf;
mode = "0444";
user = "mixer"; # TODO: Make user configurable
group = "mixer";
};
};
# Set up firewall
networking.firewall = {
allowedTCPPorts = [
5353
5454
];
allowedUDPPorts = [
5353
5454
];
};
};
}
-118
View File
@@ -1,118 +0,0 @@
[global]
#---------#
# GENERAL #
#---------#
# The name that gets displayed under the connect tab on
# official clients.
device_name = "Linox"
# The displayed device type in Spotify clients.
# Can be unknown, computer, tablet, smartphone, speaker, t_v,
# a_v_r (Audio/Video Receiver), s_t_b (Set-Top Box), and audio_dongle.
device_type = "a_v_r"
# The directory used to store credentials and audio cache.
# Default: infers a sensible cache directory (e.g. on Linux: $XDG_CACHE_HOME)
#
# Note: The file path does not get expanded. Environment variables and
# shell placeholders like $HOME or ~ don't work!
#cache_path = "/full/path/to/cache/directory"
# If set to true, audio data does NOT get cached.
# In this case, the cache is only used for credentials.
#no_audio_cache = true
# The maximal size of the cache directory in bytes
# The example value corresponds to ~ 1GB
#max_cache_size = 1000000000
# If set to true, `spotifyd` tries to bind to dbus (default is the session bus)
# and expose MPRIS controls. When running headless, without the session bus,
# you should set this to false, to avoid errors. If you still want to use MPRIS,
# have a look at the `dbus_type` option.
use_mpris = false
# The bus to bind to with the MPRIS interface.
# Possible values: "session", "system"
# The system bus can be used if no graphical session is available
# (e.g. on headless systems) but you still want to be able to use MPRIS.
# NOTE: You might need to add appropriate policies to allow spotifyd to
# own the name.
#dbus_type = "session"
#-----------#
# DISCOVERY #
#-----------#
# If set to true, this disables zeroconf discovery.
# This can be useful, if one prefers to run a single-user instance.
#disable_discovery = false
# The port at which `spotifyd` is going to offer its service over the network (TCP).
# If not set, a random port > 1024 is used. For the service to be discoverable on the
# local network via mDNS, both the mDNS port (5353 UDP) and the random or fixed
# zeroconf port need to be allowed through any active firewall.
zeroconf_port = 5454
#-------#
# AUDIO #
#-------#
# The audio backend used to play music. To get
# a list of possible backends, run `spotifyd --help`.
#backend = "alsa" # use portaudio for macOS [homebrew]
backend = "pulseaudio"
# The alsa audio device to stream audio. To get a
# list of valid devices, run `aplay -L`,
#device = "default" # omit for macOS
device = "SpotifyD-Proxy"
# The PCM sample format to use. Possible values
# are F32, S32, S24, S24_3, S16.
# Change this value if you encounter errors like
# "Alsa error PCM open ALSA function 'snd_pcm_hw_params_set_format' failed with error 'EINVAL: Invalid argument'"
#audio_format = "S16"
# The volume controller. Each one behaves different to
# volume increases. For possible values, run
# `spotifyd --help`.
#volume_controller = "softvol" # use softvol for macOS
# ! Only relevant for ALSA !
# The alsa control device. By default this is the same
# name as the `device` field.
#control = "default"
# ! Only relevant for ALSA !
# The alsa mixer used by `spotifyd`.
#mixer = "PCM" # omit for macOS
# The audio bitrate. 96, 160 or 320 kbit/s
#bitrate = 160
# Volume on startup between 0 and 100
#initial_volume = 90
initial_volume = 100
# If set to true, enables volume normalisation between songs.
# volume_normalisation = true
# The normalisation pregain that is applied for each song.
#normalisation_pregain = -10
#-------ä
# OTHER #
#-------#
# After the music playback has ended, start playing similar songs based on the previous tracks.
# By default, `spotifyd` infers this setting from the user settings.
autoplay = true
# A command that gets executed in your shell after each song changes.
#on_song_change_hook = "echo \"hook executed on $PLAYER_EVENT\""
# The proxy `spotifyd` will use to connect to spotify.
#proxy = "http://proxy.example.org:8080"
-20
View File
@@ -1,20 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.ssh;
in
{
options.modules.ssh = {
enable = mkEnableOption "ssh";
};
config = mkIf cfg.enable {
services.openssh.enable = true;
};
}
-24
View File
@@ -1,24 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.unfree;
in
{
options.modules.unfree = {
enable = mkEnableOption "unfree";
allowedPackages = mkOption {
type = types.listOf types.str;
default = [ ];
};
};
config = mkIf cfg.enable {
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (getName pkg) cfg.allowedPackages;
};
}
-79
View File
@@ -1,79 +0,0 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
# User configuration
userModule = types.submodule {
options = {
sudo = mkOption {
type = types.bool;
default = false;
example = true;
description = "Whether the user is allowed sudo access.";
};
configuration = mkOption {
type = types.path;
default = ./users/base.nix;
description = "What home manager configuration to use for this user.";
};
desktopInit = mkOption {
type = types.lines;
default = "";
description = "Bash script to execute after initial log in.";
};
};
};
in
{
imports = [
# Import systemwide configuration
./systemwide.nix
];
options = {
machine.sudo-groups = mkOption {
type = types.listOf types.str;
default = [ ];
description = "Groups assigned to sudo users.";
};
machine.users = mkOption {
type = types.attrsOf userModule;
default = { };
description = "Users configured on this system.";
};
};
config = {
# Add required home manager modules
home-manager.sharedModules = [
# Modules
../../user-modules/default.nix
# Custom packages
../../pkgs/default.nix
];
# Create users
users.users = attrsets.concatMapAttrs (name: value: {
${name} = {
isNormalUser = true;
extraGroups = mkIf value.sudo (
[
"wheel"
]
++ config.machine.sudo-groups
);
};
}) config.machine.users;
# Create home manager configuration for users
home-manager.users = attrsets.concatMapAttrs (name: value: {
${name} = value.configuration;
}) config.machine.users;
};
}
-42
View File
@@ -1,42 +0,0 @@
{
config,
lib,
...
}:
with lib;
let
moduleFiles = [
../../user-modules/desktop/systemwide.nix
../../user-modules/development/systemwide.nix
../../user-modules/gaming/systemwide.nix
../../user-modules/keyring/systemwide.nix
];
moduleConfig = lists.foldr (file: acc: recursiveUpdate acc (import file)) { } moduleFiles;
moduleNames = attrNames moduleConfig;
mkModule =
name: moduleConfig:
{ pkgs, ... }:
{
config =
mkIf
(any (
user:
(
config.home-manager.users.${user}.modules.${name}.enable
|| (any (specialisation: specialisation.configuration.modules.${name}.enable) (
attrValues config.home-manager.users.${user}.specialisation
))
)
) (attrNames config.home-manager.users))
(if (isAttrs moduleConfig) then moduleConfig else (moduleConfig { inherit config pkgs; }));
};
imports = map (name: mkModule name moduleConfig."${name}") moduleNames;
in
{
imports = imports;
}
-23
View File
@@ -1,23 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.tailscale;
in
{
options.modules.tailscale = {
enable = mkEnableOption "tailscale";
};
config = mkIf cfg.enable {
services.tailscale = {
enable = true;
useRoutingFeatures = "client";
};
};
}
-24
View File
@@ -1,24 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.wpa_supplicant;
in
{
options.modules.wpa_supplicant = {
enable = mkEnableOption "wpa_supplicant";
};
config = mkIf cfg.enable {
networking.wireless = {
enable = true;
userControlled.enable = true;
allowAuxiliaryImperativeNetworks = true;
};
};
}