From 062fd5de0b1dbc7619ca3f80764b6a8b5c8fdf78 Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Tue, 22 Jul 2025 22:58:18 +0200 Subject: [PATCH] refactor: normalize usage of `lib` and `builtins` namespaces --- flake/hosts.nix | 4 ++-- flake/modules.nix | 2 +- flake/packages.nix | 2 +- modules/home/de/hyprland/keybinds.nix | 4 ++-- modules/home/programs/firefox.nix | 2 +- modules/home/programs/shell/aliases.nix | 2 +- modules/home/sops.nix | 2 +- modules/system/meta/domains.nix | 4 ++-- modules/system/meta/ports.nix | 4 ++-- modules/system/services/caddy.nix | 2 +- modules/system/services/crowdsec/default.nix | 4 ++-- modules/system/services/crowdsec/firewall-bouncer.nix | 2 +- modules/system/services/forgejo/default.nix | 2 +- modules/system/services/it-tools.nix | 2 +- modules/system/services/ntfy.nix | 2 +- modules/system/services/syncthing.nix | 6 +++--- modules/system/sops.nix | 2 +- 17 files changed, 24 insertions(+), 24 deletions(-) diff --git a/flake/hosts.nix b/flake/hosts.nix index c69d619..da86c90 100644 --- a/flake/hosts.nix +++ b/flake/hosts.nix @@ -14,7 +14,7 @@ let hostFiles = "${self}/hosts/${hostName}" |> lib.filesystem.listFilesRecursive - |> builtins.filter (lib.hasSuffix ".nix"); + |> lib.filter (lib.hasSuffix ".nix"); in [ { networking = { inherit hostName; }; } @@ -46,6 +46,6 @@ in |> lib.filterAttrs (_: type: type == "directory") |> lib.mapAttrs (name: _: mkDeployNode name); - checks = builtins.mapAttrs (_: deployLib: deployLib.deployChecks self.deploy) inputs.deploy-rs.lib; + checks = lib.mapAttrs (_: deployLib: deployLib.deployChecks self.deploy) inputs.deploy-rs.lib; }; } diff --git a/flake/modules.nix b/flake/modules.nix index 7570bf4..90b40b3 100644 --- a/flake/modules.nix +++ b/flake/modules.nix @@ -1,6 +1,6 @@ { self, lib, ... }: let - modulesOf = dir: dir |> lib.filesystem.listFilesRecursive |> builtins.filter (lib.hasSuffix ".nix"); + modulesOf = dir: dir |> lib.filesystem.listFilesRecursive |> lib.filter (lib.hasSuffix ".nix"); in { flake = { diff --git a/flake/packages.nix b/flake/packages.nix index 0c26f25..0c797d2 100644 --- a/flake/packages.nix +++ b/flake/packages.nix @@ -27,7 +27,7 @@ |> lib.filterAttrs (_: value: value.config.home-manager.users.seb.custom.sops.enable or false) |> lib.mapAttrsToList (_: value: mkCreationRule value.config.home-manager.users.seb.custom.sops); - jsonConfig = { creation_rules = hostCreationRules ++ userCreationRules; } |> builtins.toJSON; + jsonConfig = { creation_rules = hostCreationRules ++ userCreationRules; } |> lib.strings.toJSON; in pkgs.runCommand "sops-config" { buildInputs = [ pkgs.yj ]; } '' mkdir $out diff --git a/modules/home/de/hyprland/keybinds.nix b/modules/home/de/hyprland/keybinds.nix index 74f953f..662bcf4 100644 --- a/modules/home/de/hyprland/keybinds.nix +++ b/modules/home/de/hyprland/keybinds.nix @@ -51,8 +51,8 @@ # Switch workspace ${lib.concatMapStringsSep "\n" (n: '' - bind = SUPER, ${toString n}, focusworkspaceoncurrentmonitor, ${toString n} - bind = SUPER SHIFT, ${toString n}, movetoworkspacesilent, ${toString n} + bind = SUPER, ${builtins.toString n}, focusworkspaceoncurrentmonitor, ${builtins.toString n} + bind = SUPER SHIFT, ${builtins.toString n}, movetoworkspacesilent, ${builtins.toString n} '') (lib.range 1 9)} # Manage session diff --git a/modules/home/programs/firefox.nix b/modules/home/programs/firefox.nix index b72726a..f7eeefc 100644 --- a/modules/home/programs/firefox.nix +++ b/modules/home/programs/firefox.nix @@ -35,7 +35,7 @@ "sidebar.revamp" = false; }; - extraConfig = builtins.readFile "${inputs.betterfox}/user.js"; + extraConfig = lib.readFile "${inputs.betterfox}/user.js"; }; policies.ExtensionSettings = diff --git a/modules/home/programs/shell/aliases.nix b/modules/home/programs/shell/aliases.nix index 9ed2234..a2ce117 100644 --- a/modules/home/programs/shell/aliases.nix +++ b/modules/home/programs/shell/aliases.nix @@ -19,7 +19,7 @@ let aliasList = lib.mapCartesianProduct ({ a, b, c }: a + b + c) { a = ["ll" "lt" "l"]; b = ["" "a"]; c = ["" "d" "f"]; }; eza = "eza --header --group --time-style=long-iso --group-directories-first --sort=name --icons=auto --git --git-repos-no-status --binary "; - convertAliasToCmd = str: eza + (builtins.replaceStrings ["ll" "lt" "l" "a" "d" "f"] ["--long " "--tree " "--oneline --dereference " "--all " "--only-dirs " "--only-files "] str); + convertAliasToCmd = str: eza + (lib.replaceStrings ["ll" "lt" "l" "a" "d" "f"] ["--long " "--tree " "--oneline --dereference " "--all " "--only-dirs " "--only-files "] str); in (lib.genAttrs aliasList convertAliasToCmd) // { ls = "l"; }; diff --git a/modules/home/sops.nix b/modules/home/sops.nix index 37c1a56..1f00af5 100644 --- a/modules/home/sops.nix +++ b/modules/home/sops.nix @@ -29,7 +29,7 @@ in }; secrets = lib.mkOption { type = lib.types.anything; - default = absoluteSecretsPath |> builtins.readFile |> builtins.fromJSON; + default = absoluteSecretsPath |> lib.readFile |> lib.strings.fromJSON; }; }; diff --git a/modules/system/meta/domains.nix b/modules/system/meta/domains.nix index 516ed77..d14d613 100644 --- a/modules/system/meta/domains.nix +++ b/modules/system/meta/domains.nix @@ -33,12 +33,12 @@ in |> lib.concatLists |> lib.concatMap ( entry: - map (domain: { + lib.map (domain: { file = entry.file; inherit domain; }) entry.value ) - |> lib.groupBy (entry: toString entry.domain) + |> lib.groupBy (entry: builtins.toString entry.domain) |> lib.filterAttrs (domain: entries: lib.length entries > 1); errorMessage = diff --git a/modules/system/meta/ports.nix b/modules/system/meta/ports.nix index 37a99e6..3d4f78d 100644 --- a/modules/system/meta/ports.nix +++ b/modules/system/meta/ports.nix @@ -23,12 +23,12 @@ in options.meta.ports.list.definitionsWithLocations |> lib.concatMap ( entry: - map (port: { + lib.map (port: { inherit (entry) file; inherit port; }) entry.value ) - |> lib.groupBy (entry: toString entry.port) + |> lib.groupBy (entry: builtins.toString entry.port) |> lib.filterAttrs (port: entries: lib.length entries > 1); errorMessage = diff --git a/modules/system/services/caddy.nix b/modules/system/services/caddy.nix index c992d64..36640a8 100644 --- a/modules/system/services/caddy.nix +++ b/modules/system/services/caddy.nix @@ -24,7 +24,7 @@ let logFormat = "output file ${config.services.caddy.logDir}/access-${domain}.log { mode 640 }"; extraConfig = '' ${lib.optionalString (isTailscaleDomain domain) "bind tailscale/${getSubdomain domain}"} - reverse_proxy localhost:${toString port} + reverse_proxy localhost:${builtins.toString port} ''; }; diff --git a/modules/system/services/crowdsec/default.nix b/modules/system/services/crowdsec/default.nix index a6472ce..7a90f90 100644 --- a/modules/system/services/crowdsec/default.nix +++ b/modules/system/services/crowdsec/default.nix @@ -52,8 +52,8 @@ in package = inputs.crowdsec.packages.${pkgs.system}.crowdsec; enrollKeyFile = config.sops.secrets."crowdsec/enrollment-key".path; settings = { - api.server.listen_uri = "127.0.0.1:${toString cfg.apiPort}"; - cscli.prometheus_uri = "http://127.0.0.1:${toString cfg.prometheusPort}"; + api.server.listen_uri = "127.0.0.1:${builtins.toString cfg.apiPort}"; + cscli.prometheus_uri = "http://127.0.0.1:${builtins.toString cfg.prometheusPort}"; }; allowLocalJournalAccess = true; diff --git a/modules/system/services/crowdsec/firewall-bouncer.nix b/modules/system/services/crowdsec/firewall-bouncer.nix index 05613ca..0656d38 100644 --- a/modules/system/services/crowdsec/firewall-bouncer.nix +++ b/modules/system/services/crowdsec/firewall-bouncer.nix @@ -19,7 +19,7 @@ in package = inputs.crowdsec.packages.${pkgs.system}.crowdsec-firewall-bouncer; settings = { api_key = "cs-firewall-bouncer"; - api_url = "http://127.0.0.1:${toString cfg.apiPort}"; + api_url = "http://127.0.0.1:${builtins.toString cfg.apiPort}"; }; }; diff --git a/modules/system/services/forgejo/default.nix b/modules/system/services/forgejo/default.nix index 86a26b3..d70f296 100644 --- a/modules/system/services/forgejo/default.nix +++ b/modules/system/services/forgejo/default.nix @@ -60,7 +60,7 @@ in database.SQLITE_JOURNAL_MODE = "WAL"; cache = { ADAPTER = "twoqueue"; - HOST = builtins.toJSON { + HOST = lib.strings.toJSON { size = 100; recent_ratio = 0.25; ghost_ratio = 0.5; diff --git a/modules/system/services/it-tools.nix b/modules/system/services/it-tools.nix index 1583003..41f2e66 100644 --- a/modules/system/services/it-tools.nix +++ b/modules/system/services/it-tools.nix @@ -28,7 +28,7 @@ in services.static-web-server = { enable = true; - listen = "[::]:${toString cfg.port}"; + listen = "[::]:${builtins.toString cfg.port}"; root = "${pkgs.it-tools}/lib"; configuration.general.health = true; }; diff --git a/modules/system/services/ntfy.nix b/modules/system/services/ntfy.nix index 82df120..1d97e7c 100644 --- a/modules/system/services/ntfy.nix +++ b/modules/system/services/ntfy.nix @@ -25,7 +25,7 @@ in enable = true; settings = { base-url = "https://${cfg.domain}"; - listen-http = ":${toString cfg.port}"; + listen-http = ":${builtins.toString cfg.port}"; behind-proxy = true; web-root = "disable"; }; diff --git a/modules/system/services/syncthing.nix b/modules/system/services/syncthing.nix index a3ac406..402a36e 100644 --- a/modules/system/services/syncthing.nix +++ b/modules/system/services/syncthing.nix @@ -67,7 +67,7 @@ in group = lib.mkIf (!cfg.isServer) "users"; dataDir = lib.mkIf (!cfg.isServer) "/home/seb"; - guiAddress = lib.mkIf cfg.isServer "127.0.0.1:${toString cfg.gui.port}"; + guiAddress = lib.mkIf cfg.isServer "127.0.0.1:${builtins.toString cfg.gui.port}"; cert = lib.mkIf useStaticTls config.sops.secrets."syncthing/cert".path; key = lib.mkIf useStaticTls config.sops.secrets."syncthing/key".path; @@ -81,7 +81,7 @@ in |> lib.mapAttrs ( name: value: { id = value.config.custom.services.syncthing.deviceId; - addresses = [ "tcp://${name}.${tailscaleCfg.domain}:${toString cfg.syncPort}" ]; + addresses = [ "tcp://${name}.${tailscaleCfg.domain}:${builtins.toString cfg.syncPort}" ]; } ); @@ -105,7 +105,7 @@ in ]; options = { - listenAddress = "tcp://0.0.0.0:${toString cfg.syncPort}"; + listenAddress = "tcp://0.0.0.0:${builtins.toString cfg.syncPort}"; globalAnnounceEnabled = false; localAnnounceEnabled = false; relaysEnabled = false; diff --git a/modules/system/sops.nix b/modules/system/sops.nix index 1de270a..7935ced 100644 --- a/modules/system/sops.nix +++ b/modules/system/sops.nix @@ -25,7 +25,7 @@ in }; secrets = lib.mkOption { type = lib.types.anything; - default = absoluteSecretsPath |> builtins.readFile |> builtins.fromJSON; + default = absoluteSecretsPath |> lib.readFile |> lib.strings.fromJSON; }; };