nixfiles/modules/common.nix

99 lines
2.3 KiB
Nix
Raw Normal View History

2022-02-06 00:19:29 +00:00
{ lib, pkgs, inputs, system, config, options, ... }:
2022-02-13 13:10:21 +00:00
let
inherit (lib) mkIf mkDefault mkAliasDefinitions;
2022-02-13 17:44:14 +00:00
inherit (lib.my) mkOpt';
2022-02-13 13:10:21 +00:00
in
{
options.my = with lib.types; {
2022-02-13 17:44:14 +00:00
# Pretty hacky but too lazy to figure out if there's a better way to alias the options
user = mkOpt' (attrsOf anything) { } "User definition (as `users.users.*`).";
2022-02-13 13:10:21 +00:00
};
2022-02-06 00:06:26 +00:00
2022-02-13 13:10:21 +00:00
config =
let
defaultUsername = "dev";
uname = config.my.user.name;
in
{
my = {
user = {
name = mkDefault defaultUsername;
isNormalUser = true;
uid = mkDefault 1000;
extraGroups = mkDefault [ "wheel" ];
password = mkDefault "hunter2"; # TODO: secrets...
2022-02-06 00:06:26 +00:00
};
2022-02-13 13:10:21 +00:00
};
2022-02-06 00:06:26 +00:00
2022-02-13 13:10:21 +00:00
time.timeZone = mkDefault "Europe/Dublin";
2022-02-06 00:06:26 +00:00
2022-02-13 13:10:21 +00:00
users = {
mutableUsers = false;
users.${uname} = mkAliasDefinitions options.my.user;
};
2022-02-06 00:06:26 +00:00
2022-02-13 13:10:21 +00:00
security = {
sudo.enable = mkDefault false;
doas = {
enable = mkDefault true;
wheelNeedsPassword = mkDefault false;
2022-02-06 00:06:26 +00:00
};
2022-02-13 13:10:21 +00:00
};
2022-02-06 00:06:26 +00:00
2022-02-13 13:10:21 +00:00
nix = {
extraOptions =
''
experimental-features = nix-command flakes ca-derivations
'';
};
nixpkgs = {
2022-02-13 17:44:14 +00:00
overlays = [
inputs.nix.overlay
];
2022-02-13 13:10:21 +00:00
config = {
allowUnfree = true;
};
2022-02-13 13:10:21 +00:00
};
2022-02-13 13:10:21 +00:00
boot = {
# Use latest LTS release by default
kernelPackages = mkDefault pkgs.linuxKernel.packages.linux_5_15;
loader = {
efi = {
efiSysMountPoint = mkDefault "/boot";
canTouchEfiVariables = mkDefault false;
};
systemd-boot = {
enable = mkDefault true;
editor = mkDefault true;
consoleMode = mkDefault "max";
configurationLimit = mkDefault 10;
memtest86.enable = mkDefault true;
};
};
2022-02-13 13:10:21 +00:00
};
2022-02-06 00:19:29 +00:00
2022-02-13 13:10:21 +00:00
networking = {
useDHCP = mkDefault false;
enableIPv6 = mkDefault true;
};
2022-02-13 13:10:21 +00:00
environment.systemPackages = with pkgs; [
bash-completion
tree
vim
htop
iperf3
];
2022-02-06 00:06:26 +00:00
2022-02-13 13:10:21 +00:00
services.openssh = {
enable = true;
};
2022-02-13 13:10:21 +00:00
system = {
stateVersion = "21.11";
configurationRevision = with inputs; mkIf (self ? rev) self.rev;
2022-02-06 00:06:26 +00:00
};
2022-02-13 13:10:21 +00:00
};
}