nix-dotfiles/hosts/common/default.nix

227 lines
4.8 KiB
Nix
Raw Normal View History

{ config, pkgs, lib, extendedLib, ... }:
let
2022-08-16 03:24:06 +02:00
inherit (config) machineVars;
in {
imports = [
./fonts.nix
./nix.nix
./programs/gnupg.nix
./programs/neovim.nix
./programs/nix-ld.nix
./programs/ssh.nix
./programs/usbtop.nix
./programs/wireshark.nix
./services/dbus.nix
./services/irqbalance.nix
./services/journald.nix
2024-12-03 13:32:15 +01:00
./services/libinput.nix
./services/openssh.nix
./services/pcscd.nix
./services/pipewire.nix
./services/printing.nix
./services/resolved.nix
./services/smartd.nix
./services/systemd-lock-handler.nix
2024-12-03 13:21:59 +01:00
./services/thermald.nix
2024-12-02 08:20:57 +01:00
./services/uptimed.nix
2024-12-02 08:22:14 +01:00
./services/userborn.nix
./services/xserver.nix
];
# systemd.enableStrictShellChecks = true;
sops.defaultSopsFile = ./../.. + "/secrets/${config.networking.hostName}.yaml";
2023-03-07 23:08:39 +01:00
2022-06-02 16:33:21 +02:00
time.timeZone = "Europe/Oslo";
console = {
font = "Lat2-Terminus16";
keyMap = "us";
};
networking = {
useDHCP = false;
nameservers = [
"1.1.1.1"
"8.8.8.8"
];
};
i18n.defaultLocale = "en_US.UTF-8";
environment = {
variables = {
EDITOR = "nvim";
VISUAL = "nvim";
};
systemPackages = with pkgs; ([
wget
2022-06-22 20:16:57 +02:00
] ++ (lib.optionals (!config.machineVars.headless) [
haskellPackages.xmobar
]));
shells = with pkgs; [
bashInteractive
zsh
dash
];
etc = {
currentSystemPackages = {
target = "current-system-packages";
text = let
inherit (lib.strings) concatStringsSep;
inherit (lib.lists) sort;
inherit (lib.trivial) lessThan;
packages = map (p: "${p.name}") config.environment.systemPackages;
sortedUnique = sort lessThan (lib.unique packages);
in concatStringsSep "\n" sortedUnique;
};
};
2022-06-02 16:33:21 +02:00
shellAliases.fixdisplay = let
2022-06-02 16:33:21 +02:00
inherit (config.machineVars) screens headless fixDisplayCommand;
2022-08-16 03:24:06 +02:00
screenToArgs = name: screen: with screen;
"--output ${name} --mode ${resolution} --rate ${toString frequency} --pos ${position}"
+ (lib.optionalString primary " --primary");
2022-08-16 03:24:06 +02:00
2022-06-02 16:33:21 +02:00
screenArgs = lib.concatStringsSep " " (lib.mapAttrsToList screenToArgs screens);
2022-08-16 03:24:06 +02:00
2022-06-02 16:33:21 +02:00
in lib.mkIf (!headless)
(if screenArgs != null
2022-08-16 03:24:06 +02:00
then "xrandr ${screenArgs}"
else (lib.mkIf (fixDisplayCommand != null) fixDisplayCommand));
};
2022-06-02 16:33:21 +02:00
users = {
users.h7x4 = {
isNormalUser = true;
shell = pkgs.zsh;
extraGroups = [
"audio"
2023-01-16 16:06:34 +01:00
"disk"
"docker"
2022-06-02 16:33:21 +02:00
"input"
2023-01-16 16:06:34 +01:00
"libvirtd"
"lp"
2023-01-16 16:06:34 +01:00
"media"
"minecraft"
"networkmanager"
2024-12-03 13:20:09 +01:00
"rtkit"
"scanner"
2023-01-16 16:06:34 +01:00
"video"
"wheel"
2024-06-02 16:30:31 +02:00
"wireshark"
2022-06-02 16:33:21 +02:00
];
};
groups = {
adbusers.members = [ "h7x4" ];
};
};
services = {
gnome.gnome-keyring.enable = !config.machineVars.headless;
2022-09-22 04:08:38 +02:00
udev.packages = with pkgs; [
yubikey-personalization
android-udev-rules
light
2022-09-22 04:08:38 +02:00
];
};
programs = {
dconf.enable = !config.machineVars.headless;
git.enable = true;
tmux.enable = true;
zsh.enable = true;
};
system.extraDependencies =
lib.optionals (config.machineVars.development) (with pkgs; [
asciidoc
asciidoctor
cabal2nix
clang
dart
dotnet-sdk
# dotnet-sdk_3
# dotnet-sdk_5
dotnetPackages.Nuget
elm2nix
elmPackages.elm
flutter
gcc
ghc
ghcid
# haskellPackages.Cabal_3_6_3_0
maven
nixfmt-rfc-style
nixpkgs-fmt
# nixpkgs-hammering
nodePackages.node2nix
nodePackages.npm
nodePackages.sass
nodePackages.typescript
nodePackages.yarn
nodejs
plantuml
python3
rustc
rustc
rustup
sqlcheck
sqlint
sqlite
sqlite-web
]);
2024-12-03 13:20:09 +01:00
# Realtime scheduling for pipewire and mpd
security.rtkit.enable = !config.machineVars.headless;
2024-12-02 08:24:39 +01:00
security.tpm2.enable = lib.mkDefault true;
security.tpm2.abrmd.enable = lib.mkDefault config.security.tpm2.enable;
2024-06-02 16:29:48 +02:00
security.sudo.extraConfig = let
sudoLecture = pkgs.writeText "sudo-lecture.txt" (extendedLib.termColors.front.red "Be careful or something, idk...\n");
in ''
Defaults lecture = always
2024-06-02 16:29:48 +02:00
Defaults lecture_file = ${sudoLecture}
'';
# https://github.com/NixOS/nixpkgs/blob/nixos-24.05/nixos/modules/profiles/hardened.nix
boot.blacklistedKernelModules = [
# Obscure network protocols
"ax25"
"netrom"
"rose"
# Old or rare or insufficiently audited filesystems
"adfs"
"affs"
"bfs"
"befs"
"cramfs"
"efs"
# "erofs" // used by systemd
"exofs"
"freevxfs"
"f2fs"
"hfs"
"hpfs"
"jfs"
"minix"
"nilfs2"
"ntfs"
"omfs"
"qnx4"
"qnx6"
"sysv"
"ufs"
];
}