2023-04-02 15:35:59 +00:00
|
|
|
|
{ pkgs, config, lib, ... }:
|
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
let
|
|
|
|
|
cfg = config.common.linux;
|
|
|
|
|
|
|
|
|
|
# Modules
|
|
|
|
|
modules = {
|
|
|
|
|
adb = { config, ... }: mkIf config.common.linux.enable {
|
|
|
|
|
services.udev.packages = with pkgs; [ android-udev-rules ];
|
|
|
|
|
programs.adb.enable = true;
|
|
|
|
|
users.users.${config.common.linux.username}.extraGroups = [ "adbusers" ];
|
|
|
|
|
};
|
2023-09-03 17:28:44 +00:00
|
|
|
|
ios = { config, pkgs, ... }: mkIf config.common.linux.enable {
|
2023-11-21 12:28:19 +00:00
|
|
|
|
services.avahi.enable = true;
|
2023-04-02 15:35:59 +00:00
|
|
|
|
services.usbmuxd.enable = true;
|
2023-09-03 17:28:44 +00:00
|
|
|
|
services.usbmuxd.package = pkgs.usbmuxd2;
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
|
libimobiledevice
|
|
|
|
|
ifuse
|
|
|
|
|
];
|
2023-04-02 15:35:59 +00:00
|
|
|
|
users.users.${config.common.linux.username}.extraGroups = [ config.services.usbmuxd.group ];
|
|
|
|
|
systemd.network.networks."05-ios-tethering" = {
|
|
|
|
|
matchConfig.Driver = "ipheth";
|
|
|
|
|
networkConfig.DHCP = "yes";
|
2023-08-30 21:53:14 +00:00
|
|
|
|
linkConfig.RequiredForOnline = "no";
|
2023-04-02 15:35:59 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
2023-04-18 11:03:19 +00:00
|
|
|
|
|
2023-11-05 12:09:34 +00:00
|
|
|
|
accounts = { pkgs, ... }: mkIf (config.common.linux.enable && !pkgs.stdenv.isAarch64) {
|
2023-09-26 11:29:16 +00:00
|
|
|
|
environment.systemPackages = with pkgs.gnome; [ pkgs.glib gnome-control-center ];
|
|
|
|
|
services.accounts-daemon.enable = true;
|
|
|
|
|
services.gnome.gnome-online-accounts.enable = true;
|
2024-04-22 09:57:42 +00:00
|
|
|
|
# programs.evolution.enable = true;
|
|
|
|
|
# programs.evolution.plugins = with pkgs; [ evolution-ews ];
|
|
|
|
|
# services.gnome.evolution-data-server.enable = true;
|
|
|
|
|
# services.gnome.evolution-data-server.plugins = with pkgs; [ evolution-ews ];
|
2023-09-26 11:29:16 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-04-18 11:03:19 +00:00
|
|
|
|
wlr = { ... }: mkIf config.common.linux.enable {
|
|
|
|
|
# swaync disable notifications on screencast
|
|
|
|
|
xdg.portal.wlr.settings.screencast = {
|
|
|
|
|
exec_before = ''which swaync-client && swaync-client --inhibitor-add "xdg-desktop-portal-wlr" || true'';
|
|
|
|
|
exec_after = ''which swaync-client && swaync-client --inhibitor-remove "xdg-desktop-portal-wlr" || true'';
|
|
|
|
|
};
|
|
|
|
|
};
|
2023-04-26 19:04:13 +00:00
|
|
|
|
|
|
|
|
|
logitech = { pkgs, ... }: mkIf cfg.enable {
|
|
|
|
|
services.ratbagd.enable = true;
|
|
|
|
|
environment.systemPackages = with pkgs; [ piper ];
|
|
|
|
|
};
|
2023-04-29 14:27:35 +00:00
|
|
|
|
|
|
|
|
|
virtualisation = { pkgs, ... }: mkIf cfg.enable {
|
|
|
|
|
virtualisation.podman = {
|
|
|
|
|
enable = true;
|
|
|
|
|
dockerCompat = true;
|
2023-08-10 04:55:04 +00:00
|
|
|
|
defaultNetwork.settings.dns_enabled = true;
|
2023-04-29 14:27:35 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
virtualisation.oci-containers.backend = "podman";
|
2023-09-04 15:10:03 +00:00
|
|
|
|
|
2024-05-24 14:33:40 +00:00
|
|
|
|
virtualisation.virtualbox.host.enable = false;
|
2023-09-04 15:10:03 +00:00
|
|
|
|
users.extraGroups.vboxusers.members = [ cfg.username ];
|
2023-04-29 14:27:35 +00:00
|
|
|
|
};
|
2023-04-02 15:35:59 +00:00
|
|
|
|
};
|
2024-03-11 13:59:57 +00:00
|
|
|
|
|
|
|
|
|
rt-audio = { pkgs, ... }: mkIf cfg.enable {
|
2024-05-27 09:06:04 +00:00
|
|
|
|
services.pipewire.lowLatency = {
|
|
|
|
|
# enable this module
|
|
|
|
|
enable = true;
|
|
|
|
|
# defaults (no need to be set unless modified)
|
|
|
|
|
quantum = 32;
|
|
|
|
|
rate = 48000;
|
|
|
|
|
};
|
2024-03-11 13:59:57 +00:00
|
|
|
|
security.rtkit.enable = true;
|
|
|
|
|
|
|
|
|
|
# Real time configurations
|
|
|
|
|
boot.kernel.sysctl = {
|
|
|
|
|
"vm.swappiness" = 10;
|
|
|
|
|
"fs.inotify.max_user_watches" = 524288;
|
|
|
|
|
};
|
|
|
|
|
security.pam.loginLimits = [
|
|
|
|
|
{
|
|
|
|
|
domain = "@audio";
|
|
|
|
|
item = "rtprio";
|
|
|
|
|
type = "-";
|
|
|
|
|
value = "90";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
domain = "@audio";
|
|
|
|
|
item = "memlock";
|
|
|
|
|
type = "-";
|
|
|
|
|
value = "unlimited";
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
};
|
2023-04-02 15:35:59 +00:00
|
|
|
|
in
|
|
|
|
|
{
|
2024-03-11 13:59:57 +00:00
|
|
|
|
imports = with modules; [ adb ios wlr logitech virtualisation accounts rt-audio ];
|
2023-04-02 15:35:59 +00:00
|
|
|
|
|
|
|
|
|
options.common.linux = {
|
|
|
|
|
enable = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
description = "Enable the common settings for Linux personal machines";
|
|
|
|
|
default = pkgs.stdenv.isLinux;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
luksDevices = mkOption {
|
|
|
|
|
type = types.attrsOf types.str;
|
|
|
|
|
description = "A mapping from device mount name to its path (/dev/disk/...) to be mounted on boot";
|
|
|
|
|
default = { };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
|
hostname = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = "Host name for your machine";
|
|
|
|
|
};
|
|
|
|
|
dnsServers = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
description = "DNS server list";
|
|
|
|
|
default = [ "8.8.8.8" "8.8.4.4" ];
|
|
|
|
|
};
|
|
|
|
|
networks = mkOption {
|
|
|
|
|
type = types.attrsOf (types.submodule {
|
|
|
|
|
options.match = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = "The interface name to match";
|
|
|
|
|
};
|
|
|
|
|
options.isRequired = mkOption {
|
|
|
|
|
type = types.bool;
|
|
|
|
|
description = "Require this interface to be connected for network-online.target";
|
|
|
|
|
default = false;
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
description = "Network configuration";
|
|
|
|
|
default = {
|
|
|
|
|
default = { match = "*"; };
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
username = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = "The linux username";
|
|
|
|
|
default = "nki";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
## Boot Configuration
|
|
|
|
|
# Set kernel version to latest
|
2023-04-04 18:28:28 +00:00
|
|
|
|
boot.kernelPackages = mkDefault pkgs.linuxPackages_latest;
|
2023-04-02 15:35:59 +00:00
|
|
|
|
# Use the systemd-boot EFI boot loader.
|
|
|
|
|
boot = {
|
|
|
|
|
loader.timeout = 60;
|
|
|
|
|
loader.systemd-boot.enable = true;
|
|
|
|
|
loader.efi.canTouchEfiVariables = true;
|
|
|
|
|
supportedFilesystems = [ "ntfs" ];
|
|
|
|
|
};
|
2023-04-04 18:28:28 +00:00
|
|
|
|
boot.initrd.systemd.enable = builtins.length (builtins.attrNames (cfg.luksDevices)) > 0;
|
2023-04-02 15:35:59 +00:00
|
|
|
|
# LUKS devices
|
|
|
|
|
boot.initrd.luks.devices = builtins.mapAttrs
|
|
|
|
|
(name: path: {
|
|
|
|
|
device = path;
|
|
|
|
|
preLVM = true;
|
|
|
|
|
allowDiscards = true;
|
|
|
|
|
|
|
|
|
|
crypttabExtraOpts = [
|
|
|
|
|
"tpm2-device=auto"
|
|
|
|
|
"fido2-device=auto"
|
|
|
|
|
];
|
|
|
|
|
})
|
|
|
|
|
cfg.luksDevices;
|
|
|
|
|
|
|
|
|
|
## Hardware-related
|
2023-12-26 13:18:19 +00:00
|
|
|
|
|
|
|
|
|
# Firmware stuff
|
|
|
|
|
services.fwupd.enable = true;
|
|
|
|
|
|
2023-04-02 15:35:59 +00:00
|
|
|
|
# Enable sound.
|
|
|
|
|
sound.enable = true;
|
|
|
|
|
services.pipewire = {
|
|
|
|
|
enable = true;
|
|
|
|
|
# alsa is optional
|
|
|
|
|
alsa.enable = true;
|
|
|
|
|
alsa.support32Bit = true;
|
|
|
|
|
|
|
|
|
|
pulse.enable = true;
|
|
|
|
|
};
|
2024-03-05 23:02:26 +00:00
|
|
|
|
|
2023-04-02 15:35:59 +00:00
|
|
|
|
# udev configurations
|
|
|
|
|
services.udev.packages = with pkgs; [
|
|
|
|
|
qmk-udev-rules # For keyboards
|
|
|
|
|
];
|
2023-08-06 06:35:20 +00:00
|
|
|
|
# udisks
|
|
|
|
|
services.udisks2.enable = true;
|
2023-04-02 15:35:59 +00:00
|
|
|
|
# Bluetooth: just enable
|
|
|
|
|
hardware.bluetooth.enable = true;
|
|
|
|
|
hardware.bluetooth.package = pkgs.bluez5-experimental; # Why do we need experimental...?
|
|
|
|
|
hardware.bluetooth.settings.General.Experimental = true;
|
|
|
|
|
services.blueman.enable = true; # For a GUI
|
2023-09-07 21:34:01 +00:00
|
|
|
|
# ZRAM
|
|
|
|
|
zramSwap.enable = true;
|
2023-04-02 15:35:59 +00:00
|
|
|
|
|
|
|
|
|
## Users
|
|
|
|
|
users.users.${cfg.username} = {
|
|
|
|
|
isNormalUser = true;
|
|
|
|
|
uid = 1000;
|
|
|
|
|
extraGroups = [
|
|
|
|
|
"wheel" # Enable ‘sudo’ for the user.
|
|
|
|
|
"plugdev" # Enable openrazer-daemon privileges
|
2024-03-11 13:59:57 +00:00
|
|
|
|
"audio"
|
2023-04-02 15:35:59 +00:00
|
|
|
|
];
|
2024-01-19 13:46:36 +00:00
|
|
|
|
shell = pkgs.fish;
|
2023-04-02 15:35:59 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
## Network configuration
|
|
|
|
|
systemd.network.enable = true;
|
2023-09-27 12:26:10 +00:00
|
|
|
|
networking.dhcpcd.enable = lib.mkForce false;
|
2023-12-01 21:05:54 +00:00
|
|
|
|
networking.useDHCP = false;
|
|
|
|
|
networking.useNetworkd = true;
|
2023-08-30 21:53:14 +00:00
|
|
|
|
systemd.network.wait-online.enable = false;
|
2023-04-02 15:35:59 +00:00
|
|
|
|
networking.hostName = cfg.networking.hostname;
|
|
|
|
|
networking.wireless.iwd.enable = true;
|
2023-09-27 12:26:10 +00:00
|
|
|
|
networking.wireless.iwd.settings.General.EnableNetworkConfiguration = true;
|
2023-04-02 15:35:59 +00:00
|
|
|
|
systemd.network.networks = builtins.mapAttrs
|
|
|
|
|
(name: cfg: {
|
|
|
|
|
matchConfig.Name = cfg.match;
|
|
|
|
|
networkConfig.DHCP = "yes";
|
|
|
|
|
linkConfig.RequiredForOnline = if cfg.isRequired then "yes" else "no";
|
|
|
|
|
})
|
|
|
|
|
cfg.networking.networks;
|
|
|
|
|
# Leave DNS to systemd-resolved
|
|
|
|
|
services.resolved.enable = true;
|
|
|
|
|
services.resolved.domains = cfg.networking.dnsServers;
|
|
|
|
|
services.resolved.fallbackDns = cfg.networking.dnsServers;
|
|
|
|
|
# Firewall: only open to SSH now
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ 22 ];
|
|
|
|
|
networking.firewall.allowedUDPPorts = [ 22 ];
|
2023-05-04 16:30:55 +00:00
|
|
|
|
# Enable tailscale
|
|
|
|
|
services.tailscale.enable = true;
|
2023-04-02 15:35:59 +00:00
|
|
|
|
|
|
|
|
|
## Time and Region
|
|
|
|
|
time.timeZone = "Europe/Zurich";
|
|
|
|
|
# Select internationalisation properties.
|
|
|
|
|
console.keyMap = "jp106"; # Console key layout
|
|
|
|
|
i18n.defaultLocale = "ja_JP.UTF-8";
|
|
|
|
|
# Input methods (only fcitx5 works reliably on Wayland)
|
|
|
|
|
i18n.inputMethod = {
|
|
|
|
|
enabled = "fcitx5";
|
2024-05-28 20:02:11 +00:00
|
|
|
|
fcitx5.waylandFrontend = true;
|
2023-04-02 15:35:59 +00:00
|
|
|
|
fcitx5.addons = with pkgs; [
|
|
|
|
|
fcitx5-mozc
|
|
|
|
|
fcitx5-unikey
|
|
|
|
|
fcitx5-gtk
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Default packages
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
|
kakoune # An editor
|
|
|
|
|
wget # A simple fetcher
|
|
|
|
|
|
|
|
|
|
## System monitoring tools
|
|
|
|
|
usbutils # lsusb and friends
|
|
|
|
|
pciutils # lspci and friends
|
|
|
|
|
psmisc # killall, pstree, ...
|
2024-01-28 13:46:35 +00:00
|
|
|
|
lm_sensors # sensors
|
2023-04-02 15:35:59 +00:00
|
|
|
|
|
|
|
|
|
## Security stuff
|
|
|
|
|
libsForQt5.qtkeychain
|
|
|
|
|
|
|
|
|
|
## Wayland
|
|
|
|
|
qt5.qtwayland
|
|
|
|
|
];
|
|
|
|
|
# Add a reliable terminal
|
2023-11-20 20:26:07 +00:00
|
|
|
|
programs.fish.enable = true;
|
2023-05-07 13:44:02 +00:00
|
|
|
|
# programs.gnome-terminal.enable = true;
|
2023-04-02 15:35:59 +00:00
|
|
|
|
# KDEConnect is just based
|
|
|
|
|
programs.kdeconnect.enable = true;
|
|
|
|
|
# Flatpaks are useful... sometimes...
|
|
|
|
|
services.flatpak.enable = true;
|
|
|
|
|
# DConf for GNOME configurations
|
|
|
|
|
programs.dconf.enable = true;
|
|
|
|
|
# Gaming! (not for ARM64)
|
|
|
|
|
programs.steam.enable = !pkgs.stdenv.isAarch64;
|
|
|
|
|
hardware.opengl.enable = true;
|
|
|
|
|
hardware.opengl.driSupport = true;
|
|
|
|
|
hardware.opengl.driSupport32Bit = !pkgs.stdenv.isAarch64; # For 32 bit applications
|
|
|
|
|
|
|
|
|
|
## Services
|
|
|
|
|
# gnome-keyring for storing keys
|
|
|
|
|
services.gnome.gnome-keyring.enable = true;
|
|
|
|
|
# OpenSSH so you can SSH to me
|
|
|
|
|
services.openssh.enable = true;
|
|
|
|
|
# PAM
|
|
|
|
|
security.pam.services.login.enableKwallet = true;
|
|
|
|
|
security.pam.services.login.enableGnomeKeyring = true;
|
|
|
|
|
security.pam.services.lightdm.enableKwallet = true;
|
|
|
|
|
security.pam.services.lightdm.enableGnomeKeyring = true;
|
|
|
|
|
security.pam.services.swaylock = { };
|
|
|
|
|
# Printers
|
|
|
|
|
services.printing.enable = true;
|
|
|
|
|
# Portals
|
|
|
|
|
xdg.portal = {
|
|
|
|
|
enable = true;
|
|
|
|
|
wlr.enable = true;
|
2024-05-27 09:03:15 +00:00
|
|
|
|
xdgOpenUsePortal = true;
|
2023-04-02 15:35:59 +00:00
|
|
|
|
# gtk portal needed to make gtk apps happy
|
|
|
|
|
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
|
2023-12-01 21:05:54 +00:00
|
|
|
|
|
2024-05-27 09:03:15 +00:00
|
|
|
|
config.sway."org.freedesktop.impl.portal.Secret" = [ "gnome-keyring" ];
|
2023-12-01 21:05:54 +00:00
|
|
|
|
config.sway.default = [ "wlr" "gtk" ];
|
2023-04-02 15:35:59 +00:00
|
|
|
|
};
|
|
|
|
|
# D-Bus
|
|
|
|
|
services.dbus.packages = with pkgs; [ gcr ];
|
|
|
|
|
|
|
|
|
|
## Environment
|
|
|
|
|
environment.variables = {
|
|
|
|
|
# Set default editor
|
|
|
|
|
EDITOR = "kak";
|
|
|
|
|
VISUAL = "kak";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|