summaryrefslogtreecommitdiff
path: root/hosts/eostre/default.nix
blob: 5f58e0a045a73b57f0cfa0bfdfd2f509c75ae39d (plain)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
{ flake, config, pkgs, lib, ... }:

with lib;

{
  imports = with flake.nixosModules.systemProfiles; [
    nfsroot
  ];

  config = {
    nixpkgs = {
      system = "x86_64-linux";
      config = {
        allowUnfree = true;
      };
    };

    boot = {
      initrd = {
        availableKernelModules = [ "nvme" "ahci" "xhci_pci" "usbhid" "sd_mod" "sr_mod" ];
        kernelModules = [ "igb" ];
      };
      kernelModules = [ "kvm-amd" ];
      extraModulePackages = [ ];

      plymouth.enable = true;

      tmpOnTmpfs = true;
    };

    hardware = {
      enableRedistributableFirmware = true;
      cpu.amd.updateMicrocode = config.hardware.enableRedistributableFirmware;

      nvidia = {
        modesetting.enable = true;
        powerManagement.enable = true;
      };

      opengl.enable = true;
    };

    environment.etc."machine-id".text = "f457b21333f1491e916521151ff5d468";

    networking = {
      hostId = "f457b213";

      domain = "lan.yggdrasil";
      search = [ "lan.yggdrasil" "yggdrasil" ];

      hosts = {
        "127.0.0.1" = [ "eostre.lan.yggdrasil" "eostre" ];
        "::1" = [ "eostre.lan.yggdrasil" "eostre" ];
      };

      firewall.enable = false;
      nftables = {
        enable = true;
        rulesetFile = ./ruleset.nft;
      };
    };

    services.resolved = {
      llmnr = "false";
    };

    zramSwap.enable = true;

    system.stateVersion = config.system.nixos.release; # No state


    time.timeZone = "Europe/Berlin";
    time.hardwareClockInLocalTime = true;
    i18n.defaultLocale = "en_DK.UTF-8";


    environment.systemPackages = with pkgs; [ cifs-utils ];

    security.pam.mount = {
      enable = true;
      extraVolumes = [
        "<volume sgrp=\"users\" fstype=\"cifs\" server=\"vidhar.lan.yggdrasil\" path=\"home-eostre\" mountpoint=\"~\" options=\"mfsymlinks\" />"
        "<volume sgrp=\"users\" fstype=\"cifs\" server=\"vidhar.lan.yggdrasil\" path=\"%(USER)\" mountpoint=\"/run/media/%(USER)/vidhar\" options=\"mfsymlinks,noexec,nosuid\" />"
      ];
    };


    services.xserver = {
      enable = true;
      displayManager.sddm = {
        enable = true;
        settings = {
          Users.HideUsers = "gkleen";
        };
      };
      desktopManager.plasma5.enable = true;

      videoDrivers = [ "nvidia" ];
    };

    systemd.services = mapAttrs' (userName: _: nameValuePair "home-manager-${userName}" { enable = mkForce false; }) config.home-manager.users;

    systemd.user.services."home-manager" = let
      cfg = config.home-manager;
    in {
      description = "Home Manager environment";
      requiredBy = [ "basic.target" ];
      wants = [ "nix-daemon.socket" ];
      after = [ "nix-daemon.socket" ];
      before = [ "basic.target" ];

      environment = optionalAttrs (cfg.backupFileExtension != null) {
        HOME_MANAGER_BACKUP_EXT = cfg.backupFileExtension;
      } // optionalAttrs cfg.verbose { VERBOSE = "1"; };

      stopIfChanged = false;

      serviceConfig = {
        Type = "oneshot";
        RemainAfterExit = "yes";
        TimeoutStartSec = 90;
        SyslogIdentifier = "hm-activate";

        ExecStart = pkgs.writeScript "hm-activate" ''
          #! ${pkgs.runtimeShell} -el

          case $USER of
            ${concatStringsSep "\n  " (mapAttrsToList (_: usercfg: builtins.replaceStrings ["\n"] ["\n  "] ''
              ${usercfg.home.username})
                ${usercfg.home.activationPackage}/activate
                systemctl --user daemon-reload
              ;;
            '') cfg.users)}
            *) exit 0; ;;
          esac
        '';
      };
    };
  };
}