From c8fdfc2f3a226aa5ada33cacdc22d32ebb288fef Mon Sep 17 00:00:00 2001 From: Zynh Ludwig Date: Sun, 6 Oct 2024 07:08:00 -0700 Subject: [PATCH] network: extract nixos module --- hosts/snowhawk/configuration.nix | 12 ------------ modules/default.nix | 1 + modules/network.nix | 23 +++++++++++++++++++++++ 3 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 modules/network.nix diff --git a/hosts/snowhawk/configuration.nix b/hosts/snowhawk/configuration.nix index bef00f2..3ce39cd 100644 --- a/hosts/snowhawk/configuration.nix +++ b/hosts/snowhawk/configuration.nix @@ -63,18 +63,6 @@ # Enable trash:/// support services.gvfs.enable = true; - # Enable the OpenSSH daemon. - services.openssh.enable = true; - services.openssh.openFirewall = true; - - services.avahi.enable = true; - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - # Before changing this value read the documentation for this option # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). system.stateVersion = "23.11"; # Did you read the comment? diff --git a/modules/default.nix b/modules/default.nix index 2d71101..8ee626c 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -13,6 +13,7 @@ in snowhawk.i18n.enable = lib.mkDefault true; snowhawk.audio.enable = lib.mkDefault true; snowhawk.env.enable = lib.mkDefault true; + snowhawk.network.enable = lib.mkDefault true; snowhawk.sops.enable = lib.mkDefault true; snowhawk.power-button.enable = lib.mkDefault true; } diff --git a/modules/network.nix b/modules/network.nix new file mode 100644 index 0000000..e7bcca4 --- /dev/null +++ b/modules/network.nix @@ -0,0 +1,23 @@ +{ config, lib, ... }: +let + cfg = config.snowhawk.network; +in +{ + options.snowhawk.network = { + enable = lib.mkEnableOption "network nixos module"; + }; + + config = lib.mkIf cfg.enable { + # Enable the OpenSSH daemon. + services.openssh.enable = true; + services.openssh.openFirewall = true; + + services.avahi.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + }; +}