From ea5ee00760ae3c4855dcc0b612b3388b841b3c45 Mon Sep 17 00:00:00 2001 From: servostar Date: Fri, 15 Dec 2023 20:10:28 +0100 Subject: [PATCH] added core modules to settings --- core/default.nix | 14 ++++++++------ core/printing.nix | 35 +++++++++++++++++++++++------------ core/xdg.nix | 17 +++++++---------- settings.nix | 15 ++++++++++++++- 4 files changed, 52 insertions(+), 29 deletions(-) diff --git a/core/default.nix b/core/default.nix index ca99987..068951f 100644 --- a/core/default.nix +++ b/core/default.nix @@ -1,8 +1,10 @@ +{ lib, ... }: +let + settings = import ./../settings.nix; +in { - imports = [ - ./java.nix - ./dotnet.nix - ./printing.nix - ./xdg.nix - ]; + imports = lib.optionals settings.printing.enable [ ./printing.nix ] + ++ lib.optionals settings.xdg.enable [ ./xdg.nix ] + ++ lib.optionals settings.java [ ./java.nix ] + ++ lib.optionals settings.dotnet [ ./dotnet.nix ]; } diff --git a/core/printing.nix b/core/printing.nix index 6bda1c3..69ab596 100644 --- a/core/printing.nix +++ b/core/printing.nix @@ -1,13 +1,24 @@ -{ pkgs, config, ... }: { - services.printing.enable = true; - services.avahi.enable = true; - # for a WiFi printer - services.avahi.openFirewall = true; - services.avahi.nssmdns = false; # Use the settings from below - # settings from avahi-daemon.nix where mdns is replaced with mdns4 - system.nssModules = pkgs.lib.optional (!config.services.avahi.nssmdns) pkgs.nssmdns; - system.nssDatabases.hosts = with pkgs.lib; optionals (!config.services.avahi.nssmdns) (mkMerge [ - (mkBefore [ "mdns4_minimal [NOTFOUND=return]" ]) # before resolve - (mkAfter [ "mdns4" ]) # after dns - ]); +{ pkgs, lib, config, ... }: +let + settings = import ./../settings.nix; +in +{ + config = lib.mkMerge [ + { + services.printing.enable = true; + } + # Avahi daemon + (lib.mkIf settings.printing.avahi { + services.avahi.enable = true; + # for a WiFi printer + services.avahi.openFirewall = true; + services.avahi.nssmdns = false; # Use the settings from below + # settings from avahi-daemon.nix where mdns is replaced with mdns4 + system.nssModules = pkgs.lib.optional (!config.services.avahi.nssmdns) pkgs.nssmdns; + system.nssDatabases.hosts = with pkgs.lib; optionals (!config.services.avahi.nssmdns) (mkMerge [ + (mkBefore [ "mdns4_minimal [NOTFOUND=return]" ]) # before resolve + (mkAfter [ "mdns4" ]) # after dns + ]); + }) + ]; } diff --git a/core/xdg.nix b/core/xdg.nix index 89f14b8..527b8cf 100644 --- a/core/xdg.nix +++ b/core/xdg.nix @@ -1,15 +1,12 @@ -{ pkgs, config, ... }: { - +{ pkgs, ... }: +let + settings = import ./../settings.nix; +in +{ xdg.portal = { enable = true; - extraPortals = [ - pkgs.xdg-desktop-portal-gtk - pkgs.xdg-desktop-portal-kde - ]; + extraPortals = settings.xdg.extraPortals; }; - environment.systemPackages = with pkgs; [ - pkgs.xdg-desktop-portal-gtk - pkgs.xdg-desktop-portal-kde - ]; + environment.systemPackages = settings.xdg.extraPortals; } diff --git a/settings.nix b/settings.nix index 0b6039c..f92fb2b 100644 --- a/settings.nix +++ b/settings.nix @@ -1,4 +1,4 @@ -{ +with import {}; { hardware = { # support for GPUs amdgpu = true; @@ -16,6 +16,19 @@ dvd = true; # enable DVD decryption + ripping via Handbrake bluray = true; # enable Bluray decryption (requires additional setup) + printing = { + enable = true; + avahi = true; + }; + xdg = { + enable = true; + extraPortals = with pkgs; [ + xdg-desktop-portal-gtk + xdg-desktop-portal-kde + ]; + }; + java = true; + dotnet = true; networking = { wireguard = true; # enable wireguard protocol