mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 04:39:23 +08:00
Merge branch 'staging' into next
This commit is contained in:
@@ -130,7 +130,7 @@ inputs:
|
||||
nfs."/" = "192.168.84.0/24";
|
||||
};
|
||||
bugs = [ "xmunet" "backlight" "amdpstate" "iwlwifi" ];
|
||||
packages = { android-studio = {}; mathematica = {}; };
|
||||
packages = { android-studio = {}; mathematica = {}; vasp = {}; };
|
||||
user.users = [ "chn" "test" ];
|
||||
};
|
||||
boot.loader.grub =
|
||||
|
||||
@@ -62,6 +62,7 @@ inputs:
|
||||
];
|
||||
};
|
||||
};
|
||||
packages.vasp = {};
|
||||
user.users = [ "chn" "xll" "zem" "yjq" "gb" "wp" "hjp" "wm" "GROUPIII-1" "GROUPIII-2" "GROUPIII-3" ];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -80,6 +80,7 @@ inputs:
|
||||
};
|
||||
};
|
||||
};
|
||||
packages.vasp = {};
|
||||
user.users = [ "chn" "xll" "zem" "yjq" "gb" "wp" "hjp" "wm" "lly" "yxf" "hss" "zzn" ];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -90,7 +90,6 @@ inputs:
|
||||
freshrss.enable = true;
|
||||
send = {};
|
||||
huginn = {};
|
||||
fz-new-order = {};
|
||||
httpapi.enable = true;
|
||||
gitea = { enable = true; ssh = {}; };
|
||||
grafana = {};
|
||||
|
||||
@@ -66,27 +66,6 @@ freshrss:
|
||||
chn: ENC[AES256_GCM,data:Z4UmsXv1KiVfZMIQOEHH,iv:pF5lQLggkxm9y7taDVcp366JKp8U+8akNEdPA+Nf9Uo=,tag:0TajgUI/VgM3FxG1j6c/jA==,type:str]
|
||||
huginn:
|
||||
invitationCode: ENC[AES256_GCM,data:JDN913i+zf6+obWxrNAbgx1NJGPyewRm,iv:lqnjbSk46J0ZJN6ccbbiCiOK92W8fj2mWRwQHKqy2dc=,tag:UYZesryRlfAMo7xhKQ7zgw==,type:str]
|
||||
fz-new-order:
|
||||
token: ENC[AES256_GCM,data:JdMiu4du4S4fLg7b8LATG4g8NlahIFPvilGd1MsXNeMtnQs=,iv:fWBFYAVlfzi1dD/TpiA5N0JMY/LHTYPZGSh4sbK1BZc=,tag:LQTZe3DNk8xoy2+G4zld9A==,type:str]
|
||||
uids:
|
||||
#ENC[AES256_GCM,data:btt80rJcGg==,iv:DCBo36NMFiQO+dXom+AYTrSMYEAGCNXdMTJDIQVRlFA=,tag:LzoynD0J9surdmcFvVf/NQ==,type:comment]
|
||||
user0: ENC[AES256_GCM,data:53ag/e8f4aVEkUVszd7MzxNpDBBIkqGMneASW9/m5xU=,iv:LEZoitbzvTFAiXKZAPPOok/WaKsuTWgvd41Rq4/FMP4=,tag:opV15bhvDF1FR0UURsm+Iw==,type:str]
|
||||
#ENC[AES256_GCM,data:jXeZGm4rrw==,iv:hxZ6AU6FLzoUSJIeUh4zjuR6kvDfDhJCpvG47M+jRdc=,tag:AqMF7SJ96OEh0G8cgqvvuA==,type:comment]
|
||||
user1: ENC[AES256_GCM,data:emM3ffDBmymM9367YJG0lvYpw7iRl24fHSd5G4C4g6U=,iv:sJ9zLlgU2zZGFpeuIZXtL0Dqvd8RwbKU/a6HFdZTnvU=,tag:L6M7H24DXMvV55pYRiX8WA==,type:str]
|
||||
#ENC[AES256_GCM,data:gMDlZq2HXQ==,iv:hyJ2gkzrt0BZ3rO5rmz1tiS3jbrrA3VjpqjgPXQymjQ=,tag:aOWFyhuTjV9umsWJ0VjJDg==,type:comment]
|
||||
user2: ENC[AES256_GCM,data:b4jqm4Xm9dU2tYqqddKcHYcOh0Ol9W309fpQPcG2cQo=,iv:EKUDKnbYX8MTqd/G4NaQUVZ4mZAw3GvAlDe7XIVvVZQ=,tag:+oO6MaA6PFVbnP2ahfAArw==,type:str]
|
||||
#ENC[AES256_GCM,data:L0wkMIIuSA==,iv:j0LGq9Xe+Dru8bCwt93T51ZaK0ex/7CZJdBDn6jhq7w=,tag:EU4/62fe3p7QjpfSMAYHCQ==,type:comment]
|
||||
user3: ENC[AES256_GCM,data:dWJzu6S6T598TiKqX48LUcT1BAc0/gVy1tAknkvmg8k=,iv:KWl/av7a3hj27p+S2hhe2QpcNMFGJPsnnCjcaqzjOqc=,tag:HQbtRPxO8OnfKIBqTDjKlA==,type:str]
|
||||
#ENC[AES256_GCM,data:8/kYjPRSEA==,iv:etABb0TqNHhEs3/HGuRixEJUGhyXSTXI3cvhTTAUlXA=,tag:IfPzvdSamLcY1dRJls74GQ==,type:comment]
|
||||
user4: ENC[AES256_GCM,data:F6tbn2WBo9HrM+fmtf70GrNJyZ6qJ2HrNdJG788zMKM=,iv:Dx/7MUJVZO61u/DqwrrqmWIVpx4Qpi88SMflCRvj7Wc=,tag:WH6tsk/69+EEz2DS1srrNw==,type:str]
|
||||
config0:
|
||||
username: ENC[AES256_GCM,data:DDGErXyt,iv:7Z3U++o930QhngC+NzNna32F2AKSWjEFnJYXY00rCM4=,tag:L83e1KTQkVwSWSwhTwTzYQ==,type:str]
|
||||
password: ENC[AES256_GCM,data:Jy9Gbo0i,iv:ZthlQ0x5At9TUbh6MUiLkZUoVdCG0gp0SEyMtxKhnjM=,tag:fKmnopQ/sVFQsmb2ISOk0A==,type:str]
|
||||
comment: ENC[AES256_GCM,data:lb51oO8l,iv:4Iac4P+zfa7/T+aq5429VbdHoK7+WZkj1nC+yPOoIy0=,tag:NRl5GjjKn4OHfIGDNh+3MA==,type:str]
|
||||
config1:
|
||||
username: ENC[AES256_GCM,data:/QlSea1D,iv:0gMEI2JJudtKHE9J7IlI8Hsfo0jQwCy2Ap8EXxVqUVo=,tag:2DnWRv1b2VhtV5wSnnOzqg==,type:str]
|
||||
password: ENC[AES256_GCM,data:FHd4UPV2,iv:jI5BwcfxTBj2igdFUQtKS4LGnt5O96Kp3RPvnpXxFR8=,tag:Lfe8paHNQ44nRb/gk0oUbg==,type:str]
|
||||
comment: ENC[AES256_GCM,data:QILd5mRa,iv:mmM6h721UIXTuRL7k9TDOPdRrqMuq5M8krz5yWR20Mw=,tag:ALpQZjR6W0X44rST8U74NQ==,type:str]
|
||||
grafana:
|
||||
secret: ENC[AES256_GCM,data:1Wfq8QmhzKBObdktheFPySzXYlOJzHWbYYQXgn3beLOwSlW9f7bUn+wIrRoj1e8WlFJkAU2xywzjzzy/UwpSYA==,iv:/0YoHTs54O+cT6VVt1U5CYXr2qEdY2kijOlnMZMW4d0=,tag:SD/IELlcgfS7p9NBEa6D/g==,type:str]
|
||||
chn: ENC[AES256_GCM,data:8R92k7RH1491u6lfQdM0U3SG8TPi3vWhZyj810XSjnA=,iv:8v6ijLHgoTPT6MGoP/lWB+UEZCCgOpvfskWCJJ63Udo=,tag:k9SHzJ9d54Rny3n8EbksOw==,type:str]
|
||||
@@ -165,7 +144,7 @@ sops:
|
||||
d0h3aDh5QXFZYWJFdmNVYnJxQ3pBeVUKTl0XVvtwJcz+RpSylgDPl/R8msInxvWX
|
||||
eQGmrDHibeE1V+KSDiuNzC4MVRIrOnh1beHrhnVQ86HwPVgJqs2FoQ==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2025-05-16T02:55:19Z"
|
||||
mac: ENC[AES256_GCM,data:fsqb3NvXwyoGWfcJEV04XcWiifB/zEW+LU8twQ2sY3cZWR5KHAWgVXCXrCunYiSy/Q5nf+ldTgoXKdmNu1pVOJQQXRCY1q1y9MV36msAfIUc1hdkDlo2ka5+d4aBcpqr5nPo5ZU6GJ5by1p8WIPSOWCGfsqMMlKhIWJ+8YaqokU=,iv:cfveyxa/0/qKRHc6wsjAC9stZSkgF85khnp3LTtF+K0=,tag:5vVFg0isyJcg3Twhq5Ouaw==,type:str]
|
||||
lastmodified: "2025-05-26T10:55:01Z"
|
||||
mac: ENC[AES256_GCM,data:ek8oYslh51198fhnYy8LgZQBo3QEnCumeSzLEIEFp/bQshfPVtiMt29n37y89GZjfvd/UL/J/i4sxHqF328+MoMtIYwcDzJoHp/ZNJYZoM19UjEsPL5YemRRXz++gw3tvDgqPzYvtr93pg6+WcPNToIhzsew7QzYj2xLiSaecvQ=,iv:wk8RcTUbZwUHRAgNRuZ3SWWv6O57hHBCkccYNZiMwPQ=,tag:8bwhsrkk8bVMwThZQPkNXg==,type:str]
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.10.2
|
||||
|
||||
10
flake.lock
generated
10
flake.lock
generated
@@ -41,11 +41,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1746921594,
|
||||
"lastModified": 1748433430,
|
||||
"narHash": "sha256-rTmarmlP4SplEBAD+RM0kD5cB1F5g93H8ooSodxl8XE=",
|
||||
"owner": "CHN-beta",
|
||||
"repo": "bscpkgs",
|
||||
"rev": "01b2b0303435eb9a7ea33c1688feb4d70b9c88f9",
|
||||
"rev": "bd7d5b02b59c4807e551a43f43489f79206e326a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -531,11 +531,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1748069742,
|
||||
"narHash": "sha256-GcfcL/c9Q696oftYwlKjTZS1UTTQR7jSzxNa+imZ+tI=",
|
||||
"lastModified": 1748221239,
|
||||
"narHash": "sha256-zUlZp/ebt+EVBp1sA2ChVGz9MSdZpz/rIesOFSq23bo=",
|
||||
"owner": "CHN-beta",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "08e074b33507733ffb0ccb3006eb5fbad612ce6f",
|
||||
"rev": "3da8a40d3722ba5bc42e5076c774ac24daf3cc0d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.packages.vasp = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule {});
|
||||
# default = if builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ] then {} else null;
|
||||
# TODO: fix vasp
|
||||
default = null;
|
||||
};
|
||||
# TODO: add more options to correctly configure VASP
|
||||
{ type = types.nullOr (types.submodule {}); default = null; };
|
||||
config = let inherit (inputs.config.nixos.packages) vasp; in inputs.lib.mkIf (vasp != null)
|
||||
{
|
||||
nixos.packages.packages = with inputs.pkgs;
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.services.fz-new-order = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{ type = types.nullOr (types.submodule {}); default = null; };
|
||||
config = let inherit (inputs.config.nixos.services) fz-new-order; in inputs.lib.mkIf (fz-new-order != null)
|
||||
{
|
||||
users =
|
||||
{
|
||||
users.fz-new-order =
|
||||
{
|
||||
uid = inputs.config.nixos.user.uid.fz-new-order;
|
||||
group = "fz-new-order";
|
||||
home = "/var/lib/fz-new-order";
|
||||
createHome = true;
|
||||
isSystemUser = true;
|
||||
};
|
||||
groups.fz-new-order.gid = inputs.config.nixos.user.gid.fz-new-order;
|
||||
};
|
||||
systemd =
|
||||
{
|
||||
timers.fz-new-order =
|
||||
{
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = { OnBootSec = "10m"; OnUnitActiveSec = "10m"; Unit = "fz-new-order.service"; };
|
||||
};
|
||||
services.fz-new-order = rec
|
||||
{
|
||||
description = "fz-new-order";
|
||||
after = [ "network.target" ];
|
||||
requires = after;
|
||||
serviceConfig =
|
||||
{
|
||||
User = inputs.config.users.users."fz-new-order".name;
|
||||
Group = inputs.config.users.users."fz-new-order".group;
|
||||
WorkingDirectory = "/var/lib/fz-new-order";
|
||||
ExecStart =
|
||||
let
|
||||
src = inputs.pkgs.replaceVars ./main.cpp
|
||||
{ config_file = inputs.config.sops.templates."fz-new-order/config.json".path; };
|
||||
binary = inputs.pkgs.stdenv.mkDerivation
|
||||
{
|
||||
name = "fz-new-order";
|
||||
inherit src;
|
||||
buildInputs = with inputs.pkgs; [ jsoncpp.dev cereal fmt httplib ];
|
||||
dontUnpack = true;
|
||||
buildPhase =
|
||||
''
|
||||
runHook preBuild
|
||||
g++ -std=c++20 -O2 -o fz-new-order ${src} -ljsoncpp -lfmt
|
||||
runHook postBuild
|
||||
'';
|
||||
installPhase =
|
||||
''
|
||||
runHook preInstall
|
||||
mkdir -p $out/bin
|
||||
cp fz-new-order $out/bin/fz-new-order
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
in "${binary}/bin/fz-new-order";
|
||||
};
|
||||
};
|
||||
tmpfiles.rules =
|
||||
[
|
||||
"d /var/lib/fz-new-order 0700 fz-new-order fz-new-order"
|
||||
"Z /var/lib/fz-new-order - fz-new-order fz-new-order"
|
||||
];
|
||||
};
|
||||
sops = let userNum = 5; configNum = 2; in
|
||||
{
|
||||
templates."fz-new-order/config.json" =
|
||||
{
|
||||
owner = inputs.config.users.users."fz-new-order".name;
|
||||
group = inputs.config.users.users."fz-new-order".group;
|
||||
content = let placeholder = inputs.config.sops.placeholder; in builtins.toJSON
|
||||
{
|
||||
token = placeholder."fz-new-order/token";
|
||||
uids = builtins.map (j: placeholder."fz-new-order/uids/user${builtins.toString j}")
|
||||
(builtins.genList (n: n) userNum);
|
||||
config = builtins.map
|
||||
(i: builtins.listToAttrs (builtins.map
|
||||
(attrName: { name = attrName; value = placeholder."fz-new-order/config${toString i}/${attrName}"; })
|
||||
[ "username" "password" "comment" ]))
|
||||
(builtins.genList (n: n) configNum);
|
||||
};
|
||||
};
|
||||
secrets =
|
||||
{ "fz-new-order/token" = {}; }
|
||||
// (builtins.listToAttrs (builtins.map
|
||||
(i: { name = "fz-new-order/uids/user${toString i}"; value = {}; })
|
||||
(builtins.genList (n: n) userNum)))
|
||||
// (builtins.listToAttrs (builtins.concatLists (builtins.map
|
||||
(i: builtins.map
|
||||
(attrName: { name = "fz-new-order/config${builtins.toString i}/${attrName}"; value = {}; })
|
||||
[ "username" "password" "comment" ])
|
||||
(builtins.genList (n: n) configNum))));
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,244 +0,0 @@
|
||||
# include <iostream>
|
||||
# include <set>
|
||||
# include <sstream>
|
||||
# include <filesystem>
|
||||
# include <cereal/types/set.hpp>
|
||||
# include <cereal/archives/json.hpp>
|
||||
# include <fmt/format.h>
|
||||
# include <fmt/ranges.h>
|
||||
# include <httplib.h>
|
||||
# include <json/json.h>
|
||||
|
||||
std::string urlencode(std::string s)
|
||||
{
|
||||
auto hexchar = [](unsigned char c, unsigned char &hex1, unsigned char &hex2)
|
||||
{
|
||||
hex1 = c / 16;
|
||||
hex2 = c % 16;
|
||||
hex1 += hex1 <= 9 ? '0' : 'a' - 10;
|
||||
hex2 += hex2 <= 9 ? '0' : 'a' - 10;
|
||||
};
|
||||
const char *str = s.c_str();
|
||||
std::vector<char> v(s.size());
|
||||
v.clear();
|
||||
for (std::size_t i = 0, l = s.size(); i < l; i++)
|
||||
{
|
||||
char c = str[i];
|
||||
if
|
||||
(
|
||||
(c >= '0' && c <= '9')
|
||||
|| (c >= 'a' && c <= 'z')
|
||||
|| (c >= 'A' && c <= 'Z')
|
||||
|| c == '-' || c == '_' || c == '.' || c == '!' || c == '~'
|
||||
|| c == '*' || c == '\'' || c == '(' || c == ')'
|
||||
)
|
||||
v.push_back(c);
|
||||
else
|
||||
{
|
||||
v.push_back('%');
|
||||
unsigned char d1, d2;
|
||||
hexchar(c, d1, d2);
|
||||
v.push_back(d1);
|
||||
v.push_back(d2);
|
||||
}
|
||||
}
|
||||
return std::string(v.cbegin(), v.cend());
|
||||
}
|
||||
|
||||
void oneshot
|
||||
(
|
||||
const std::string& username, const std::string& password, const std::string& comment,
|
||||
const std::set<std::string>& wxuser, const std::string& token
|
||||
)
|
||||
{
|
||||
httplib::Client fzclient("http://scmv9.fengzhansy.com:8882");
|
||||
httplib::Client wxclient("http://wxpusher.zjiecode.com");
|
||||
auto& log = std::clog;
|
||||
|
||||
try
|
||||
{
|
||||
// get JSESSIONID
|
||||
auto cookie_jsessionid = [&]() -> std::string
|
||||
{
|
||||
log << "get /scmv9/login.jsp\n";
|
||||
auto result = fzclient.Get("/scmv9/login.jsp");
|
||||
if (result.error() != httplib::Error::Success)
|
||||
throw std::runtime_error("request failed");
|
||||
auto it = result.value().headers.find("Set-Cookie");
|
||||
if (it == result.value().headers.end() || it->first != "Set-Cookie")
|
||||
throw std::runtime_error("find cookie failed");
|
||||
log << fmt::format("set_cookie JSESSIONID {}\n", it->second.substr(0, it->second.find(';')));
|
||||
return it->second.substr(0, it->second.find(';'));
|
||||
}();
|
||||
|
||||
// login
|
||||
auto cookie_pppp = [&]() -> std::string
|
||||
{
|
||||
auto body = fmt::format("method=dologinajax&rand=1234&userc={}&mdid=P&passw={}", username, password);
|
||||
httplib::Headers headers =
|
||||
{
|
||||
{ "X-Requested-With", "XMLHttpRequest" },
|
||||
{
|
||||
"User-Agent",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"
|
||||
},
|
||||
{ "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" },
|
||||
{ "Origin", "http://scmv9.fengzhansy.com:8882" },
|
||||
{ "Referer", "http://scmv9.fengzhansy.com:8882/scmv9/login.jsp" },
|
||||
{ "Cookie", cookie_jsessionid }
|
||||
};
|
||||
log << "post /scmv9/data.jsp\n";
|
||||
auto result = fzclient.Post("/scmv9/data.jsp", headers, body, "application/x-www-form-urlencoded; charset=UTF-8");
|
||||
if (result.error() != httplib::Error::Success)
|
||||
throw std::runtime_error("request failed");
|
||||
log << fmt::format("set_cookie pppp {}\n", fmt::format("pppp={}%40{}", username, password));
|
||||
return fmt::format("pppp={}%40{}", username, password);
|
||||
}();
|
||||
|
||||
// get order list
|
||||
auto order_list = [&]() -> std::map<std::string, std::pair<std::string, std::string>>
|
||||
{
|
||||
auto body = fmt::format("method=dgate&rand=1234&op=scmmgr_pcggl&nv%5B%5D=opmode&nv%5B%5D=dd_qry&nv%5B%5D=bill&nv%5B%5D=&nv%5B%5D=storeid&nv%5B%5D=&nv%5B%5D=vendorid&nv%5B%5D={}&nv%5B%5D=qr_status&nv%5B%5D=&nv%5B%5D=ddprt&nv%5B%5D=%25&nv%5B%5D=fdate&nv%5B%5D=&nv%5B%5D=tdate&nv%5B%5D=&nv%5B%5D=shfdate&nv%5B%5D=&nv%5B%5D=shtdate&nv%5B%5D=&nv%5B%5D=fy_pno&nv%5B%5D=1&nv%5B%5D=fy_psize&nv%5B%5D=10", username);
|
||||
httplib::Headers headers =
|
||||
{
|
||||
{ "X-Requested-With", "XMLHttpRequest" },
|
||||
{
|
||||
"User-Agent",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"
|
||||
},
|
||||
{ "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" },
|
||||
{ "Origin", "http://scmv9.fengzhansy.com:8882"
|
||||
},
|
||||
{ "Referer", "http://scmv9.fengzhansy.com:8882/scmv9/SCM/cggl_po_qry.jsp" },
|
||||
{ "Cookie", fmt::format("{}; {}", cookie_jsessionid, cookie_pppp) }
|
||||
};
|
||||
log << "post /scmv9/data.jsp\n";
|
||||
auto result = fzclient.Post("/scmv9/data.jsp", headers, body, "application/x-www-form-urlencoded; charset=UTF-8");
|
||||
if (result.error() != httplib::Error::Success)
|
||||
throw std::runtime_error("request failed");
|
||||
log << fmt::format("get result {}\n", result.value().body);
|
||||
std::stringstream result_body(result.value().body);
|
||||
Json::Value root;
|
||||
result_body >> root;
|
||||
std::map<std::string, std::pair<std::string, std::string>> orders;
|
||||
for (unsigned i = 0; i < root["dt"][1].size(); i++)
|
||||
{
|
||||
log << fmt::format
|
||||
(
|
||||
"insert order {} {} {}\n", root["dt"][1][i].asString(), root["dt"][2][i].asString(),
|
||||
root["dt"][4][i].asString()
|
||||
);
|
||||
orders.insert({root["dt"][1][i].asString(), {root["dt"][2][i].asString(), root["dt"][4][i].asString()}});
|
||||
}
|
||||
return orders;
|
||||
}();
|
||||
|
||||
// read order old
|
||||
auto order_old = [&]() -> std::set<std::string>
|
||||
{
|
||||
if (!std::filesystem::exists("orders.json"))
|
||||
return {};
|
||||
else
|
||||
{
|
||||
std::ifstream ins("orders.json");
|
||||
cereal::JSONInputArchive ina(ins);
|
||||
std::set<std::string> data;
|
||||
cereal::load(ina, data);
|
||||
return data;
|
||||
}
|
||||
}();
|
||||
|
||||
// push new order info
|
||||
for (const auto& order : order_list)
|
||||
if (!order_old.contains(order.first))
|
||||
{
|
||||
auto body = fmt::format
|
||||
(
|
||||
"method=dgate&rand=1234&op=scmmgr_pcggl&nv%5B%5D=opmode&nv%5B%5D=ddsp_qry&nv%5B%5D=bill&nv%5B%5D={}",
|
||||
order.first
|
||||
);
|
||||
httplib::Headers headers =
|
||||
{
|
||||
{ "X-Requested-With", "XMLHttpRequest" },
|
||||
{
|
||||
"User-Agent",
|
||||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"
|
||||
},
|
||||
{ "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" },
|
||||
{ "Origin", "http://scmv9.fengzhansy.com:8882" },
|
||||
{ "Referer", "http://scmv9.fengzhansy.com:8882/scmv9/SCM/cggl_po_qry.jsp" },
|
||||
{ "Cookie", fmt::format("{}; {}", cookie_jsessionid, cookie_pppp) }
|
||||
};
|
||||
log << "post /scmv9/data.jsp\n";
|
||||
auto result = fzclient.Post
|
||||
("/scmv9/data.jsp", headers, body, "application/x-www-form-urlencoded; charset=UTF-8");
|
||||
if (result.error() != httplib::Error::Success)
|
||||
throw std::runtime_error("request failed");
|
||||
log << fmt::format("get result {}\n", result.value().body);
|
||||
std::stringstream result_body(result.value().body);
|
||||
Json::Value root;
|
||||
result_body >> root;
|
||||
|
||||
std::stringstream push_body;
|
||||
double all_cost = 0;
|
||||
push_body << fmt::format
|
||||
(
|
||||
"{} {} {}店\n", comment, order.second.second.substr(order.second.second.find('-') + 1),
|
||||
order.second.first.substr(1, 2)
|
||||
);
|
||||
for (unsigned i = 0; i < root["dt"][6].size(); i++)
|
||||
{
|
||||
push_body << fmt::format
|
||||
(
|
||||
"{} {}{}\n", root["dt"][6][i].asString().substr(root["dt"][6][i].asString().length() - 4),
|
||||
root["dt"][7][i].asString(), root["dt"][5][i].asString()
|
||||
);
|
||||
// 订货金额 maybe empty ???
|
||||
if (root["dt"][10][i].asString() != "")
|
||||
all_cost += std::stod(root["dt"][10][i].asString());
|
||||
}
|
||||
push_body << fmt::format("共{:.2f}元\n", all_cost);
|
||||
log << fmt::format("push to wx {}\n", push_body.str());
|
||||
auto encoded = urlencode(push_body.str());
|
||||
|
||||
for (const auto& wxu : wxuser)
|
||||
{
|
||||
auto path = fmt::format
|
||||
("/api/send/message/?appToken={}&content={}&uid={}", token, encoded, wxu);
|
||||
auto wxresult = wxclient.Get(path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// save data
|
||||
{
|
||||
for (const auto& order : order_list)
|
||||
if (!order_old.contains(order.first))
|
||||
order_old.insert(order.first);
|
||||
std::ofstream os("orders.json");
|
||||
cereal::JSONOutputArchive oa(os);
|
||||
cereal::save(oa, order_old);
|
||||
}
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
log << ex.what() << "\n" << std::flush;
|
||||
std::terminate();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
Json::Value configs;
|
||||
std::ifstream("@config_file@") >> configs;
|
||||
auto config_uids = configs["uids"];
|
||||
std::set<std::string> uids;
|
||||
for (auto& uid : config_uids)
|
||||
uids.insert(uid.asString());
|
||||
for (auto& config : configs["config"])
|
||||
oneshot
|
||||
(
|
||||
config["username"].asString(), config["password"].asString(), config["comment"].asString(),
|
||||
uids, configs["token"].asString()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,26 +13,26 @@ let
|
||||
{ cudaForwardCompat = nixpkgs.cuda.forwardCompat; })
|
||||
);
|
||||
allowInsecurePredicate = p: inputs.lib.warn "Allowing insecure package ${p.name or "${p.pname}-${p.version}"}" true;
|
||||
config = cudaConfig
|
||||
// {
|
||||
inherit allowInsecurePredicate;
|
||||
allowUnfree = true;
|
||||
android_sdk.accept_license = true;
|
||||
}
|
||||
// (inputs.lib.optionalAttrs (nixpkgs.march != null)
|
||||
{
|
||||
# TODO: test znver3 do use AVX
|
||||
oneapiArch = let match = {}; in match.${nixpkgs.march} or nixpkgs.march;
|
||||
nvhpcArch = nixpkgs.march;
|
||||
contentAddressedByDefault = true;
|
||||
})
|
||||
// (inputs.lib.optionalAttrs (nixpkgs.nixRoot != null)
|
||||
{ nix = { storeDir = "${nixpkgs.nixRoot}/store"; stateDir = "${nixpkgs.nixRoot}/var"; }; });
|
||||
in platformConfig //
|
||||
{
|
||||
config = cudaConfig //
|
||||
{
|
||||
inherit allowInsecurePredicate;
|
||||
allowUnfree = true;
|
||||
android_sdk.accept_license = true;
|
||||
}
|
||||
// (inputs.lib.optionalAttrs (nixpkgs.march != null)
|
||||
{
|
||||
# TODO: test znver3 do use AVX
|
||||
oneapiArch = let match = {}; in match.${nixpkgs.march} or nixpkgs.march;
|
||||
nvhpcArch = nixpkgs.march;
|
||||
# contentAddressedByDefault = true;
|
||||
})
|
||||
// (inputs.lib.optionalAttrs (nixpkgs.nixRoot != null)
|
||||
{ nix = { storeDir = "${nixpkgs.nixRoot}/store"; stateDir = "${nixpkgs.nixRoot}/var"; }; });
|
||||
inherit config;
|
||||
overlays =
|
||||
[
|
||||
inputs.topInputs.bscpkgs.overlays.default
|
||||
inputs.topInputs.nur-xddxdd.overlays.inSubTree
|
||||
inputs.topInputs.shadowrz.overlays.default
|
||||
inputs.topInputs.nix-vscode-extensions.overlays.default
|
||||
@@ -59,7 +59,7 @@ in platformConfig //
|
||||
};
|
||||
libvirt = (prev.libvirt.override { iptables = final.nftables; }).overrideAttrs
|
||||
(prev: { patches = prev.patches or [] ++ [ ./libvirt.patch ]; });
|
||||
root = prev.root.overrideAttrs (prev:
|
||||
root = (prev.root.override { stdenv = final.gcc13Stdenv; }).overrideAttrs (prev:
|
||||
{
|
||||
patches = prev.patches or [] ++ [ ./root.patch ];
|
||||
cmakeFlags = prev.cmakeFlags ++ [ "-DCMAKE_CXX_STANDARD=23" ];
|
||||
@@ -72,7 +72,7 @@ in platformConfig //
|
||||
{
|
||||
pkgs-2305 = "nixpkgs-2305";
|
||||
pkgs-2311 = "nixpkgs-2311";
|
||||
pkgs-2411 = "nixpkgs-2411";
|
||||
pkgs-2411 = { source = "nixpkgs-2411"; overlay = inputs.topInputs.bscpkgs.overlays.default; };
|
||||
pkgs-unstable =
|
||||
{
|
||||
source = "nixpkgs-unstable";
|
||||
@@ -116,12 +116,7 @@ in platformConfig //
|
||||
packages = name: import inputs.topInputs.${source.${name}.source or source.${name}}
|
||||
{
|
||||
localSystem = platformConfig.hostPlatform or { inherit (platformConfig) system; };
|
||||
config = cudaConfig //
|
||||
{
|
||||
allowUnfree = true;
|
||||
# contentAddressedByDefault = true;
|
||||
inherit allowInsecurePredicate;
|
||||
};
|
||||
inherit config;
|
||||
overlays = [(source.${name}.overlay or (_: _: {}))];
|
||||
};
|
||||
in builtins.listToAttrs (builtins.map
|
||||
@@ -157,8 +152,11 @@ in platformConfig //
|
||||
{
|
||||
scipy = prev.scipy.overridePythonAttrs (prev:
|
||||
{ disabledTests = prev.disabledTests or [] ++ [ "test_hyp2f1" ]; });
|
||||
rich = prev.rich.overridePythonAttrs (prev:
|
||||
{ disabledTests = prev.disabledTests or [] ++ [ "test_brokenpipeerror" ]; });
|
||||
# paperwork-backend = prev.paperwork-backend.overrideAttrs (prev: { doCheck = false; });
|
||||
})];
|
||||
inherit (final.pkgs-2411) intelPackages_2023;
|
||||
})
|
||||
# // (inputs.lib.optionalAttrs (nixpkgs.march == "silvermont")
|
||||
# { c-blosc = prev.c-blosc.overrideAttrs { doCheck = false; }; })
|
||||
|
||||
Reference in New Issue
Block a user