summary refs log tree commit diff
path: root/modules/base.nix
blob: 537e7e64ba0062143c219020a1836e7c00393efd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{ config, pkgs, lib, ... }:

{
  imports =
    [
      ./monitoring.nix
      ./users/Rory.nix
      ./users/chris.nix
      ./users/maddy.nix
    ];
  boot = {
    kernelPackages = pkgs.linuxPackages_latest;
    kernelParams = [ "memory_hotplug.memmap_on_memory=1" "memhp_default_state=online" ];
    loader = {
      grub = {
        enable = true;
        version = 2;
        devices = [ "/dev/sda" ]; # nodev for EFI only
        # EFI
        efiSupport = false;
        efiInstallAsRemovable = false;
      };
      timeout = 1;
    };
    # Emma - Is this secure?
    #initrd.network.ssh.enable = true;
  };

  networking = {
    hostName = lib.mkDefault "Spacebar-nix-base-server";
    firewall = {
      enable = false;
      # allowedTCPPorts = [ ... ];
      # allowedUDPPorts = [ ... ];
    };
    
    networkmanager.enable = false;
    wireless.enable = false;
    enableIPv6 = false;

    useDHCP = false;
    nameservers = [ "1.1.1.1" ];
    defaultGateway = "192.168.1.1";

    extraHosts = ''
      192.168.1.2 secrets.spacebar.local
    '';
  };

  services = {
    openssh = {
      enable = true;
#      banner = ''
#         yg__    _ay      yggggy                                 $@@                    "
#         @@@@@gg@@@@     a@@~~~~ yy_yggy   yggy_yy _yaggy _yggy_ $@@yagy_  _agy_yy,yy_yg"
#        g@@~~~$~~~$@$    `?@@@gy @@@~~R@@_@@P~~@@@y@@F~~~g@@~_$@$$@@F~~@@La@@~~4@@L@@@F~"
#        @@@yyy@yyy@@@    y___y@@F@@$__g@@M@@L__a@@4@@y___4@@~~~~~$@@__y@@F$@$__y@@L@@$  "
#        `?PPPPPPPPPF~    fR@@@P~ @@F4@@P~ ~4@@P~RR ~4@@@P ~4@@@P 4RF?@@P~  ~R@RFRRFRRF  "
#                                 @@F                                                    "
#      '';
      settings = {
        PasswordAuthentication = false;
        GatewayPorts = "yes";
        KbdInteractiveAuthentication = false;
        UsePAM = true;
      };
      startWhenNeeded = true;
    };
  };

  security = {
    sudo = { 
      wheelNeedsPassword = false;
      execWheelOnly = true;
    };
    polkit.enable = true;
  };

  environment.systemPackages = with pkgs; [
    wget
    neofetch
    lnav
    git
    lsd
    htop
    btop
    duf
    kitty.terminfo
    neovim
  ];

  systemd.coredump.extraConfig = lib.mkDefault ''
    Storage=none
  '';

  security.pam.services.sshd.text = lib.mkAfter ''
    #login script
    auth optional pam_exec.so stdout ${pkgs.writeShellScript "login-banner" ''
      echo 'Welcome!'
      ${pkgs.chafa}/bin/chafa https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/branding/svg/Spacebar__Logo-Blue.svg --fg-only -s 80 -O 9 -w 9
    ''}
    #Account management.
    account required pam_unix.so

    #Authentication management.
    auth required pam_deny.so

    #Password management.
    password required pam_unix.so nullok yescrypt

    session required pam_env.so conffile=/etc/pam/environment readenv=0
    session required pam_unix.so
    session required pam_loginuid.so
    session optional ${pkgs.systemd}/lib/security/pam_systemd.so
  '';


  documentation.nixos.enable = false;
  hardware.pulseaudio.enable = false;
  i18n.defaultLocale = "en_US.UTF-8";
  nix.settings.experimental-features = [ "nix-command" "flakes" ];
  nixpkgs.config.allowUnfree = true;
  sound.enable = false;
  system.stateVersion = "22.11"; # DO NOT EDIT!
}