From ae8f0f2433131d7e129a65189d76677be78486ff Mon Sep 17 00:00:00 2001 From: Guanran Wang Date: Sun, 21 Jul 2024 18:09:21 +0800 Subject: [PATCH] treewide: replace builtins with lib --- darwin/modules/networking/proxy.nix | 2 +- darwin/modules/services/mihomo.nix | 2 +- darwin/profiles/common/core/anti-features.nix | 2 +- home/applications/sway/default.nix | 4 +-- hosts/aristotle/anti-feature.nix | 4 +-- hosts/blacksteel/anti-feature.nix | 4 +-- hosts/blacksteel/default.nix | 2 +- hosts/lightsail-tokyo/anti-feature.nix | 4 +-- hosts/lightsail-tokyo/default.nix | 26 +++++++++---------- nixos/profiles/opt-in/mihomo/default.nix | 4 +-- nixos/profiles/opt-in/wireless/default.nix | 2 +- 11 files changed, 27 insertions(+), 29 deletions(-) diff --git a/darwin/modules/networking/proxy.nix b/darwin/modules/networking/proxy.nix index 9715d5b..8c35b7c 100644 --- a/darwin/modules/networking/proxy.nix +++ b/darwin/modules/networking/proxy.nix @@ -127,7 +127,7 @@ in { # naive but works(tm) # "http://127.0.0.1:1234/" -> "127.0.0.1 1234" - proxy = builtins.replaceStrings ["http://" ":" "/"] ["" " " ""] cfg.proxy.httpProxy; + proxy = lib.replaceStrings ["http://" ":" "/"] ["" " " ""] cfg.proxy.httpProxy; in lib.concatMapStrings (x: '' ${networksetup} -setwebproxystate "${x}" on diff --git a/darwin/modules/services/mihomo.nix b/darwin/modules/services/mihomo.nix index 6a5ed74..c3b47ec 100644 --- a/darwin/modules/services/mihomo.nix +++ b/darwin/modules/services/mihomo.nix @@ -36,7 +36,7 @@ in { ### launchd service # TODO: not run as root user launchd.daemons."mihomo" = { - command = builtins.concatStringsSep " " [ + command = lib.concatStringsSep " " [ (lib.getExe cfg.package) "-d /etc/mihomo" (lib.optionalString (cfg.webui != null) "-ext-ui ${cfg.webui}") diff --git a/darwin/profiles/common/core/anti-features.nix b/darwin/profiles/common/core/anti-features.nix index bf1fcd2..feaf717 100644 --- a/darwin/profiles/common/core/anti-features.nix +++ b/darwin/profiles/common/core/anti-features.nix @@ -1,7 +1,7 @@ {lib, ...}: { # Allow unfree applications nixpkgs.config.allowUnfreePredicate = pkg: - builtins.elem (lib.getName pkg) [ + lib.elem (lib.getName pkg) [ "keka" ]; } diff --git a/home/applications/sway/default.nix b/home/applications/sway/default.nix index 7d60edd..b4ea431 100644 --- a/home/applications/sway/default.nix +++ b/home/applications/sway/default.nix @@ -129,7 +129,7 @@ } // # workspace binds - builtins.listToAttrs (builtins.concatMap (x: [ + lib.listToAttrs (lib.concatMap (x: [ { name = "${modifier}+${x}"; value = "workspace ${x}"; @@ -138,7 +138,7 @@ name = "${modifier}+Shift+${x}"; value = "move container to workspace ${x}"; } - ]) (builtins.genList (x: toString (x + 1)) 9)); + ]) (lib.genList (x: toString (x + 1)) 9)); }; }; } diff --git a/hosts/aristotle/anti-feature.nix b/hosts/aristotle/anti-feature.nix index 73e368b..e741827 100644 --- a/hosts/aristotle/anti-feature.nix +++ b/hosts/aristotle/anti-feature.nix @@ -4,7 +4,7 @@ allowNonSource = false; allowNonSourcePredicate = pkg: - builtins.elem (lib.getName pkg) [ + lib.elem (lib.getName pkg) [ "adoptopenjdk-hotspot-bin" "cargo-bootstrap" "cef-binary" @@ -18,7 +18,7 @@ allowUnfree = false; allowUnfreePredicate = pkg: - builtins.elem (lib.getName pkg) [ + lib.elem (lib.getName pkg) [ "fcitx5-pinyin-minecraft" "fcitx5-pinyin-moegirl" "libXNVCtrl" diff --git a/hosts/blacksteel/anti-feature.nix b/hosts/blacksteel/anti-feature.nix index 38077b6..e0211a2 100644 --- a/hosts/blacksteel/anti-feature.nix +++ b/hosts/blacksteel/anti-feature.nix @@ -5,7 +5,7 @@ allowNonSource = false; allowNonSourcePredicate = pkg: - builtins.elem (lib.getName pkg) [ + lib.elem (lib.getName pkg) [ "adoptopenjdk-hotspot-bin" "cargo-bootstrap" "minecraft-server" @@ -17,7 +17,7 @@ allowUnfree = false; allowUnfreePredicate = pkg: - builtins.elem (lib.getName pkg) [ + lib.elem (lib.getName pkg) [ "broadcom-sta" "minecraft-server" ]; diff --git a/hosts/blacksteel/default.nix b/hosts/blacksteel/default.nix index 3bd4bf2..0e97551 100644 --- a/hosts/blacksteel/default.nix +++ b/hosts/blacksteel/default.nix @@ -24,7 +24,7 @@ ######## Secrets sops = { - secrets = builtins.mapAttrs (_name: value: value // {sopsFile = ./secrets.yaml;}) { + secrets = lib.mapAttrs (_name: value: value // {sopsFile = ./secrets.yaml;}) { "synapse/secret" = { restartUnits = ["matrix-synapse.service"]; owner = config.systemd.services.matrix-synapse.serviceConfig.User; diff --git a/hosts/lightsail-tokyo/anti-feature.nix b/hosts/lightsail-tokyo/anti-feature.nix index 7d6725d..e38cd33 100644 --- a/hosts/lightsail-tokyo/anti-feature.nix +++ b/hosts/lightsail-tokyo/anti-feature.nix @@ -2,7 +2,7 @@ nixpkgs.config = { allowNonSource = false; allowNonSourcePredicate = pkg: - builtins.elem (lib.getName pkg) [ + lib.elem (lib.getName pkg) [ "adoptopenjdk-hotspot-bin" "cargo-bootstrap" "rustc-bootstrap" @@ -13,7 +13,7 @@ allowUnfree = false; allowUnfreePredicate = pkg: - builtins.elem (lib.getName pkg) [ + lib.elem (lib.getName pkg) [ ]; }; } diff --git a/hosts/lightsail-tokyo/default.nix b/hosts/lightsail-tokyo/default.nix index 66ec3b0..43a3501 100644 --- a/hosts/lightsail-tokyo/default.nix +++ b/hosts/lightsail-tokyo/default.nix @@ -31,20 +31,18 @@ boot.kernelPackages = pkgs.linuxPackages; ### Secrets - sops = { - secrets = builtins.mapAttrs (_name: value: value // {sopsFile = ./secrets.yaml;}) { - "hysteria/auth" = { - restartUnits = ["hysteria.service"]; - }; - "pixivfe/environment" = { - restartUnits = ["pixivfe.service"]; - }; - "searx/environment" = { - restartUnits = ["searx.service"]; - }; - "miniflux/environment" = { - restartUnits = ["miniflux.service"]; - }; + sops.secrets = lib.mapAttrs (_name: value: value // {sopsFile = ./secrets.yaml;}) { + "hysteria/auth" = { + restartUnits = ["hysteria.service"]; + }; + "pixivfe/environment" = { + restartUnits = ["pixivfe.service"]; + }; + "searx/environment" = { + restartUnits = ["searx.service"]; + }; + "miniflux/environment" = { + restartUnits = ["miniflux.service"]; }; }; diff --git a/nixos/profiles/opt-in/mihomo/default.nix b/nixos/profiles/opt-in/mihomo/default.nix index 647e2a8..089564f 100644 --- a/nixos/profiles/opt-in/mihomo/default.nix +++ b/nixos/profiles/opt-in/mihomo/default.nix @@ -25,7 +25,7 @@ }; ### sops-nix - sops.secrets = builtins.mapAttrs (_name: value: + sops.secrets = lib.mapAttrs (_name: value: value // { restartUnits = ["mihomo.service"]; @@ -42,7 +42,7 @@ sops.templates."clash.yaml".file = let convert = url: "https://sub.maoxiongnet.com/sub?target=clash&list=true&url=${url}"; substituteV2 = {src, ...} @ args: let - args' = builtins.removeAttrs args ["src"]; + args' = lib.removeAttrs args ["src"]; in pkgs.substitute { inherit src; diff --git a/nixos/profiles/opt-in/wireless/default.nix b/nixos/profiles/opt-in/wireless/default.nix index d8b179a..ade6664 100644 --- a/nixos/profiles/opt-in/wireless/default.nix +++ b/nixos/profiles/opt-in/wireless/default.nix @@ -1,5 +1,5 @@ {lib, ...}: { - sops.secrets = builtins.mapAttrs (_name: value: value // {sopsFile = ./secrets.yaml;}) { + sops.secrets = lib.mapAttrs (_name: value: value // {sopsFile = ./secrets.yaml;}) { "wireless/wangxiaobo".path = "/var/lib/iwd/wangxiaobo.psk"; "wireless/ImmortalWrt".path = "/var/lib/iwd/ImmortalWrt.psk"; };