about summary refs log tree commit diff
path: root/modules/nixos
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2023-01-05 04:22:04 +0300
committerAzat Bahawi <azat@bahawi.net>2023-01-05 04:22:04 +0300
commit5e81e4814d6da25ce8531baf0bc2d23da7fc26b3 (patch)
treecd887f80d9f98d42db556b4a42bcb8d5faa91c84 /modules/nixos
parent2022-12-17 (diff)
2023-01-05
Diffstat (limited to 'modules/nixos')
-rw-r--r--modules/nixos/common/networking.nix186
-rw-r--r--modules/nixos/common/nix.nix3
-rw-r--r--modules/nixos/discord.nix2
-rw-r--r--modules/nixos/emacs.nix2
-rw-r--r--modules/nixos/games/minecraft.nix4
-rw-r--r--modules/nixos/libvirtd.nix8
-rw-r--r--modules/nixos/matrix/default.nix8
-rw-r--r--modules/nixos/profiles/dev/default.nix4
-rw-r--r--modules/nixos/profiles/headful.nix5
9 files changed, 124 insertions, 98 deletions
diff --git a/modules/nixos/common/networking.nix b/modules/nixos/common/networking.nix
index 6109933..0c44159 100644
--- a/modules/nixos/common/networking.nix
+++ b/modules/nixos/common/networking.nix
@@ -5,104 +5,118 @@
   this,
   ...
 }:
