nix/modules/system.nix
2024-11-10 13:00:29 +01:00

93 lines
2 KiB
Nix

{ lib, pkgs, config, hostname, ... } @ args: let
inherit (lib) mkOption types;
cfg = config.chuj.system;
in {
options.chuj.system = {
user = mkOption {
type = types.str;
};
host = mkOption {
type = types.str;
};
platform = mkOption {
type = types.str;
};
groups = mkOption {
type = types.listOf types.str;
default = [];
};
stateVersion = mkOption {
type = types.str;
default = "23.11";
};
};
config = {
networking.hostName = cfg.host;
users.users.${cfg.user} = {
isNormalUser = true;
extraGroups = [ "wheel" ] ++ cfg.groups;
};
nixpkgs.hostPlatform = cfg.platform;
system.stateVersion = cfg.stateVersion;
time.timeZone = "Europe/Warsaw";
hardware.pulseaudio.enable = true;
services.pipewire.enable = false;
networking = {
nameservers = [ "9.9.9.9" ];
networkmanager = {
enable = true;
insertNameservers = [ "9.9.9.9" ];
};
};
nix.settings = {
experimental-features = [ "nix-command" "flakes" ];
auto-optimise-store = true;
};
nixpkgs.overlays = import ../pkgs args;
nixpkgs.config.allowUnfree = true;
security.sudo = {
package = pkgs.sudo.override { withInsults = true; };
extraConfig = ''
Defaults pwfeedback
'';
};
environment.systemPackages = with pkgs; let
nixos-rebuild = lib.getExe pkgs.nixos-rebuild;
sudo = "/run/wrappers/bin/sudo"; # is this correct
in [
ed # is the standard text editor.
ripgrep
file
tree
btop
wget
eza
usbutils
zip
unzip
# rar
unrar
p7zip
p7zip-rar
gcc
gnumake
python311
(writeShellScriptBin "rebuild" ''
set -e
ulimit -n 4096 # this fixes the "too many open files" error
${sudo} ${nixos-rebuild} switch --flake ~/nix#${hostname} -v $@
'')
];
};
}