diff --git a/nixos/lib/default.nix b/nixos/lib/default.nix index bcbc606..dcc2c6b 100644 --- a/nixos/lib/default.nix +++ b/nixos/lib/default.nix @@ -3,7 +3,7 @@ with lib; rec { - firstOrDefault = first: default: if !isNull first then first else default; + firstOrDefault = first: default: if first != null then first else default; existsOrDefault = x: set: default: if builtins.hasAttr x set then builtins.getAttr x set else default; @@ -36,8 +36,7 @@ rec { # so here i try to get a robust list of security options for containers # because everyone needs more tinfoild hat right? RIGHT? - containerExtraOptions = [ ] - ++ lib.optionals (lib.attrsets.attrByPath [ "container" "caps" "privileged" ] false options) [ "--privileged" ] + containerExtraOptions = lib.optionals (lib.attrsets.attrByPath [ "container" "caps" "privileged" ] false options) [ "--privileged" ] ++ lib.optionals (lib.attrsets.attrByPath [ "container" "caps" "readOnly" ] false options) [ "--read-only" ] ++ lib.optionals (lib.attrsets.attrByPath [ "container" "caps" "tmpfs" ] false options) [ (map (folders: "--tmpfs=${folders}") tmpfsFolders) ] ++ lib.optionals (lib.attrsets.attrByPath [ "container" "caps" "noNewPrivileges" ] false options) [ "--security-opt=no-new-privileges" ] @@ -53,8 +52,7 @@ rec { environment = { TZ = options.timeZone; } // options.container.env; - environmentFiles = [ ] - ++ lib.attrsets.attrByPath [ "container" "envFiles" ] [ ] options; + environmentFiles = lib.attrsets.attrByPath [ "container" "envFiles" ] [ ] options; volumes = [ "/etc/localtime:/etc/localtime:ro" ] ++ lib.optionals (lib.attrsets.hasAttrByPath [ "container" "persistentFolderMount" ] options) [ "${options.persistence.folder}:${options.container.persistentFolderMount}:rw" @@ -64,16 +62,15 @@ rec { labels = mkIf addTraefikLabels (mkTraefikLabels { name = subdomain; - port = options.port; - domain = options.domain; + inherit (options) port; + inherit (options) domain; url = host; }); extraOptions = containerExtraOptions; }; - systemd.tmpfiles.rules = [ ] - ++ lib.optionals (lib.attrsets.hasAttrByPath [ "persistence" "folder" ] options) [ "d ${options.persistence.folder} 0755 ${user} ${group} -" ] + systemd.tmpfiles.rules = lib.optionals (lib.attrsets.hasAttrByPath [ "persistence" "folder" ] options) [ "d ${options.persistence.folder} 0755 ${user} ${group} -" ] ; # built a entry for homepage @@ -82,8 +79,8 @@ rec { ${options.app} = { icon = homepageIcon; href = "https://${ host }"; - host = host; - description = options.description; + inherit host; + inherit (options) description; }; } ]; diff --git a/nixos/modules/nixos/containers/arr/lidarr/default.nix b/nixos/modules/nixos/containers/arr/lidarr/default.nix index a2bacca..b79dd7e 100644 --- a/nixos/modules/nixos/containers/arr/lidarr/default.nix +++ b/nixos/modules/nixos/containers/arr/lidarr/default.nix @@ -55,7 +55,7 @@ in ]; labels = lib.myLib.mkTraefikLabels { name = app; - domain = config.networking.domain; + inherit (config.networking) domain; inherit port; }; diff --git a/nixos/modules/nixos/containers/arr/prowlarr/default.nix b/nixos/modules/nixos/containers/arr/prowlarr/default.nix index 9ee0c8d..7e6e86f 100644 --- a/nixos/modules/nixos/containers/arr/prowlarr/default.nix +++ b/nixos/modules/nixos/containers/arr/prowlarr/default.nix @@ -53,7 +53,7 @@ in ]; labels = lib.myLib.mkTraefikLabels { name = app; - domain = config.networking.domain; + inherit (config.networking) domain; inherit port; }; diff --git a/nixos/modules/nixos/containers/arr/radarr/default.nix b/nixos/modules/nixos/containers/arr/radarr/default.nix index 61e4756..cdef450 100644 --- a/nixos/modules/nixos/containers/arr/radarr/default.nix +++ b/nixos/modules/nixos/containers/arr/radarr/default.nix @@ -55,7 +55,7 @@ in ]; labels = lib.myLib.mkTraefikLabels { name = app; - domain = config.networking.domain; + inherit (config.networking) domain; inherit port; }; diff --git a/nixos/modules/nixos/containers/arr/readarr/default.nix b/nixos/modules/nixos/containers/arr/readarr/default.nix index 914bd1e..3040359 100644 --- a/nixos/modules/nixos/containers/arr/readarr/default.nix +++ b/nixos/modules/nixos/containers/arr/readarr/default.nix @@ -54,7 +54,7 @@ in ]; labels = lib.myLib.mkTraefikLabels { name = app; - domain = config.networking.domain; + inherit (config.networking) domain; inherit port; }; diff --git a/nixos/modules/nixos/containers/arr/sonarr/default.nix b/nixos/modules/nixos/containers/arr/sonarr/default.nix index 9312976..19b658e 100644 --- a/nixos/modules/nixos/containers/arr/sonarr/default.nix +++ b/nixos/modules/nixos/containers/arr/sonarr/default.nix @@ -57,7 +57,7 @@ in ]; labels = lib.myLib.mkTraefikLabels { name = app; - domain = config.networking.domain; + inherit (config.networking) domain; inherit port; }; diff --git a/nixos/modules/nixos/containers/backrest/default.nix b/nixos/modules/nixos/containers/backrest/default.nix index 67eaf85..aa9fc5a 100644 --- a/nixos/modules/nixos/containers/backrest/default.nix +++ b/nixos/modules/nixos/containers/backrest/default.nix @@ -47,7 +47,7 @@ in ]; labels = lib.myLib.mkTraefikLabels { name = app; - domain = config.networking.domain; + inherit (config.networking) domain; inherit port; }; diff --git a/nixos/modules/nixos/containers/gatus/default.nix b/nixos/modules/nixos/containers/gatus/default.nix index a3d7f4a..5540e41 100644 --- a/nixos/modules/nixos/containers/gatus/default.nix +++ b/nixos/modules/nixos/containers/gatus/default.nix @@ -105,7 +105,7 @@ in labels = lib.myLib.mkTraefikLabels { name = app; - domain = config.networking.domain; + inherit (config.networking) domain; inherit port; }; diff --git a/nixos/modules/nixos/containers/home-assistant/default-old.nix b/nixos/modules/nixos/containers/home-assistant/default-old.nix index f44251e..766781a 100644 --- a/nixos/modules/nixos/containers/home-assistant/default-old.nix +++ b/nixos/modules/nixos/containers/home-assistant/default-old.nix @@ -26,7 +26,7 @@ in sops.secrets."services/${app}/env" = { sopsFile = ./secrets.sops.yaml; owner = user; - group = group; + inherit group; restartUnits = [ "podman-${app}.service" ]; }; } @@ -36,9 +36,9 @@ in inherit app user group; description = "Home Automation"; port = 8123; - timeZone = config.time.timeZone; + inherit (config.time) timeZone; # subdomainOverride = "hass"; - domain = config.networking.domain; + inherit (config.networking) domain; persistence = { folder = persistentFolder; backup = true; diff --git a/nixos/modules/nixos/containers/home-assistant/default.nix b/nixos/modules/nixos/containers/home-assistant/default.nix index 4f18dc1..e46c487 100644 --- a/nixos/modules/nixos/containers/home-assistant/default.nix +++ b/nixos/modules/nixos/containers/home-assistant/default.nix @@ -49,7 +49,7 @@ in ]; labels = lib.myLib.mkTraefikLabels { name = app; - domain = config.networking.domain; + inherit (config.networking) domain; inherit port; }; diff --git a/nixos/modules/nixos/containers/homepage/default.nix b/nixos/modules/nixos/containers/homepage/default.nix index f521ffd..411bbea 100644 --- a/nixos/modules/nixos/containers/homepage/default.nix +++ b/nixos/modules/nixos/containers/homepage/default.nix @@ -284,7 +284,7 @@ in # }; labels = lib.myLib.mkTraefikLabels { name = app; - domain = config.networking.domain; + inherit (config.networking) domain; inherit port; }; diff --git a/nixos/modules/nixos/containers/node-red/default.nix b/nixos/modules/nixos/containers/node-red/default.nix index f550b5d..8491130 100644 --- a/nixos/modules/nixos/containers/node-red/default.nix +++ b/nixos/modules/nixos/containers/node-red/default.nix @@ -9,8 +9,8 @@ let app = "node-red"; persistentFolder = "${config.mySystem.persistentFolder}/${appFolder}"; appFolder = "apps/${app}"; - user = config.services.node-red.user; - group = config.services.node-red.group; + inherit (config.services.node-red) user; + inherit (config.services.node-red) group; url = "code-${config.networking.hostName}.${config.networking.domain}"; in diff --git a/nixos/modules/nixos/containers/plex/default.nix b/nixos/modules/nixos/containers/plex/default.nix index 70ecde3..d5856dd 100644 --- a/nixos/modules/nixos/containers/plex/default.nix +++ b/nixos/modules/nixos/containers/plex/default.nix @@ -46,7 +46,7 @@ in ports = [ "${builtins.toString port}:${builtins.toString port}" ]; # expose port labels = lib.myLib.mkTraefikLabels { name = app; - domain = config.networking.domain; + inherit (config.networking) domain; inherit port; }; diff --git a/nixos/modules/nixos/containers/qbittorrent/default.nix b/nixos/modules/nixos/containers/qbittorrent/default.nix index 8befb7f..a92b6f9 100644 --- a/nixos/modules/nixos/containers/qbittorrent/default.nix +++ b/nixos/modules/nixos/containers/qbittorrent/default.nix @@ -46,7 +46,7 @@ in ]; labels = lib.myLib.mkTraefikLabels { name = app; - domain = config.networking.domain; + inherit (config.networking) domain; inherit port; }; diff --git a/nixos/modules/nixos/containers/redlib/default.nix b/nixos/modules/nixos/containers/redlib/default.nix index 5ca56e6..87ecc94 100644 --- a/nixos/modules/nixos/containers/redlib/default.nix +++ b/nixos/modules/nixos/containers/redlib/default.nix @@ -20,8 +20,8 @@ in port = 8080; user = "nobody"; group = "nobody"; - timeZone = config.time.timeZone; - domain = config.networking.domain; + inherit (config.time) timeZone; + inherit (config.networking) domain; homepage = { icon = "libreddit.svg"; category = "home"; diff --git a/nixos/modules/nixos/containers/sabnzbd/default.nix b/nixos/modules/nixos/containers/sabnzbd/default.nix index 0478402..4e69c85 100644 --- a/nixos/modules/nixos/containers/sabnzbd/default.nix +++ b/nixos/modules/nixos/containers/sabnzbd/default.nix @@ -40,7 +40,7 @@ in ]; labels = lib.myLib.mkTraefikLabels { name = app; - domain = config.networking.domain; + inherit (config.networking) domain; inherit port; }; diff --git a/nixos/modules/nixos/containers/searxng/default.nix b/nixos/modules/nixos/containers/searxng/default.nix index 933ed9d..963f487 100644 --- a/nixos/modules/nixos/containers/searxng/default.nix +++ b/nixos/modules/nixos/containers/searxng/default.nix @@ -39,7 +39,7 @@ in }; labels = lib.myLib.mkTraefikLabels { name = app; - domain = config.networking.domain; + inherit (config.networking) domain; inherit port; }; diff --git a/nixos/modules/nixos/containers/tautulli/default.nix b/nixos/modules/nixos/containers/tautulli/default.nix index 67c71ce..234a720 100644 --- a/nixos/modules/nixos/containers/tautulli/default.nix +++ b/nixos/modules/nixos/containers/tautulli/default.nix @@ -38,7 +38,7 @@ in ]; labels = lib.myLib.mkTraefikLabels { name = app; - domain = config.networking.domain; + inherit (config.networking) domain; inherit port; }; diff --git a/nixos/modules/nixos/containers/whoogle/default.nix b/nixos/modules/nixos/containers/whoogle/default.nix index 4f8538f..f20e06e 100644 --- a/nixos/modules/nixos/containers/whoogle/default.nix +++ b/nixos/modules/nixos/containers/whoogle/default.nix @@ -50,7 +50,7 @@ in labels = lib.myLib.mkTraefikLabels { name = app; - domain = config.networking.domain; + inherit (config.networking) domain; inherit port; }; diff --git a/nixos/modules/nixos/services/adguardhome/default.nix b/nixos/modules/nixos/services/adguardhome/default.nix index 7a5fc95..dc857ac 100644 --- a/nixos/modules/nixos/services/adguardhome/default.nix +++ b/nixos/modules/nixos/services/adguardhome/default.nix @@ -126,13 +126,13 @@ in buildList = id: url: { enabled = true; - id = id; - name = url.name; - url = url.url; + inherit id; + inherit (url) name; + inherit (url) url; }; in - (lib.imap1 buildList urls); + lib.imap1 buildList urls; }; }; diff --git a/nixos/modules/nixos/services/zigbee2mqtt/default.nix b/nixos/modules/nixos/services/zigbee2mqtt/default.nix index cc05a21..7266a38 100644 --- a/nixos/modules/nixos/services/zigbee2mqtt/default.nix +++ b/nixos/modules/nixos/services/zigbee2mqtt/default.nix @@ -29,7 +29,7 @@ in sops.secrets."services/mosquitto/mq/plainPassword.yaml" = { sopsFile = ../mosquitto/secrets.sops.yaml; owner = config.users.users.zigbee2mqtt.name; - group = config.users.users.zigbee2mqtt.group; + inherit (config.users.users.zigbee2mqtt) group; restartUnits = [ "${app}.service" ]; };