-with lib; {
-  # TODO Support multiple interfaces and IP addresses.
-  networking = mkMerge [
-    {
-      domain = my.domain.shire;
+with lib; let
+  cfg = config.nixfiles.modules.common.networking;
+in {
+  options.nixfiles.modules.common.networking.onlyDefault =
+    mkEnableOption "custom networking settings";
 
-      hostName = this.hostname;
-      hostId = substring 0 8 (builtins.hashString "md5" this.hostname);
+  config = mkIf (!cfg.onlyDefault) {
+    # TODO Support multiple interfaces and IP addresses.
+    networking = mkMerge [
+      {
+        domain = my.domain.shire;
 
-      # Remove default hostname mappings. This is required at least by the current
-      # implementation of the montoring module.
-      hosts = {
-        "127.0.0.2" = mkForce [];
-        "::1" = mkForce [];
-      };
+        hostName = this.hostname;
+        hostId = substring 0 8 (builtins.hashString "md5" this.hostname);
 
-      nameservers = mkDefault dns.const.quad9.default;
+        # Remove default hostname mappings. This is required at least by the current
+        # implementation of the montoring module.
+        hosts = {
+          "127.0.0.2" = mkForce [];
+          "::1" = mkForce [];
+        };
 
-      useDHCP = false;
+        nameservers = mkDefault dns.const.quad9.default;
 
-      firewall = {
-        enable = true;
+        useDHCP = false;
 
-        rejectPackets = false;
+        firewall = {
+          enable = true;
 
-        allowPing = true;
-        pingLimit = "--limit 1/minute --limit-burst 5";
+          rejectPackets = false;
 
-        logRefusedConnections = false;
-        logRefusedPackets = false;
-        logRefusedUnicastsOnly = false;
-        logReversePathDrops = false;
-      };
-    }
-    (let
-      interface = "eth0"; # This assumes `usePredictableInterfaceNames` is false.
-    in
-      mkIf (hasAttr "ipv4" this && hasAttr "ipv6" this) {
-        usePredictableInterfaceNames = false; # NOTE This can break something!
-        interfaces.${interface} = {
-          ipv4.addresses = with this.ipv4;
-            optional (isString address && isInt prefixLength) {
-              inherit address prefixLength;
-            };
+          allowPing = true;
+          pingLimit = "--limit 1/minute --limit-burst 5";
 
-          ipv6.addresses = with this.ipv6;
-            optional (isString address && isInt prefixLength) {
-              inherit address prefixLength;
-            };
+          logRefusedConnections = false;
+          logRefusedPackets = false;
+          logRefusedUnicastsOnly = false;
+          logReversePathDrops = false;
         };
-        defaultGateway = with this.ipv4;
-          mkIf (isString gatewayAddress) {
-            inherit interface;
-            address = gatewayAddress;
-          };
-        defaultGateway6 = with this.ipv6;
-          mkIf (isString gatewayAddress) {
-            inherit interface;
-            address = gatewayAddress;
+      }
+      (let
+        interface = "eth0"; # This assumes `usePredictableInterfaceNames` is false.
+      in
+        mkIf (hasAttr "ipv4" this && hasAttr "ipv6" this) {
+          usePredictableInterfaceNames = false; # NOTE This can break something!
+          interfaces.${interface} = {
+            ipv4.addresses = with this.ipv4;
+              optional (isString address && isInt prefixLength) {
+                inherit address prefixLength;
+              };
+
+            ipv6.addresses = with this.ipv6;
+              optional (isString address && isInt prefixLength) {
+                inherit address prefixLength;
+              };
           };
-      })
-    (mkIf this.isHeadful {
-      interfaces = {
-        eth0.useDHCP = mkDefault true;
-        wlan0.useDHCP = mkDefault true;
-      };
+          defaultGateway = with this.ipv4;
+            mkIf (isString gatewayAddress) {
+              inherit interface;
+              address = gatewayAddress;
+            };
+          defaultGateway6 = with this.ipv6;
+            mkIf (isString gatewayAddress) {
+              inherit interface;
+              address = gatewayAddress;
+            };
+        })
+      (mkIf this.isHeadful {
+        interfaces = {
+          eth0.useDHCP = mkDefault true;
+          wlan0.useDHCP = mkDefault true;
+        };
 
-      networkmanager = {
-        enable = mkDefault true;
-        wifi.backend = "iwd";
-      };
+        networkmanager = {
+          enable = mkDefault true;
+          wifi.backend = "iwd";
+        };
 
-      wireless = {
-        enable = false;
-        iwd.enable = mkDefault true;
-        userControlled.enable = true;
-        allowAuxiliaryImperativeNetworks = true;
-      };
-    })
-  ];
+        wireless = {
+          enable = false;
+          iwd.enable = mkDefault true;
+          userControlled.enable = true;
+          allowAuxiliaryImperativeNetworks = true;
+        };
+      })
+    ];
 
-  environment.shellAliases = listToAttrs (map
-    ({
-      name,
-      value,
-    }:
-      nameValuePair name "${pkgs.iproute2}/bin/${value}") [
-      {
-        name = "bridge";
-        value = "bridge -color=always";
-      }
-      {
-        name = "ip";
-        value = "ip -color=always";
-      }
-      {
-        name = "tc";
-        value = "tc -color=always";
-      }
-    ]);
+    environment = {
+      shellAliases = listToAttrs (map
+        ({
+          name,
+          value,
+        }:
+          nameValuePair name "${pkgs.iproute2}/bin/${value}") [
+          {
+            name = "bridge";
+            value = "bridge -color=always";
+          }
+          {
+            name = "ip";
+            value = "ip -color=always";
+          }
+          {
+            name = "tc";
+            value = "tc -color=always";
+          }
+        ]);
+
+      systemPackages = with pkgs; [
+        ethtool
+        nethogs
+      ];
+    };
+  };
 }
diff --git a/modules/nixos/common/nix.nix b/modules/nixos/common/nix.nix
index 07136a0..71f62fd 100644
--- a/modules/nixos/common/nix.nix
+++ b/modules/nixos/common/nix.nix
@@ -22,8 +22,9 @@ in {
 
       overlays = with inputs; [
         agenix.overlay
-        # nix-minecraft-servers.overlays.default
+        pollymc.overlay
         xmonad-ng.overlays.default
+        # nix-minecraft-servers.overlays.default
       ];
     };
 
diff --git a/modules/nixos/discord.nix b/modules/nixos/discord.nix
index 190b5fc..69ab525 100644
--- a/modules/nixos/discord.nix
+++ b/modules/nixos/discord.nix
@@ -15,7 +15,7 @@ in {
 
     hm.home.packages = with pkgs; [
       (discord.override {
-        withOpenASAR = true;
+        withOpenASAR = false; # This doesnt work.
       })
     ];
   };
diff --git a/modules/nixos/emacs.nix b/modules/nixos/emacs.nix
index 800d411..2db8120 100644
--- a/modules/nixos/emacs.nix
+++ b/modules/nixos/emacs.nix
@@ -17,7 +17,7 @@ in {
     nixfiles.modules.x11.enable = true;
 
     hm = {
-      programs.doom-emacs.extraConfig = ''
+      programs.doom-emacs.extraConfig = mkAfter ''
         (appendq! auth-sources '("${config.secrets.authinfo.path}"))
       '';
 
diff --git a/modules/nixos/games/minecraft.nix b/modules/nixos/games/minecraft.nix
index e53f9eb..7b21195 100644
--- a/modules/nixos/games/minecraft.nix
+++ b/modules/nixos/games/minecraft.nix
@@ -22,7 +22,7 @@ in {
 
   config = mkMerge [
     (mkIf cfg.client.enable {
-      hm.home.packages = with pkgs; [pollymc];
+      hm.home.packages = with pkgs; [prismlauncher];
     })
     (mkIf cfg.server.enable {
       # Configurations, opslist, whitelist and plugins are managed imperatively.
@@ -31,7 +31,7 @@ in {
         enable = true;
         eula = true;
 
-        package = pkgs.minecraftServers.purpur_1_19_2;
+        package = pkgs.minecraftServers.purpur_1_19_3;
 
         # TODO Make a PR fixing trailing whitespace on this.
         jvmOpts =
diff --git a/modules/nixos/libvirtd.nix b/modules/nixos/libvirtd.nix
index ae8b336..58dfc50 100644
--- a/modules/nixos/libvirtd.nix
+++ b/modules/nixos/libvirtd.nix
@@ -10,6 +10,12 @@ in {
   options.nixfiles.modules.libvirtd.enable = mkEnableOption "libvirtd";
 
   config = mkIf cfg.enable {
+    hm.home.packages = with pkgs; [
+      qemu-utils
+      quickemu
+      virt-manager
+    ];
+
     virtualisation.libvirtd = {
       enable = true;
 
@@ -37,8 +43,6 @@ in {
       };
     };
 
-    environment.systemPackages = with pkgs; [virt-manager qemu-utils];
-
     my.extraGroups = ["libvirtd"];
   };
 }
diff --git a/modules/nixos/matrix/default.nix b/modules/nixos/matrix/default.nix
index bd221c4..879243e 100644
--- a/modules/nixos/matrix/default.nix
+++ b/modules/nixos/matrix/default.nix
@@ -1 +1,7 @@
-_: {imports = [./dendrite.nix ./element.nix ./synapse.nix];}
+_: {
+  imports = [
+    ./dendrite.nix
+    ./element.nix
+    ./synapse.nix
+  ];
+}
diff --git a/modules/nixos/profiles/dev/default.nix b/modules/nixos/profiles/dev/default.nix
index 83d41c0..8cb2356 100644
--- a/modules/nixos/profiles/dev/default.nix
+++ b/modules/nixos/profiles/dev/default.nix
@@ -8,6 +8,10 @@
 with lib; let
   cfg = config.nixfiles.modules.profiles.dev.default;
 in {
+  imports = [
+    ./containers.nix
+  ];
+
   config = mkIf cfg.enable {
     hm.home.language = {
       collate = "C";
diff --git a/modules/nixos/profiles/headful.nix b/modules/nixos/profiles/headful.nix
index d15f004..2d37b47 100644
--- a/modules/nixos/profiles/headful.nix
+++ b/modules/nixos/profiles/headful.nix
@@ -77,10 +77,7 @@ in {
       psd.enable = true;
     };
 
-    environment.systemPackages = with pkgs; [
-      ethtool
-      nethogs
-    ];
+    environment.systemPackages = with pkgs; [lm_sensors];
 
     my.extraGroups = ["audio" "video" "input"];
   };

Consider giving Nix/NixOS a try! <3