treewide: replace builtins with lib

This commit is contained in:
Guanran Wang 2024-07-21 18:09:21 +08:00
parent cebe5df3d0
commit ae8f0f2433
Signed by: nyancat
GPG key ID: 91F97D9ED12639CF
11 changed files with 27 additions and 29 deletions

View file

@ -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

View file

@ -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}")

View file

@ -1,7 +1,7 @@
{lib, ...}: {
# Allow unfree applications
nixpkgs.config.allowUnfreePredicate = pkg:
builtins.elem (lib.getName pkg) [
lib.elem (lib.getName pkg) [
"keka"
];
}

View file

@ -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));
};
};
}

View file

@ -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"

View file

@ -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"
];

View file

@ -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;

View file

@ -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) [
];
};
}

View file

@ -31,8 +31,7 @@
boot.kernelPackages = pkgs.linuxPackages;
### Secrets
sops = {
secrets = builtins.mapAttrs (_name: value: value // {sopsFile = ./secrets.yaml;}) {
sops.secrets = lib.mapAttrs (_name: value: value // {sopsFile = ./secrets.yaml;}) {
"hysteria/auth" = {
restartUnits = ["hysteria.service"];
};
@ -46,7 +45,6 @@
restartUnits = ["miniflux.service"];
};
};
};
### Services
networking.firewall.allowedUDPPorts = [443]; # hysteria

View file

@ -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;

View file

@ -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";
};