aboutsummaryrefslogblamecommitdiff
path: root/modules/private/system.nix
blob: 64fc2d972b3452ed61ec7137ec6497ee54100694 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
                                 

            
                                            









                                  



                                                                   






                                      
































                                                                                              
 



                        
 
                               
 
















                                                                         

    
{ pkgs, lib, config, name, ... }:
{
  config = {
    services.duplyBackup.profiles.system = {
      rootDir = "/var/lib";
      excludeFile = lib.mkAfter ''
        + /var/lib/nixos
        + /var/lib/udev
        + /var/lib/udisks2
        + /var/lib/systemd
        + /var/lib/private/systemd
        - /var/lib
        '';
    };
    nixpkgs.overlays = builtins.attrValues (import ../../overlays);
    _module.args = {
      pkgsNext = import <nixpkgsNext> {};
      pkgsPrevious = import <nixpkgsPrevious> {};
    };

    services.journald.extraConfig = ''
      MaxLevelStore="warning"
      MaxRetentionSec="1year"
      '';

    users.users =
      builtins.listToAttrs (map (x: lib.attrsets.nameValuePair x.name ({
        isNormalUser = true;
        home = "/home/${x.name}";
        createHome = true;
        linger = true;
      } // x)) (config.hostEnv.users pkgs))
      // {
        root.packages = let
          nagios-cli = pkgs.writeScriptBin "nagios-cli" ''
            #!${pkgs.stdenv.shell}
            sudo -u naemon ${pkgs.nagios-cli}/bin/nagios-cli -c ${./monitoring/nagios-cli.cfg}
            '';
        in
          [
            pkgs.telnet
            pkgs.htop
            pkgs.iftop
            pkgs.bind.dnsutils
            pkgs.httpie
            pkgs.iotop
            pkgs.whois
            pkgs.ngrep
            pkgs.tcpdump
            pkgs.tshark
            pkgs.tcpflow
            pkgs.mitmproxy
            pkgs.nmap
            pkgs.p0f
            pkgs.socat
            pkgs.lsof
            pkgs.psmisc
            pkgs.wget

            pkgs.cnagios
            nagios-cli
          ];
      };

    users.mutableUsers = false;

    environment.etc.cnagios.source = "${pkgs.cnagios}/share/doc/cnagios";
    environment.systemPackages =
      let
        home-manager = builtins.fetchGit {
          url = "https://github.com/rycee/home-manager.git";
          rev = "ef64bc598f28818d56c86629dad98b468af9c071";
          ref = "release-19.03";
        };
      in
      [
        pkgs.git
        pkgs.vim
      ] ++
      (lib.optional
        (builtins.length (config.hostEnv.users pkgs) > 0)
        ((pkgs.callPackage home-manager {}).home-manager)
      );
  };
}