Compare commits

..

1 Commits

Author SHA1 Message Date
chn
8924f88901 pc: enable ttyd 2024-02-04 22:46:16 +08:00
204 changed files with 3471 additions and 8437 deletions

View File

@@ -1,3 +0,0 @@
CompileFlags:
Add: [ -Wall, -Wextra, -std=c++23 ]
Compiler: gcc

1
.envrc
View File

@@ -1 +0,0 @@
use flake

2
.gitattributes vendored
View File

@@ -1,4 +1,2 @@
*.png filter=lfs diff=lfs merge=lfs -text
*.icm filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.webp filter=lfs diff=lfs merge=lfs -text

4
.gitignore vendored
View File

@@ -1,7 +1,3 @@
result
result-man
outputs
.direnv
build
.vscode
.cache

View File

@@ -5,47 +5,35 @@ keys: # cat /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age
- &vps7 age137x7csalutwvfygvvzpemlsywvdxj3j4z93a50z2sjx03w6zau8q3r5902
- &surface age1ck5vzs0xqx0jplmuksrkh45xwmkm2t05m2wyq5k2w2mnkmn79fxs6tvl3l
- &nas age19lhcwk37jmvn6z0v4dpdfh0k4u23f76twdjknc0p7atktf37rd7s4t4wj3
- &xmupc1 age1hnarptkze0ujpp05dqr8uma04cxg9zqcx68qgpks5uf5l6rpk5gqhh8wxg
- &xmupc2 age1l4stuz0vr7gs7pqwjrmezam44702jp2vmqaqyxw0l0r42kf9updq4dfhrw
- &pi3b age1yjgswvexp0x0de0sw4u6hamruzeluxccmx2enxazl6pwhhsr2s9qlxdemq
- &xmupc1 age19ax6vm3pv8rph5tq3mmehd9sy9jk823tw8svsd790r0lkslycquqvlwz9m
creation_rules:
- path_regex: devices/pc/.*$
- path_regex: secrets/pc/.*$
key_groups:
- age:
- *chn
- *pc
- path_regex: devices/vps6/.*$
- path_regex: secrets/vps6/.*$
key_groups:
- age:
- *chn
- *vps6
- path_regex: devices/vps7/.*$
- path_regex: secrets/vps7/.*$
key_groups:
- age:
- *chn
- *vps7
- path_regex: devices/nas/.*$
- path_regex: secrets/nas/.*$
key_groups:
- age:
- *chn
- *nas
- path_regex: devices/surface/.*$
- path_regex: secrets/surface/.*$
key_groups:
- age:
- *chn
- *surface
- path_regex: devices/xmupc1/.*$
- path_regex: secrets/xmupc1/.*$
key_groups:
- age:
- *chn
- *xmupc1
- path_regex: devices/xmupc2/.*$
key_groups:
- age:
- *chn
- *xmupc2
- path_regex: devices/pi3b/.*$
key_groups:
- age:
- *chn
- *pi3b

View File

@@ -37,18 +37,17 @@ inputs:
delayedMount = [ "/" "/nix" ];
};
swap = [ "/nix/swap/swap" ];
rollingRootfs.waitDevices = [ "/dev/mapper/root2" ];
rollingRootfs = { device = "/dev/mapper/root1"; path = "/nix/rootfs"; };
};
initrd.sshd.enable = true;
grub.installDevice = "efi";
nixpkgs.march = "silvermont";
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
kernel.patches = [ "cjktty" "lantian" ];
networking = { hostname = "nas"; networkd = {}; };
gui.preferred = false;
kernel.patches = [ "cjktty" ];
networking.hostname = "nas";
};
hardware = { cpus = [ "intel" ]; gpu.type = "intel"; };
packages.packageSet = "desktop-fat";
hardware = { cpus = [ "intel" ]; gpus = [ "intel" ]; };
packages.packageSet = "server";
services =
{
snapper.enable = true;
@@ -59,15 +58,24 @@ inputs:
hostsAllowed = "192.168. 127.";
shares = { home.path = "/home"; root.path = "/"; };
};
sshd = {};
xray.client.dae.wanInterface = [ "enp3s0" ];
xrdp = { enable = true; hostname = [ "nas.chn.moe" "office.chn.moe" ]; };
groupshare = {};
smartd.enable = true;
beesd.instances =
sshd = { enable = true; passwordAuthentication = true; };
xray.client =
{
root = { device = "/"; hashTableSizeMB = 4096; threads = 4; };
nix = { device = "/nix"; hashTableSizeMB = 128; };
enable = true;
serverAddress = "74.211.99.69";
serverName = "vps6.xserver.chn.moe";
dns.extraInterfaces = [ "docker0" ];
};
groupshare.enable = true;
smartd.enable = true;
beesd =
{
enable = true;
instances =
{
root = { device = "/"; hashTableSizeMB = 2048; };
nix = { device = "/nix"; hashTableSizeMB = 128; };
};
};
frpClient =
{
@@ -85,7 +93,7 @@ inputs:
wireguardIp = "192.168.83.4";
};
};
user.users = [ "chn" "xll" "zem" "yjq" "gb" ];
users.users = [ "chn" "xll" "zem" "yjq" "yxy" ];
};
};
}

View File

@@ -10,22 +10,22 @@ inputs:
{
mount =
{
vfat."/dev/disk/by-uuid/E58F-416A" = "/boot/efi";
vfat."/dev/disk/by-uuid/3F57-0EBE" = "/boot/efi";
btrfs =
{
"/dev/disk/by-uuid/066be4fd-8617-4fe1-9654-c133c2996d33"."/" = "/boot";
"/dev/disk/by-uuid/02e426ec-cfa2-4a18-b3a5-57ef04d66614"."/" = "/boot";
"/dev/mapper/root" = { "/nix" = "/nix"; "/nix/rootfs/current" = "/"; };
};
};
decrypt.auto =
{
"/dev/disk/by-uuid/4c73288c-bcd8-4a7e-b683-693f9eed2d81" = { mapper = "root"; ssd = true; };
"/dev/disk/by-uuid/55fdd19f-0f1d-4c37-bd4e-6df44fc31f26" = { mapper = "root"; ssd = true; };
"/dev/disk/by-uuid/4be45329-a054-4c20-8965-8c5b7ee6b35d" =
{ mapper = "swap"; ssd = true; before = [ "root" ]; };
};
swap = [ "/dev/mapper/swap" ];
resume = "/dev/mapper/swap";
rollingRootfs = {};
rollingRootfs = { device = "/dev/mapper/root"; path = "/nix/rootfs"; };
};
grub =
{
@@ -50,19 +50,22 @@ inputs:
# SERIALIZE SGX WAITPKG WIDEKL XSAVE XSAVEOPT
"alderlake"
];
remote.master = { enable = true; hosts = [ "xmupc1" "xmupc2" ]; };
};
nixpkgs =
{ march = "znver4"; cuda = { enable = true; capabilities = [ "8.9" ]; forwardCompat = false; }; };
kernel = { varient = "cachyos"; patches = [ "cjktty" "hibernate-progress" ]; };
kernel.patches = [ "cjktty" "lantian" ];
networking.hostname = "pc";
sysctl.laptop-mode = 5;
};
hardware =
{
cpus = [ "amd" ];
gpu = { type = "amd+nvidia"; prime.busId = { amd = "8:0:0"; nvidia = "1:0:0"; }; dynamicBoost = true; };
legion = {};
gpus = [ "nvidia" ];
bluetooth.enable = true;
joystick.enable = true;
printer.enable = true;
sound.enable = true;
legion.enable = true;
};
packages.packageSet = "workstation";
virtualization =
@@ -89,16 +92,29 @@ inputs:
share.path = "/home/chn/share";
};
};
sshd = {};
sshd.enable = true;
xray.client =
{
dnsmasq.hosts = builtins.listToAttrs (builtins.map
(name: { inherit name; value = "74.211.99.69"; })
[ "mirism.one" "beta.mirism.one" "ng01.mirism.one" "initrd.vps6.chn.moe" ]);
dae.wanInterface = [ "wlp4s0" "enp5s0" ];
enable = true;
serverAddress = "74.211.99.69";
serverName = "vps6.xserver.chn.moe";
dns =
{
extraInterfaces = [ "docker0" ];
hosts =
{
"mirism.one" = "74.211.99.69";
"beta.mirism.one" = "74.211.99.69";
"ng01.mirism.one" = "74.211.99.69";
"debug.mirism.one" = "127.0.0.1";
"initrd.vps6.chn.moe" = "74.211.99.69";
"nix-store.chn.moe" = "127.0.0.1";
"initrd.nas.chn.moe" = "192.168.1.185";
};
};
};
firewall.trustedInterfaces = [ "virbr0" "waydroid0" ];
acme.cert."debug.mirism.one" = {};
acme = { enable = true; cert."debug.mirism.one" = {}; };
frpClient =
{
enable = true;
@@ -109,7 +125,7 @@ inputs:
nix-serve = { enable = true; hostname = "nix-store.chn.moe"; };
smartd.enable = true;
misskey.instances.misskey.hostname = "xn--qbtm095lrg0bfka60z.chn.moe";
beesd.instances.root = { device = "/"; hashTableSizeMB = 4096; threads = 4; };
beesd = { enable = true; instances.root = { device = "/"; hashTableSizeMB = 2048; threads = 4; }; };
wireguard =
{
enable = true;
@@ -117,60 +133,22 @@ inputs:
publicKey = "l1gFSDCeBxyf/BipXNvoEvVvLqPgdil84nmr5q6+EEw=";
wireguardIp = "192.168.83.3";
};
gamemode = { enable = true; drmDevice = 1; };
slurm = { enable = true; cpu = { cores = 16; threads = 2; }; memoryMB = 90112; gpus."4060" = 1; };
xrdp =
{
enable = true;
hostname = [ "pc.chn.moe" ];
};
};
bugs = [ "xmunet" "backlight" "amdpstate" "suspend-hibernate-no-platform" ];
bugs = [ "xmunet" "backlight" "amdpstate" ];
};
networking.extraHosts = "74.211.99.69 mirism.one beta.mirism.one ng01.mirism.one";
services.colord.enable = true;
virtualisation.virtualbox.host = { enable = true; enableExtensionPack = true; };
specialisation =
# use plasma-x11 as default, instead of plasma-wayland
services.xserver.displayManager =
{
nvidia.configuration =
{
nixos =
{
hardware.gpu.type = inputs.lib.mkForce "nvidia";
services.gamemode.drmDevice = inputs.lib.mkForce 0;
};
system.nixos.tags = [ "nvidia" ];
};
hybrid-sync.configuration =
{
nixos.hardware.gpu.prime.mode = "sync";
system.nixos.tags = [ "hybrid-sync" ];
};
amd.configuration =
{
nixos.hardware.gpu = { type = inputs.lib.mkForce "amd"; dynamicBoost = inputs.lib.mkForce false; };
boot =
{
extraModprobeConfig =
''
blacklist nouveau
options nouveau modeset=0
'';
blacklistedKernelModules = [ "nvidia" "nvidia_drm" "nvidia_modeset" ];
};
services.udev.extraRules =
''
# Remove NVIDIA USB xHCI Host Controller devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{power/control}="auto", ATTR{remove}="1"
# Remove NVIDIA USB Type-C UCSI devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{power/control}="auto", ATTR{remove}="1"
# Remove NVIDIA Audio devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{power/control}="auto", ATTR{remove}="1"
# Remove NVIDIA VGA/3D controller devices
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", ATTR{power/control}="auto", ATTR{remove}="1"
'';
system.nixos.tags = [ "amd" ];
};
defaultSession = inputs.lib.mkForce "plasma";
setupCommands = "${inputs.pkgs.xcalib}/bin/xcalib -d :0 ${./color/TPLCD_161B_Default.icm}";
};
virtualisation.virtualbox.host = { enable = true; enableExtensionPack = true; };
hardware.nvidia.forceFullCompositionPipeline = true;
services.ttyd =
{
enable = true;
username = "ttyd";
passwordFile = inputs.pkgs.writeText "ttydpw" "0000";
};
};
}

View File

@@ -1,24 +0,0 @@
{
"data": "ENC[AES256_GCM,data:ftogJ/2oPME8sVbyNAuI3t3GEzUmdCadyjf2g/bjGNx3AoV0jU0SDxnBLDFfoR1rEtV00zfgCMPDGsEXavg+QVvoICpvvhckXMOLXe37H3Ff0wDVJtL4BBIK3oVh/SiYaRm/+uR0x6HW37KX50RRvKvpQoRdMVNnvtKbMjmQVIA=,iv:MOHfTIavoU643K10jSR3HruzoofOqqVspYgiaLc294o=,tag:zjDTPKwAOh/nqkquvAQpbw==,type:str]",
"sops": {
"kms": null,
"gcp_kms": null,
"azure_kv": null,
"hc_vault": null,
"age": [
{
"recipient": "age19ax6vm3pv8rph5tq3mmehd9sy9jk823tw8svsd790r0lkslycquqvlwz9m",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA5TTB1bHFXcDhoMk1QVzJ0\nUUplcGVBVUhoOEt0Rnc2ZStDUUpjZmV0eGpvCjFQSGl4TjlMT2R5RExNZWxwOUtz\nSWhhSUtFN0JISzJhclpCMFZDQ09jK28KLS0tIGJydDNoY3hBbEhBYUNYZGZCaWpQ\nQnVDalJCcWpIRTdVaWkzeGVNSGpDRWsKWXoMC8NApfenn191aRwdAjD0iM5+C3R6\nXKpHxfhc1Gf6paxBhketFU+AwWsKiBDKh0gntV49F+YSriPa7uI3FA==\n-----END AGE ENCRYPTED FILE-----\n"
},
{
"recipient": "age1ffvr5pqd2lfj24e3fh53s92z6h76fda3du4y4k6r3yjumdwvpfgqzj033a",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAzclYwVjdOZnQ1Y2dlUi9n\naXQya21QVHZ0KzMxTkVuTEJuazB4WklqdFdvCmpMd0h6OXUvZSttOFpmeUdsSlNs\nQkhQaVJqVFdidFNMejljV2h3WUFTaFUKLS0tIGNBemY5R1N3T00zMEthZjBsWXZh\nVXRtNG5UV3I3WG5LYUphNUNyUDI5WXcKVQpMe3zYgzHOtQQvo8Vvz94lYR6TBFuV\nD7ztr4rD/Vdk3hkSGZQvdzGjNDdGpac38LUN9vtFQbzMofykcn/etw==\n-----END AGE ENCRYPTED FILE-----\n"
}
],
"lastmodified": "2024-02-24T05:48:31Z",
"mac": "ENC[AES256_GCM,data:kCLcS6xeMijD8Bxa0MBUbFH2pdXX6BdGL1SztHHPet8loMkiCfgEiyp9l/QjszWa3G6zx3K+0wXXtRXmrNAxThnIgMZQVGCy4Ucw7fp8Pral/5eaJNlZGb56JQPF9ZDHb9YQPDPImaEAKYUtzayyaZAGJGlCmIIhVVhXTx7iiig=,iv:MXRDA/6YnVUbLdYAIrMvrdb2iPsi4Bmr06SPCU8CCVc=,tag:9hT7Xo0tRnHTgAaivKj4QQ==,type:str]",
"pgp": null,
"unencrypted_suffix": "_unencrypted",
"version": "3.8.1"
}
}

View File

@@ -1,29 +0,0 @@
inputs:
{
config =
{
nixos =
{
system =
{
fileSystems =
{
mount =
{
vfat."/dev/disk/by-uuid/CE84-E0D8" = "/boot/efi";
btrfs."/dev/disk/by-uuid/61f51d93-d3e5-4028-a903-332fafbfd365" =
{ "/nix/rootfs/current" = "/"; "/nix" = "/nix"; "/nix/boot" = "/boot"; };
};
rollingRootfs = {};
};
grub.installDevice = "efi";
networking = { hostname = "pcarm"; networkd = {}; };
binfmt.enable = false;
nixpkgs.arch = "aarch64";
kernel.varient = "nixos";
};
packages.packageSet = "server";
services.sshd = {};
};
};
}

View File

@@ -1,44 +0,0 @@
inputs:
{
config =
{
nixos =
{
system =
{
fileSystems =
{
mount =
{
vfat."/dev/disk/by-uuid/ABC6-6B3E" = "/boot/efi";
btrfs."/dev/disk/by-uuid/c459c6c0-23a6-4ef2-945a-0bfafa9a45b6" =
{ "/nix/rootfs/current" = "/"; "/nix" = "/nix"; "/nix/boot" = "/boot"; };
};
swap = [ "/nix/swap/swap" ];
rollingRootfs = {};
};
grub.installDevice = "efi";
networking = { hostname = "pi3b"; networkd = {}; };
binfmt.enable = false;
nixpkgs.arch = "aarch64";
kernel.varient = "nixos";
};
packages.packageSet = "server";
services =
{
# snapper.enable = true;
sshd = {};
xray.client.dae.wanInterface = [ "enu1u1" ];
fail2ban = {};
wireguard =
{
enable = true;
peers = [ "vps6" ];
publicKey = "X5SwWQk3JDT8BDxd04PYXTJi5E20mZKP6PplQ+GDnhI=";
wireguardIp = "192.168.83.8";
};
beesd.instances.root = { device = "/"; hashTableSizeMB = 32; };
};
};
};
}

View File

@@ -1,33 +0,0 @@
xray-client:
uuid: ENC[AES256_GCM,data:82Xg9VkmkLrKKcZfojA7dHqqMZh45n+eL4T5qZ1z/xy9k0q5,iv:/2j9flBDwjY6JW2mHYo1S2VE+ruu6gxrw8BzSyoiPcc=,tag:iq8wzfIRyq1T18k3vStVGw==,type:str]
wireguard:
privateKey: ENC[AES256_GCM,data:8whySpY/4WPWx2+t7IOgn+qjKCsv+BgRtaAFLrP8L0fV3TJdLob5vwDplHk=,iv:kXTDwOyJNzbjPtlzQqNsXtuk3EXFdF9CAsYkvImbyDE=,tag:tsK9nCMmwEb0c08rJ3Iwyg==,type:str]
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age19ax6vm3pv8rph5tq3mmehd9sy9jk823tw8svsd790r0lkslycquqvlwz9m
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB6TzU0U2Facm5yWkYrREgw
a1Fxc1MxaHYwRWUzUHpsbDBHYVoxb1NKVDAwCjNuUFlabzJ0aWtGMFBQb05nSlRP
akwrWDI0QnZBYkFmSUpWZFFnYmQ2aDQKLS0tIGlIQ3lTREN4WXgxV3pNdjdaakF6
ZnppV1ZRZzZ5Smt2NGsyRndjTFdnV00KaWVPGLWPnqINH6AHKS/84kuYy/v1v4Tb
QdehcMiq5ZF5XLqOX5sMDLu8h96FIklqOSTZNFkzr+s9VYv/UO58rg==
-----END AGE ENCRYPTED FILE-----
- recipient: age1yjgswvexp0x0de0sw4u6hamruzeluxccmx2enxazl6pwhhsr2s9qlxdemq
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAyTEZERkRSZUdSN2dySnlI
aDFjdXFCWnlJZlpYQmR1WEE2RzdCaVp1WFEwCjd1N1ZpMUExZ0ZBWmFwSHg3RUs4
RkRYTjRMWmE5cTA4Z2JJUGgyN05HSmMKLS0tIFpKZmd2Q2k2bnNYK1V2ZnNQNUxH
aDU3Vm95ZkpvSTJDMjJEOFY1ZjhrQlUKLdMYiOj6tlzwLpwZsTQVSQ8hHart0ba3
NS7+SprzJRb0hQXrvyU6s9zho8dPOw8wiGbscmMXSVS/Kar3eQigmg==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2024-03-28T13:31:33Z"
mac: ENC[AES256_GCM,data:fuppF9gFh3O6ZqJRTcVxNqVlz2y5f4xR39JIeInKblh4hNhrdnQg7oh8repoZeXHVRewGeGyxSqzUg+Twy8J+q+d6TSmiDVViD/SHse5rPns2Egt671geF7JmGEB/yKSCbECjGCp0QFgYYEg/vUOaV3v1a0s7LLTE/t2haPIaYc=,iv:f4T7JGxKB3WmEtETuSH7ApKRJ8ptPwZPfspyqc8+vmM=,tag:GF5br+e/p6qHsNCTjfIBCA==,type:str]
pgp: []
unencrypted_suffix: _unencrypted
version: 3.8.1

View File

@@ -26,37 +26,56 @@ inputs:
};
swap = [ "/dev/mapper/swap" ];
resume = "/dev/mapper/swap";
rollingRootfs = {};
rollingRootfs = { device = "/dev/mapper/root"; path = "/nix/rootfs"; };
};
nixpkgs.march = "skylake";
grub.installDevice = "efi";
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
kernel.patches = [ "cjktty" "lantian" "surface" ];
kernel.patches = [ "cjktty" "lantian" ];
networking.hostname = "surface";
};
hardware = { cpus = [ "intel" ]; gpu.type = "intel"; };
hardware =
{
cpus = [ "intel" ];
gpus = [ "intel" ];
bluetooth.enable = true;
joystick.enable = true;
printer.enable = true;
sound.enable = true;
};
packages.packageSet = "desktop-fat";
virtualization = { docker.enable = true; waydroid.enable = true; };
services =
{
snapper.enable = true;
fontconfig.enable = true;
sshd = {};
xray.client.dae.wanInterface = [ "wlp2s0" ];
firewall.trustedInterfaces = [ "virbr0" ];
wireguard =
sshd.enable = true;
xray.client =
{
enable = true;
peers = [ "vps6" ];
publicKey = "j7qEeODVMH31afKUQAmKRGLuqg8Bxd0dIPbo17LHqAo=";
wireguardIp = "192.168.83.5";
serverAddress = "74.211.99.69";
serverName = "vps6.xserver.chn.moe";
dns.extraInterfaces = [ "docker0" ];
};
beesd.instances.root = { device = "/"; hashTableSizeMB = 512; };
firewall.trustedInterfaces = [ "virbr0" ];
};
bugs = [ "xmunet" ];
};
boot.kernelParams = [ "intel_iommu=off" ];
boot.kernelPackages =
let
originalKernel = inputs.pkgs.linuxPackages_xanmod_latest.kernel;
version = originalKernel.version;
majorVersion =
let versionArray = builtins.splitVersion version;
in "${builtins.elemAt versionArray 0}.${builtins.elemAt versionArray 1}";
repoFile = "${inputs.topInputs.nixos-hardware}/microsoft/surface/common/kernel/linux-package.nix";
inherit (inputs.pkgs.callPackage repoFile {}) repos;
patchDir = repos.linux-surface + "/patches/${majorVersion}";
patchFile = "${inputs.topInputs.nixos-hardware}/microsoft/surface/common/kernel/linux-6.6.x/patches.nix";
kernelPatches = inputs.pkgs.callPackage patchFile { inherit (inputs.lib) kernel; inherit version patchDir; };
in
inputs.lib.mkForce (inputs.pkgs.linuxPackagesFor (originalKernel.override
(prev: { kernelPatches = prev.kernelPatches ++ kernelPatches; })));
environment.systemPackages = with inputs.pkgs; [ maliit-keyboard maliit-framework ];
powerManagement.resumeCommands = ''${inputs.pkgs.systemd}/bin/systemctl restart iptsd'';
};
}

View File

@@ -23,20 +23,20 @@ inputs:
delayedMount = [ "/" ];
};
swap = [ "/nix/swap/swap" ];
rollingRootfs = {};
rollingRootfs = { device = "/dev/mapper/root"; path = "/nix/rootfs"; };
};
grub.installDevice = "/dev/disk/by-path/pci-0000:00:05.0-scsi-0:0:0:0";
nixpkgs.march = "sandybridge";
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
initrd.sshd.enable = true;
networking = { hostname = "vps6"; networkd = {}; };
networking.hostname = "vps6";
};
packages.packageSet = "server";
services =
{
snapper.enable = false;
sshd = {};
xray.server = { serverName = "vps6.xserver.chn.moe"; userNumber = 14; };
snapper.enable = true;
sshd.enable = true;
xray.server = { enable = true; serverName = "vps6.xserver.chn.moe"; };
frpServer = { enable = true; serverName = "frp.chn.moe"; };
nginx =
{
@@ -53,7 +53,7 @@ inputs:
(site: { name = "${site}.chn.moe"; value.upstream.address = "wireguard.vps7.chn.moe"; })
[
"xn--s8w913fdga" "misskey" "synapse" "syncv3.synapse" "matrix" "syncv3.matrix"
"send" "kkmeeting" "api" "git" "grafana" "vikunja"
"send" "kkmeeting" "api" "git" "grafana"
]));
applications =
{
@@ -64,20 +64,19 @@ inputs:
main.enable = true;
};
};
coturn = {};
httpua = {};
coturn.enable = true;
httpua.enable = true;
mirism.enable = true;
fail2ban = {};
fail2ban.enable = true;
wireguard =
{
enable = true;
peers = [ "pc" "nas" "vps7" "surface" "xmupc1" "xmupc2" "pi3b" ];
peers = [ "pc" "nas" "vps7" ];
publicKey = "AVOsYUKQQCvo3ctst3vNi8XSVWo1Wh15066aHh+KpF4=";
wireguardIp = "192.168.83.1";
listenIp = "74.211.99.69";
lighthouse = true;
};
beesd.instances.root = { device = "/"; hashTableSizeMB = 64; };
};
};
};

View File

@@ -23,21 +23,20 @@ inputs:
delayedMount = [ "/" ];
};
swap = [ "/nix/swap/swap" ];
rollingRootfs = {};
rollingRootfs = { device = "/dev/mapper/root"; path = "/nix/rootfs"; };
};
grub.installDevice = "/dev/disk/by-path/pci-0000:00:05.0-scsi-0:0:0:0";
nixpkgs.march = "broadwell";
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
initrd.sshd.enable = true;
networking = { hostname = "vps7"; networkd = {}; };
gui.preferred = false;
networking.hostname = "vps7";
};
packages.packageSet = "desktop";
packages.packageSet = "server";
services =
{
snapper.enable = true;
fontconfig.enable = true;
sshd = {};
sshd.enable = true;
rsshub.enable = true;
wallabag.enable = true;
misskey.instances =
@@ -50,20 +49,19 @@ inputs:
synapse.matrixHostname = "synapse.chn.moe";
matrix = { port = 8009; redisPort = 6380; slidingSyncPort = 9001; };
};
xrdp = { enable = true; hostname = [ "vps7.chn.moe" ]; };
vaultwarden.enable = true;
beesd.instances.root = { device = "/"; hashTableSizeMB = 1024; };
beesd = { enable = true; instances.root = { device = "/"; hashTableSizeMB = 1024; }; };
photoprism.enable = true;
nextcloud.enable = true;
freshrss.enable = true;
send.enable = true;
huginn.enable = true;
fz-new-order = {};
fz-new-order.enable = true;
nginx.applications = { kkmeeting.enable = true; webdav.instances."webdav.chn.moe" = {}; };
httpapi.enable = true;
gitea.enable = true;
grafana.enable = true;
fail2ban = {};
fail2ban.enable = true;
wireguard =
{
enable = true;
@@ -72,8 +70,6 @@ inputs:
wireguardIp = "192.168.83.2";
listenIp = "95.111.228.40";
};
vikunja.enable = true;
chatgpt = {};
};
};
};

View File

@@ -1,278 +0,0 @@
# 硬件
* CPU16 核 32 线程。
* 内存96 G。
* 显卡:
* 409024 G 显存。
* 309024 G 显存。
* 2080Ti: 12 G 显存。
* 硬盘2 T。
# 队列系统SLURM
## 基本概念
SLURM 是一个用来对任务排队的系统,轮到某个任务时,再调用其它程序来执行这个任务。
## 常用命令
提交一个 VASP GPU 任务的例子:
```bash
sbatch --gpus=1 --ntasks-per-gpu=1 --job-name="my great job" vasp-nvidia-640
```
* `--gpus` 指定使用GPU 的情况:
* 要占用任意一个 GPU排到这个任务时哪个空闲就使用哪个`--gpus=1`。要占用任意两个就写 `--gpus=2`,以此类推。
但一般来说,**单个任务不要占用超过一个 GPU**,多个显卡的速度会比单个更慢。
* 要指定具体使用哪个 GPU 时,写 `--gpus=4090:1`。2080 Ti 需要写为 `2080_ti`P5000 需要写为 `p5000`
* 当需要使用多个不同类型的显卡(例如,指定使用一个 3090 和一个 4090`--gres=gpu:3090:1,gpu:4090:1`
* `--ntasks-per-gpu=1` 对于 VASP 来说一定要写。
* `--job-name=xxx` 指定任务的名字。可以简写为 `-J`。也可以不指定。
* 默认情况下,一个 task 会搭配分配一个 CPU 核(一个线程),一般已经够用。如果一定要修改,用 `--cpus-per-task`
* `vasp-nvidia-640` 指调用 std 版本,要使用 gam 或 ncl 版本时,写为例如 `vasp-nvidia-640-gam`
提交一个 VASP CPU 任务的例子:
```bash
sbatch --ntasks=4 --cpus-per-task=4 --hint=nomultithread --job-name="my great job" vasp-intel-640
```
* `--ntasks=4 --cpus-per-task=4` 指定使用占用多少核。
* CPU 的调度是个非常复杂的问题,而且 slurm 和 Intel MPI 之间的兼容性也不算好,因此**推荐照抄下面的设置**。
也可以自己测试一下怎样分配更好,但不要随意地设置。不同的设置会成倍地影响性能。
* 对于 xmupc1`--ntasks=3 --cpus-per-task=4`
* 对于 xmupc2`--ntasks=4 --cpus-per-task=10`
* `--hint=nomultithread` 记得写。
* `--job-name=xxx` 指定任务的名字。可以简写为 `-J`。也可以不指定。
* `vasp-intel-640` 指调用 std 版本,要使用 gam 或 ncl 版本时,写为例如 `vasp-intel-640-gam`
要把其它程序提交到队列里,也是类似的写法。请自行举一反三。
要列出已经提交(包括已经完成、取消、失败)的任务:
```bash
squeue -t all -l
```
取消一个任务:
```bash
# 按任务的 id 取消
scancel 114514
# 按任务的名字取消
scancel -n my_great_job
# 取消一个用户的所有任务
scancel -u chn
```
要将自己已经提交的一个任务优先级提到最高(相应降低其它任务的优先级,使得总体来说不影响别人的任务):
```bash
scontrol top 114514
```
要显示一个任务的详细信息(不包括服务器重启之前算过的任务):
```bash
scontrol show job 114514
```
要显示一个任务的详细信息(包括服务器重启之前算过的任务):
```bash
sacct --units M --format=ALL -j 114514 | bat -S
```
## `sbatch` 的更多参数
```bash
# 提交一个新任务,但是礼让后面的任务(推迟到指定时间再开始排队)
--begin=16:00 --begin=now+1hour
# 指定工作目录
--chdir=/path/to/your/workdir
# 指定备注
--comment="my great job"
# 指定任务的 ddl算不完就杀掉
--deadline=now+1hour
# 标准错误输出写到别的文件里
--error=error.log
# 将一些环境变量传递给任务(=ALL是默认行为
--export=ALL,MY_ENV_VAR=my_value
# 不传递现在的环境变量
--export=NONE
# 打开一个文件作为标准输入
--input=
# 发生一些事件(任务完成等)时发邮件
--mail-type=NONE,BEGIN,END,FAIL,REQUEUE,ALL --mail-user=chn@chn.moe
# 要求分配内存(不会真的限制内存使用,只是在分配资源时会考虑)
--mem=20G --mem-per-cpu --mem-per-gpu
# 输出文件是否覆盖
--open-mode={append|truncate}
# 指定输出文件
-o, --output=<filename_pattern>
# 不排队,直接跑(超额分配)
-s, --oversubscribe
# 包裹一个二进制程序
--wrap=
```
# 支持的连接协议
## SSH
ssh 就是 putty winscp 之类的工具使用的那个协议。
* 地址xmupc1.chn.moe
* 端口6007
* 用户名:自己名字的拼音首字母
* 可以用密码登陆,也可以用证书登陆。
从一台服务器登陆到其它服务器,只需要使用 `ssh`` 命令:
```bash
ssh jykang
ssh xmupc1
ssh xmupc2
ssh user@host
```
直接从另外一台服务器下载文件,可以使用 `rsync` 命令:
```bash
rsync -avzP jykang:/path/to/remote/directory_or_file /path/to/local/directory
```
将另外一个服务器的某个目录挂载到这个服务器,可以使用 `sshfs` 命令:
```bash
sshfs jykang:/path/to/remote/directory /path/to/local/directory
```
用完之后记得卸载(不卸载也不会有什么后果,只是怕之后忘记了以为这是本地的目录,以及如果网络不稳定的话,运行在这里的软件可能会卡住):
```bash
umount /path/to/local/directory
```
如果不喜欢敲命令来挂载/卸载远程目录,也可以 RDP 登陆后用 dolphin。
## RDP
就是 windows 那个远程桌面。
* 地址xmupc1.chn.moe
* 用户名:自己名字的拼音首字母
* 密码和 ssh 一样(使用同样的验证机制)。
RDP 暂时没有硬件加速(主要是毛玻璃之类的特效会有点卡)。
记得在连接时点击“显示选项”将“体验”中的连接速度改为“LAN10 Mbps 或更高)”,不然会很卡。
## samba
samba 就是 windows 共享文件夹的那个协议。
* 地址xmupc1.chn.moe
* 用户名:自己名字的拼音首字母
* 初始密码和 ssh 一样,你可以自己修改密码(使用 `smbpasswd` 命令。samba 的密码和 ssh/rdp 的密码是分开的,它们使用不同的验证机制。
在 windows 上,可以直接在资源管理器中输入 `\\xmupc1.chn.moe` 访问。
也可以将它作为一个网络驱动器添加(地址同样是 `\\xmupc1.chn.moe`)。
# 计算软件
## VASP
VASP 有很多很多个版本,具体来说:
* VASP 多个版本可以共存。目前安装了两个版本6.3.1 和 6.4.0。
* VASP 可以用不同的编译器编译。目前安装的有nvidia、gnu、intel 和 amd。nvidia 使用 GPU 计算,其它的只能用 CPU 计算。
* VASP 的 std/gam/ncl 版本有一点区别,一般用 std只有一个 gamma 点的时候用 gam 会快一点,系统中存在方向不平行的磁矩时必须用 ncl。
* 无论哪个版本,都集成了下面这些补丁:
* HDF5用于生成 hdf5 格式的输出文件。
* wannier90我也不知道干啥的随手加上的。
* OPTCELL如果存在一个 `OPTCELL` 文件VASP 会据此决定弛豫时仅优化哪几个晶胞参数。
* MPI shared memory用来减小内存占用。
如何提交 VASP 到队列系统已经在上面介绍过了。下面的例子是,如果要直接运行一个任务的写法:
```bash
vasp-nvidia-640-env mpirun -np 1 -x CUDA_DEVICE_ORDER=PCI_BUS_ID -x CUDA_VISIBLE_DEVICES=0 -x OMP_NUM_THREADS=4 vasp-std
vasp-gnu-640-env mpirun -np 2 -x OMP_NUM_THREADS=4 vasp-std
vasp-intel-640-env mpirun -n 2 -genv OMP_NUM_THREADS=4 vasp-std
vasp-amd-640-env mpirun -np 2 -x OMP_NUM_THREADS=4 vasp-std
```
其中 `CUDA_VISIBLE_DEVICES` 用于指定用哪几个显卡计算(多个显卡用逗号分隔)。
要查看显卡的编号,可以用 `CUDA_DEVICE_ORDER=PCI_BUS_ID vasp-nvidia-640-env nvaccelinfo` 命令。
这里 `vasp-xxx-6.4.0` 命令的作用是,进入一个安装了对应版本的 VASP 的环境,实际上和 VASP 关系不大;
后面的 `mpirun xxx` 才是真的调用 VASP。
所以实际上你也可以在这个环境里做别的事情,例如执行上面的 `nvaccelinfo` 命令。
## mumax
问龚斌,我没用过。
## lammps
除了我应该没人用,就不写了。
## quantum espresso
我也只用过一次。大规模用到了再说吧。
# 其它软件
我自己电脑上有的软件,服务器都有装,用于科研的比如 VESTA 什么的。可以自己去菜单里翻一翻。
## 操作系统
操作系统是 NixOS是一个相对来说比较小众的系统。
它是一个所谓“函数式”的系统。
也就说,理想情况下,系统的状态(包括装了什么软件、每个软件和服务的设置等等)是由一组配置文件唯一决定的(这组配置文件放在 `/etc/nixos` 中)。
要修改系统的状态(新增软件、修改设置等等),只需要修改这组配置文件,然后要求系统应用这组配置文件就可以了,
系统会自动计算出应该怎么做(增加、删除、修改哪些文件,重启哪些服务等等)。
这样设计有许多好处,例如可以方便地回滚到之前任意一个时刻的状态(方便在调试时试错);
一份配置文件可以描述多台机器的系统,在一台上调试好后在其它机器上直接部署;
以及适合抄或者引用别人写好的配置文件。
以上都是对于管理员来说的好处。对于用户来说的好处不是太多,但是也有一些。
举个例子,如果用户需要使用一个没有安装的软件(例如 `phonopy`,当然实际上这个已经装了),只需要在要执行的命令前加一个逗号:
```bash
, phonopy --dim 2 2 2
```
系统就会帮你下载所有的依赖,并在一个隔离的环境中运行这个命令(不会影响这之后系统的状态)。
还有一个命令可能也有用,叫 `try`。
它会在当前的文件系统上添加一个 overlay之后执行的命令对文件的修改只会发生在这个 overlay 上;
命令执行完成后,它会告诉你哪些文件发生了改变,然后可以选择实际应用这些改变还是丢弃这些改变。
例如:
```bash
try phonopy --dim 2 2 2
```
这个命令和 NixOS 无关,只是突然想起来了。
## 文件系统
文件系统是 BtrFS。它的好处有
* 同样的内容只占用一份空间;以及内容会被压缩存储(在读取时自动解压)。这样大致可以节省一半左右的空间。
例如现在 xll 目录里放了 213 G 文件,但只占用了 137 G 空间。
* 每小时自动备份,放置在 `/nix/persistent/.snapshots` 中,大致上会保留最近一周的备份。如果你误删了什么文件,可以去里面找回。
## ZSH
所谓 “shell” 就是将敲击的一行行命令转换成操作系统能理解的系统调用C 语言的函数)的那个东西,也就是负责解释敲进去的命令的意思的那个程序。
大多情况下默认的 shell 是 bash但我装的服务器上用 zsh。
zsh 几乎完全兼容 bash 的语法,除此以外有一些顺手的功能:
* 如果忘记了曾经输入过的一个命令,输入其中的几个连续的字母或者单词(不一定是开头的几个字母),然后按 `` 键,就会自动在历史命令中依次搜索。
例如我输入 `install` 按几下 `` 键,就可以找到 `sudo nixos-rebuild boot --flake . --install-bootloader --option substituters https://nix-store.chn.moe` 这个东西。
* 如果从头开始输入一个曾经输入过的命令,会用浅灰色提示这个命令。要直接补全全部命令,按 `` 键。要补全一个单词,按 `Ctrl` + `` 键。
* 常用的命令,以及常用命令的常用选项,按几下 `tab` 键,会自动补全或者弹出提示。

View File

@@ -10,21 +10,16 @@ inputs:
{
mount =
{
vfat."/dev/disk/by-uuid/467C-02E3" = "/boot/efi";
vfat."/dev/disk/by-uuid/3F57-0EBE" = "/boot/efi";
btrfs =
{
"/dev/disk/by-uuid/2f9060bc-09b5-4348-ad0f-3a43a91d158b" = { "/nix" = "/nix"; "/nix/boot" = "/boot"; };
"/dev/disk/by-uuid/a04a1fb0-e4ed-4c91-9846-2f9e716f6e12" =
{
"/nix/rootfs" = "/nix/rootfs";
"/nix/persistent" = "/nix/persistent";
"/nix/nodatacow" = "/nix/nodatacow";
"/nix/rootfs/current" = "/";
};
"/dev/disk/by-uuid/02e426ec-cfa2-4a18-b3a5-57ef04d66614"."/" = "/boot";
"/dev/mapper/root" = { "/nix" = "/nix"; "/nix/rootfs/current" = "/"; };
};
};
swap = [ "/nix/swap/swap" ];
rollingRootfs = {};
swap = [ "/dev/mapper/swap" ];
resume = "/dev/mapper/swap";
rollingRootfs = { device = "/dev/mapper/root"; path = "/nix/rootfs"; };
};
grub.installDevice = "efi";
nixpkgs =
@@ -35,8 +30,6 @@ inputs:
enable = true;
capabilities =
[
# p5000 p400
"6.1"
# 2080 Ti
"7.5"
# 3090
@@ -47,53 +40,60 @@ inputs:
forwardCompat = false;
};
};
gui = { preferred = false; autoStart = true; };
kernel.patches = [ "cjktty" "lantian" ];
gui.preferred = false;
kernel.patches = [ "cjktty" ];
networking.hostname = "xmupc1";
nix.remote.slave.enable = true;
};
hardware = { cpus = [ "amd" ]; gpu.type = "nvidia"; };
hardware =
{
cpus = [ "amd" ];
gpus = [ "nvidia" ];
bluetooth.enable = true;
joystick.enable = true;
printer.enable = true;
sound.enable = true;
gamemode.drmDevice = 1;
};
packages.packageSet = "workstation";
virtualization = { waydroid.enable = true; docker.enable = true; kvmHost = { enable = true; gui = true; }; };
virtualization = { docker.enable = true; kvmHost = { enable = true; gui = true; }; };
services =
{
snapper.enable = true;
fontconfig.enable = true;
sshd = { passwordAuthentication = true; groupBanner = true; };
xray.client.dae.wanInterface = [ "wlp57s0" ];
firewall.trustedInterfaces = [ "virbr0" "waydroid0" ];
smartd.enable = true;
beesd.instances =
samba =
{
root = { device = "/"; hashTableSizeMB = 16384; threads = 4; };
nix = { device = "/nix"; hashTableSizeMB = 512; };
enable = true;
private = true;
hostsAllowed = "192.168. 127.";
shares =
{
media.path = "/run/media/chn";
home.path = "/home/chn";
mnt.path = "/mnt";
share.path = "/home/chn/share";
};
};
sshd.enable = true;
xray.client =
{
enable = true;
serverAddress = "74.211.99.69";
serverName = "vps6.xserver.chn.moe";
dns.extraInterfaces = [ "docker0" ];
};
firewall.trustedInterfaces = [ "virbr0" "waydroid0" ];
acme = { enable = true; cert."debug.mirism.one" = {}; };
smartd.enable = true;
beesd = { enable = true; instances.root = { device = "/nix/persistent"; hashTableSizeMB = 2048; }; };
wireguard =
{
enable = true;
peers = [ "vps6" ];
publicKey = "JEY7D4ANfTpevjXNvGDYO6aGwtBGRXsf/iwNwjwDRQk=";
wireguardIp = "192.168.83.6";
wireguardIp = "192.168.83.5";
};
slurm =
{
enable = true;
cpu = { cores = 16; threads = 2; };
memoryMB = 94208;
gpus = { "2080_ti" = 1; "3090" = 1; "4090" = 1; };
};
xrdp = { enable = true; hostname = [ "xmupc1.chn.moe" ]; };
samba =
{
enable = true;
hostsAllowed = "";
shares = { home.path = "/home"; root.path = "/"; };
};
groupshare = {};
};
bugs = [ "xmunet" "amdpstate" ];
user.users = [ "chn" "xll" "zem" "yjq" "gb" ];
bugs = [ "xmunet" "firefox" ];
};
services.hardware.bolt.enable = true;
};
}

View File

@@ -1,48 +0,0 @@
acme:
cloudflare.ini: ENC[AES256_GCM,data:PjCyozvFTXxA///enYYbaMZ8ISfFjJviLVKfdOcMSi5G3CEjEsp1Ez4krbgy4/eJo4v9HfTN0bMmUnl2OHOyzTg=,iv:e1iQZ5JUHkzfnfP956Lzl3FWs11xdULctA5MZsALtU0=,tag:8X2Q/Hixxn/ci4XRSUDidg==,type:str]
nginx:
maxmind-license: ENC[AES256_GCM,data:/7R7w+fiMw54Cmd7y/wT/s8RMqFMf3Fc0Mph0ZhURmCzowkmLEhtmw==,iv:i+Z+2NbssI864Edwf73SQfaeFuWoqr+U8eQ/8R23FOk=,tag:8ITlkS97vlsmHM1HDk6/3A==,type:str]
xray-client:
uuid: ENC[AES256_GCM,data:4PM/d263HgBseIgRplgo5ahJ8u8HuPznXt2hW5O+VawS6WjP,iv:98Ymj4eiCGQPMcaHBI9zJAaRagm82mF0LY2c9bzA+/s=,tag:8imXq/hxAxS5XKy0uWIBPw==,type:str]
wireguard:
privateKey: ENC[AES256_GCM,data:Azaqung7llErB7/IdnOnEkwjQ39yQHKcO7VgvMDCDTExM7nS0zx+yMYX4ls=,iv:FX8oLHMBVEnKkYOg8q2A9vFmtRZDws5T87+lEl7+2G8=,tag:DdOQUbNKB6JK7Tp6McQ0Og==,type:str]
users:
#ENC[AES256_GCM,data:1RG/IM/UrLCk,iv:LY2QCBN0gYwuhVwS/WIrjt4MEHhjPPQG+cjTZJhU6Zc=,tag:AEL+smmitSqW+D70K74LbQ==,type:comment]
xll: ENC[AES256_GCM,data:YauaeGHDVAnMXp9hSz4r4jNsioF79Q+WplfsYGpl4g5FxoakhfjRlnfzrLmMO3mWEIBOmDqeShbDEulyV5O47CIBGaMUUHe+Gg==,iv:RNwRfghJBb0PO4A/T5d5J1U0NsXdygXlWq/FfF8MO4U=,tag:BOh666TYGbCCHcgB/uBhTw==,type:str]
#ENC[AES256_GCM,data:zxOQcoOzJNBK,iv:YJQB8lV+nhwm5XYMpDIyt0IDHBlHTiHO8cpgXkXe/dQ=,tag:re5ekGkYRewPdxv83mtLUQ==,type:comment]
zem: ENC[AES256_GCM,data:bIxVN4T3Gh3aSa1gylkPmW3/uT5xQAlruC+L3zk0Tc3KvwBCQA5DpxXU8ZxjeK0P0xGi02U7gFWgm+yxp6otdCsUEmWed4EHHw==,iv:vpKpY0nRUwuI5mCcYTOD3zN/E21wHl4ZbRDUPoFmdhQ=,tag:m5WTzCgOTC7oqU4yfV9gkQ==,type:str]
#ENC[AES256_GCM,data:ZnMFN0WzjKDd,iv:t1YHrNoHOohYsdBOqoV6OtfS5ig6CTS8jW5mKy0oSQA=,tag:WkgrH1ZXcbHruxJY/hVsmg==,type:comment]
yjq: ENC[AES256_GCM,data:ua0DINHutjt2Pk+SfHRQRV99mT3Cnw6rRKO8VRIAlP0dY6QhK9wkNdyRYWYRBKVrWgyFQMGNFYAxIpymjF/X7mBOVI2sOHLgkw==,iv:PUZ6S0KICuqoSA2sDLxdL4gtAOQnQXOUY+5f3qDZgpc=,tag:f39P34vAUOrV23BsKkRarA==,type:str]
#ENC[AES256_GCM,data:6qNjSdjck4Vz,iv:c/GNqCNgRgwgL+2f6Vumtjb/ub9WCBSy8R02NRCDqk8=,tag:b/tucJsHTjSfcK0vgHtE8A==,type:comment]
gb: ENC[AES256_GCM,data:3eAKBiJoC1owCHTFd3Xq8vI8VK980evePc92xCXJJ21M9D1MdbwN8ySZ3Ovjk7VfQmEo8oRv1Ll1sftyrXYoeTHmJsNDxCpR6A==,iv:Ju/ERNuGrgO5kYlbvmkbLJkgiW3Elou34AsJTFITCUg=,tag:POVlxYh9kZ1BMSbt97IVOQ==,type:str]
mariadb:
slurm: ENC[AES256_GCM,data:qQMD8SKNmxb3PdScXNqppF9zkX7dV5i7rvljvZuhiI5zLnu77qYCHBW6ymh0mrY14N9NjxmQZhZWX/H8TvBlcg==,iv:J5N3LjCYW3QmuEkMBpl7qvPFW1Z9ZoPLkj45jKcIW9U=,tag:Tl+ld07+lVkmzt7f/f2MqQ==,type:str]
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age19ax6vm3pv8rph5tq3mmehd9sy9jk823tw8svsd790r0lkslycquqvlwz9m
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB5RWIreCtMeTZ0UE9Zd2di
VE9tR0x6SUNyWjlPV1BqMU5Tb0RTSXNGN2hNCkxuVjFFb0xJZTBMekxqdE96RlRh
czF0dHQxdVhsNE5tVWg0Q2RmYktsWDgKLS0tIFY3dHRlbFpsWUsyTzA3RVR1Qyts
UUJHMU13cm1lOXhRYzhSWlFyTFltYWcKDUxABRGskWWpHEFL44gHYzAqaQ3AmBDt
LcL/4IiEs3TwOpuY+WTVx8JKZBOsxcSlNahiDuCnoTbL4gZTPnd0pA==
-----END AGE ENCRYPTED FILE-----
- recipient: age1hnarptkze0ujpp05dqr8uma04cxg9zqcx68qgpks5uf5l6rpk5gqhh8wxg
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBwbHd4ZHhsTk5leDlreC9E
TVAzRXVuS0Judk5zTGVWRVhWSUhpMFdscEg0ClVFYzZYZG9hNjJKTlRVZ1I3eXVq
M2Y5by85dE1QM25yQ3g3bFVSL2tsVlkKLS0tIHVYbGxrT0hOQkZ5SHBsQ3UyaVly
ZDNHUjE2QVlCV3p0NHdKYW5IMHVBZzQKkZtfyvfroOntg3yRjMw4jQHiQj8eaB2h
IeIHfW4y01mmVT2ofbtB0xYpjcl4gtUlQ8X3tn5iJ9P8gcVo0G598A==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2024-03-10T13:47:17Z"
mac: ENC[AES256_GCM,data:19w2Q1SRhKIyxibGgKa+CkEhiizFJ27FePOlMll+8tJVJRzfIl8KrutlRi0hMhEYFlML0bWunbINUEIg7yJbIwFCSjxFDnqKsCT3iClT3kaktxr5+0R+ECoQTGGV67VkT5WY/LT3V1zdLYI38MVaBQObGKCpBs23nIK2QXrg39Q=,iv:q1ezSmo14vsmEE8owxnsonWMq2uj6mrVjKNh+RuK+cE=,tag:QBc99UEaEPiEgZH+Z3Z8tA==,type:str]
pgp: []
unencrypted_suffix: _unencrypted
version: 3.8.1

View File

@@ -1,24 +0,0 @@
{
"data": "ENC[AES256_GCM,data:tuEymMXW0f7Rui5wrz/xozphTEq6ffkYIfNIoURFNHwH2Cg+aKHz2ox0gk02BJARhPMDrxCYlChkcrEI0ma/T0eBe9sWz3tA8AOwU1lHSZ06d/JWzW7IUIyTac2mnjt3/jY/qpnR4A8wtHwD0j4zkzXgUgFwq7k/fs24acEE4Jo=,iv:iDTS0xswLrwkOYmfomE5hluVONgJYia/RjINDy7T3R0=,tag:oIYNpFCuT2D+X1QEJJiHew==,type:str]",
"sops": {
"kms": null,
"gcp_kms": null,
"azure_kv": null,
"hc_vault": null,
"age": [
{
"recipient": "age19ax6vm3pv8rph5tq3mmehd9sy9jk823tw8svsd790r0lkslycquqvlwz9m",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA3aFRRa0NsOUp5MEg3UHcx\nc3g1VFZEQS9Tci9QSnNFYnIrT3hUdVU5cWxjCnU5UXVEdTFXczJzcHVvSjF2WHdB\nYmpyQVVaUFozKzJIZThBbXUxb2k2YzAKLS0tIHE1QXVrOXo1Y3VXMzJJYitWU3Qv\neDF1cndrSi94clh1cS9NczN0UW9pOXcKtrnIj3WovMYdcg5nWnnyRhJhTGLrlwxW\nxQ6bmNrfbZedmCNdjY2lPXmudMXJ8YlWe/HGCe94x3iFlaSwCIGUsA==\n-----END AGE ENCRYPTED FILE-----\n"
},
{
"recipient": "age1hnarptkze0ujpp05dqr8uma04cxg9zqcx68qgpks5uf5l6rpk5gqhh8wxg",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBocFl1SHJEemRySlBnMmNn\nVW9RS1NNdlo4M3l2WGlQaHJmbDBHcjMwaVVnCnY5WExPOXZJVEdYSlJ6UTRBMGJj\ncmlYaUNVV1hnWTNkaWVuV2VuaXN2eU0KLS0tIDBTYnd2NmVYTUJKaHZWRWo3ZlUx\nTEtPZWc2RE1XNG9WTXFOTllWVUVWeUkK+9aLz1rygGAQjpG+oMNUtrDkQaDfg+2q\nnl/CtZZrFD6NXGw6Di0X5t9fQu295NTJ/0qjXnfMigG8gDtxkE+/7g==\n-----END AGE ENCRYPTED FILE-----\n"
}
],
"lastmodified": "2024-02-26T06:04:53Z",
"mac": "ENC[AES256_GCM,data:y0RkPyUwwff95BFL951TxS/x5ORzMsxFJVjopSw+8iVtswD8MT1nmsbwyth4C9OnJ/IAtnZk/CjAt72a68AZpPI+2W/JqJq20ohFoquDNhTlsoyLWdO3Vjrd+Wo3hp0+iKQ3e/uYrF1sTqQO9a3OIxu2sVLM0gEDmIe2nJpLJQo=,iv:EjXTQvVdjzfClNfQ3rPxAFVWVqr7sSOz4ap+nshPEAk=,tag:DcIlf9W7NNqQ+gf8f46MwQ==,type:str]",
"pgp": null,
"unencrypted_suffix": "_unencrypted",
"version": "3.8.1"
}
}

View File

@@ -1,31 +0,0 @@
# 硬件
* CPU44 核 88 线程。
* 内存256 G。
* 显卡:
* 409024 G 显存。
* P500016 G 显存。
* 硬盘18 T。
# 支持的连接协议
## SSH
* 地址xmupc2.chn.moe
* 端口6394
* 用户名:自己名字的拼音首字母
* 可以用密码登陆,也可以用证书登陆。
## RDP
* 地址xmupc2.chn.moe
* 用户名:自己名字的拼音首字母
* 密码和 ssh 一样(使用同样的验证机制)。
## samba
* 地址xmupc2.chn.moe
* 用户名:自己名字的拼音首字母
* 初始密码和 ssh 一样。
其它内容请阅读 [xmupc1](../xmupc1) 的说明,两台机器的软件大致是一样的。

View File

@@ -1,83 +0,0 @@
inputs:
{
config =
{
nixos =
{
system =
{
fileSystems =
{
mount =
{
vfat."/dev/disk/by-uuid/23CA-F4C4" = "/boot/efi";
btrfs =
{
"/dev/disk/by-uuid/d187e03c-a2b6-455b-931a-8d35b529edac" =
{ "/nix/rootfs/current" = "/"; "/nix" = "/nix"; "/nix/boot" = "/boot"; };
};
};
swap = [ "/nix/swap/swap" ];
rollingRootfs = {};
};
grub.installDevice = "efi";
nixpkgs =
{
march = "skylake";
cuda =
{
enable = true;
capabilities =
[
# p5000 p400
"6.1"
# 2080 Ti
"7.5"
# 3090
"8.6"
# 4090
"8.9"
];
forwardCompat = false;
};
};
gui = { preferred = false; autoStart = true; };
kernel.patches = [ "cjktty" "lantian" ];
networking.hostname = "xmupc2";
nix.remote.slave.enable = true;
};
hardware = { cpus = [ "intel" ]; gpu.type = "nvidia"; };
packages.packageSet = "workstation";
virtualization = { waydroid.enable = true; docker.enable = true; kvmHost = { enable = true; gui = true; }; };
services =
{
snapper.enable = true;
fontconfig.enable = true;
sshd = { passwordAuthentication = true; groupBanner = true; };
xray.client.dae.wanInterface = [ "wlp4s0" ];
firewall.trustedInterfaces = [ "virbr0" "waydroid0" ];
smartd.enable = true;
beesd.instances.root = { device = "/"; hashTableSizeMB = 16384; threads = 4; };
wireguard =
{
enable = true;
peers = [ "vps6" ];
publicKey = "lNTwQqaR0w/loeG3Fh5qzQevuAVXhKXgiPt6fZoBGFE=";
wireguardIp = "192.168.83.7";
};
slurm =
{
enable = true;
cpu = { sockets = 2; cores = 22; threads = 2; };
memoryMB = 253952;
gpus = { "4090" = 1; "p5000" = 1; };
};
xrdp = { enable = true; hostname = [ "xmupc2.chn.moe" ]; };
samba = { enable = true; hostsAllowed = ""; shares = { home.path = "/home"; root.path = "/"; }; };
groupshare = {};
};
bugs = [ "xmunet" ];
user.users = [ "chn" "xll" "zem" "yjq" "gb" ];
};
};
}

View File

@@ -1,48 +0,0 @@
acme:
cloudflare.ini: ENC[AES256_GCM,data:/y070fzfZFI/Jb9xS8UO7iRnjHJ3uItqsHqjyHPAqsTN4tSEyMpaE3KtNpecgWxk2PvLRfqdmdwu/bnGlIp7adU=,iv:fv4dbeK1F/cn5nhnSC1lTUqxeFPG/0lNqEvPWMH6Mzw=,tag:dE4clxPGraAXXsJM6NS8XQ==,type:str]
nginx:
maxmind-license: ENC[AES256_GCM,data:FPVSD8otQMNpbESNEHXCfQjB/zi3OVwZoyLijUtnHQlQzec7KVSiGw==,iv:DkkwCqvRmcFHQIXseh2fycCxZboJMYhHPu67GddenY4=,tag:iHEC8r5GcuB1QcZ5Uf8Skw==,type:str]
xray-client:
uuid: ENC[AES256_GCM,data:j2R0UtfS/es2A+Ic+Kq6FZJSqXlA/Q8tGkuAIX0ZdTsV4hGk,iv:Ovpr49isIJRdUyM3jxgiT+9Sc+qTF6ZnkKUwxIq6KUs=,tag:2VRSkiPNWaOmCqLJti8Bzw==,type:str]
wireguard:
privateKey: ENC[AES256_GCM,data:0Vw9NVs/Kxc52zUlmeAPFeOG8msdL0YopjhzFKRWhv6+kfb+SFObOP8EJ2M=,iv:KgIZIawbnN+1sIcMjNECkdtujPbg7yQktKVc25SXavI=,tag:b79oZP+GZKmM3OVFshvFhg==,type:str]
users:
#ENC[AES256_GCM,data:FP1Mr1TmRI4L,iv:3K4LMbOQPvF1ORWNyaXDoC5MXn3yColR4eKs9sm9y5s=,tag:f3guTegVXw1A6aqolKQnqA==,type:comment]
xll: ENC[AES256_GCM,data:CAEd+usnLKoQZ+0PLEiJfbZpz2pyn+I/edC2KbNXBXZPAgT7IDENMnSQyxme899KqRVL4nLrtHs82aA8+kl/dE+QYSTCFVVuHg==,iv:Hs8rb0Iu5Xw74p9/cL2gWfPLh61VaLzIltKUSjRFZjc=,tag:/u5vI0oTMQbNoCEzhcWqOw==,type:str]
#ENC[AES256_GCM,data:UIns0CnC/QmJ,iv:Gn4XDPcdTyDLXAgGq7qwayrN206Gx7JsJ3V9G+4bTyA=,tag:FITVs8Tgkiq1XoS8joXM1Q==,type:comment]
zem: ENC[AES256_GCM,data:znpGuS8LVxaztnwQlIwu3hykWRBUtQvOsniLaOasXDbw9lHGX8lwwYJuCE+0I14HmiZK/RrrouIwfAfcjZQzPyjJ/SRoOG1Vyg==,iv:YXHX43y99/w9102vhsvFLVOUtJmuRnLVLu+ywfn9URY=,tag:AzsmkXOyX7y/D+ndteuMmA==,type:str]
#ENC[AES256_GCM,data:6vMItERptBsX,iv:G0sDjEfLciheMxTZbeLIbWKlimPD1ANIk/VVdhQifXA=,tag:oR9FEdVx6W+0uDeKfb37iw==,type:comment]
yjq: ENC[AES256_GCM,data:sGPQ0xALULREnhzl9g/V91M5osMglsSps6R4gYn5OZc/4xVC1phF3qajVN3YMOr7kKgkHbF2Rjm6/2vuK0k1iYZnFswUAmFlmw==,iv:5vG1hn7SlX6HCpas2BgxBSwWqLby8OCxcH3EKNvceIc=,tag:TVwFBAuosKnEOZecq1phXw==,type:str]
#ENC[AES256_GCM,data:ALHxkRABA+ll,iv:r1IDiHLFcTdLID3q16zrLTavAwQfddC7bXMKcFZFveI=,tag:4Pd0/Q1BmH4gJjaM4hbqqQ==,type:comment]
gb: ENC[AES256_GCM,data:z4CrtdmdLJJ0qZzr7qvihnluJQgjtciX56KdEmtemiRu0llEJk9qz6a23aJ7m40Sfc38elF1/LsvjOuBOC87+BVkKDCj76phag==,iv:WrFVxkr3snmqDXZx5kAYCLp7ixEIzxoT7El3rV7Ovqg=,tag:iExf2Y/HObHQrKMTRvqn7A==,type:str]
mariadb:
slurm: ENC[AES256_GCM,data:9wLQ1zF/kDaiw0s3UaRpiHgmngU7u6hwyqpddSjev0+Z0v58Q2oiJtK8vn+2VlSxx5ACfqEFbzp0PZYAxd575w==,iv:q9JTkgDymOwkbZ/PaxRAAQrtO96QmGgZcQuLTFCMoS4=,tag:dwOHlOTgZqT/1jQ+oGf7UQ==,type:str]
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age19ax6vm3pv8rph5tq3mmehd9sy9jk823tw8svsd790r0lkslycquqvlwz9m
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA0Rmc2Ull1WFB4Smh3c0Zl
emlTNGJKZkpIK2JFeUNVeUcrR2FzRXRQZHlvCkhzMHpzYmZRZ0M0cXdRVi8wZmp6
ZDRZQ2FkOWt6M0lrdjBHa3VTWXBDKzgKLS0tIGtJbTRRelg1VVk2QStwdzlFM1g4
M1JOd1g3cVdjUFRhZ0FxcWphZXZJbkkKFXDtJVoi+qIrXp6cznevuZ+peBiRRITP
rrplqLiYsNIGKmKYtRIUu8WXDZ2q2CJ8Z+pka3W3H/U+m957hBDWyw==
-----END AGE ENCRYPTED FILE-----
- recipient: age1l4stuz0vr7gs7pqwjrmezam44702jp2vmqaqyxw0l0r42kf9updq4dfhrw
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBsSHdka3FPQUYrcXQzcTFo
a000TUllT0MvUzk5ZzVFbXZheG9ZVTM2S253CkE5VW9tQktvL2pMWFoxcnFjTGpr
Z0p1RjZWRGpSZ01TdTZRcEJXM2NOUkUKLS0tIC9rNmNzWitMdEd5dXQvdWlELzhM
M0xoL1dQR0kvMWpzN0RMNWVCTFQxNFUKj9LPjBo5NGOrGYNvu8qZ13PLYjLEWllU
LARzEn4XgkeHckouwvxZYMCx7WxmAruRWaOvnxTIczzSNP7wIrqnkA==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2024-03-10T13:46:59Z"
mac: ENC[AES256_GCM,data:j+bdp0emAtTNNI7aZsKTJ+uARsuyLb9GRV0CeIb2EoZaOmj5cJpUzYtcAWIdCYplt1ZScCcR7iQPUlCzUb0+pXth7QDibtGJcj0dqw87DoaY3cqm7jNkKteiIYxXOCmbMBgED9eMxQVdcGZTDSuTQ0KjFYoXkcUSriMsJltDUDc=,iv:+eLNmlxeqB/Q7Rmz5B/wZSajiesV+/ED3ROJuuShpfo=,tag:95xKRRuqRZkUFUjHbPrDNw==,type:str]
pgp: []
unencrypted_suffix: _unencrypted
version: 3.8.1

View File

@@ -1,24 +0,0 @@
{
"data": "ENC[AES256_GCM,data:Um00c+kry3QrHEZVdlUws+gGGvtPKh8WzkpT6CHL7uwHRUWc+5E0bvlwXFJTkmPdGOOV2Jx9fGvSKpQb1/MPJhMhpCAw5n69QIRjVVURZcvVVFrl+eNO2sf/h2GTFvKRAtlcNAh7cvjkpiB3r+S7mRYSI914B7w8GLTdRFvtqYo=,iv:gk7S1SiA0iBAfpXLhhPJuexolP6w1XAd8M2H+sqqmoM=,tag:O8Eoa4LjEo14H/+1W5rcgQ==,type:str]",
"sops": {
"kms": null,
"gcp_kms": null,
"azure_kv": null,
"hc_vault": null,
"age": [
{
"recipient": "age19ax6vm3pv8rph5tq3mmehd9sy9jk823tw8svsd790r0lkslycquqvlwz9m",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBWYmNFOFlnbm1FdXdGWUNr\nOGN3THhDUyt4SDVzcHY5dEYrSWsrQm1UOFJvCmhXaWFlcC8wazROaXZzcm9tUnFM\nQlphZ0x6c0RhbzY0aGVFbXdOa1BHbG8KLS0tIHF2YUNTVnZ3Z25FSnFlTEdmdXhE\nb3Z2UEp1c2UrOUp3NEdNcE5HSFptbzAKWGSTwv6xUNs/f+p0Bhpzg8zZ7EVK8kMm\no13fru2Cnqrw8Cj0zfx+7LODpBVzo03fLYKqZ6kbPZGa12ihk+fD4g==\n-----END AGE ENCRYPTED FILE-----\n"
},
{
"recipient": "age1l4stuz0vr7gs7pqwjrmezam44702jp2vmqaqyxw0l0r42kf9updq4dfhrw",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBKRVMrenM2Q1ZheFVPc2Rz\nYVd6UGoxbkpSQlZsNFN1dmIzSkl6SERwaTBRCjlHV3MvTEpxbDY4OHZjeUd5NmRF\nRmc1NzVCMTA0bDhwajNlMWZKTlNKK2cKLS0tIHRZZ0cxY2dwV21iRDlmeE5UZkM4\nK1dKV24yY3FKV2J3U2VzZWt2QnBSTHcKn8mq+1RnJG/nBbH2mAFpSFSTHDWvMqJj\nsziW9lK0cH6bPxhcpDO4oG8K08bdGHUVGtx2Zk81CDqzfamlMzzG2Q==\n-----END AGE ENCRYPTED FILE-----\n"
}
],
"lastmodified": "2024-03-09T07:59:38Z",
"mac": "ENC[AES256_GCM,data:zNh6Cioh4+r0+nx04yLqeQShozxl7bLLKSmwodnmHtVQVlOTjj5sDLMEAAmrj1Ym2KrBPJOgdm34Sl6AbsmiBLxzDcBKe6J68Y/LHIeaPkToRKpmoy9I9a177w0KzFXgNaU2ieH71egD+nf8JmGG61hDjpiJRpx1Lwxb16Bn+Xs=,iv:QxiUYymiGuH0EBwEhyg5gDzkSKvGhq0+0wERNEJ71UM=,tag:N1Nn9X9vrghwwJWC3kituA==,type:str]",
"pgp": null,
"unencrypted_suffix": "_unencrypted",
"version": "3.8.1"
}
}

1433
flake.lock generated

File diff suppressed because it is too large Load Diff

241
flake.nix
View File

@@ -4,11 +4,8 @@
inputs =
{
nixpkgs.url = "github:CHN-beta/nixpkgs/nixos-23.11";
nixpkgs-desktop.url = "github:CHN-beta/nixpkgs/nixos-23.11-desktop";
nixpkgs-unstable.url = "github:CHN-beta/nixpkgs/nixos-unstable";
"nixpkgs-23.05".url = "github:CHN-beta/nixpkgs/nixos-23.05";
"nixpkgs-22.11".url = "github:NixOS/nixpkgs/nixos-22.11";
"nixpkgs-22.05".url = "github:NixOS/nixpkgs/nixos-22.05";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-2305.url = "github:CHN-beta/nixpkgs/nixos-23.05";
home-manager = { url = "github:nix-community/home-manager/release-23.11"; inputs.nixpkgs.follows = "nixpkgs"; };
sops-nix =
{
@@ -21,6 +18,11 @@
nixos-cn = { url = "github:nixos-cn/flakes"; inputs.nixpkgs.follows = "nixpkgs"; };
nur-xddxdd = { url = "github:xddxdd/nur-packages"; inputs.nixpkgs.follows = "nixpkgs"; };
nix-vscode-extensions = { url = "github:nix-community/nix-vscode-extensions"; inputs.nixpkgs.follows = "nixpkgs"; };
nix-alien =
{
url = "github:thiagokokada/nix-alien";
inputs = { nixpkgs.follows = "nixpkgs"; nix-index-database.follows = "nix-index-database"; };
};
impermanence.url = "github:nix-community/impermanence";
qchem = { url = "github:Nix-QChem/NixOS-QChem/release-23.11"; inputs.nixpkgs.follows = "nixpkgs"; };
nixd = { url = "github:nix-community/nixd"; inputs.nixpkgs.follows = "nixpkgs"; };
@@ -28,6 +30,10 @@
nixpak = { url = "github:nixpak/nixpak"; inputs.nixpkgs.follows = "nixpkgs"; };
deploy-rs = { url = "github:serokell/deploy-rs"; inputs.nixpkgs.follows = "nixpkgs"; };
pnpm2nix-nzbr = { url = "github:CHN-beta/pnpm2nix-nzbr"; inputs.nixpkgs.follows = "nixpkgs"; };
# oneapi
lmix = { url = "github:CHN-beta/lmix"; inputs.nixpkgs.follows = "nixpkgs"; };
# nvhpc
dguibert-nur-packages = { url = "github:CHN-beta/dguibert-nur-packages"; inputs.nixpkgs.follows = "nixpkgs"; };
plasma-manager =
{
url = "github:pjones/plasma-manager";
@@ -35,13 +41,8 @@
};
nix-doom-emacs = { url = "github:nix-community/nix-doom-emacs"; inputs.nixpkgs.follows = "nixpkgs"; };
nur-linyinfeng = { url = "github:linyinfeng/nur-packages"; inputs.nixpkgs.follows = "nixpkgs"; };
nixos-hardware.url = "github:CHN-beta/nixos-hardware";
nixos-hardware.url = "github:NixOS/nixos-hardware";
envfs = { url = "github:Mic92/envfs"; inputs.nixpkgs.follows = "nixpkgs"; };
nix-fast-build = { url = "github:/Mic92/nix-fast-build"; inputs.nixpkgs.follows = "nixpkgs"; };
nix-flatpak.url = "github:gmodena/nix-flatpak";
chaotic =
{ url = "github:chaotic-cx/nyx"; inputs = { nixpkgs.follows = "nixpkgs"; home-manager.follows = "home-manager"; }; };
gricad = { url = "github:Gricad/nur-packages"; flake = false; };
misskey = { url = "git+https://github.com/CHN-beta/misskey?submodules=1"; flake = false; };
rsshub = { url = "github:DIYgod/RSSHub"; flake = false; };
@@ -56,147 +57,93 @@
nodesoup = { url = "github:olvb/nodesoup"; flake = false; };
tgbot-cpp = { url = "github:reo7sp/tgbot-cpp"; flake = false; };
v-sim = { url = "gitlab:l_sim/v_sim"; flake = false; };
win11os-kde = { url = "github:yeyushengfan258/Win11OS-kde"; flake = false; };
fluent-kde = { url = "github:vinceliuice/Fluent-kde"; flake = false; };
rycee = { url = "gitlab:rycee/nur-expressions"; flake = false; };
blurred-wallpaper = { url = "github:bouteillerAlan/blurredwallpaper"; flake = false; };
slate = { url = "github:TheBigWazz/Slate"; flake = false; };
linux-surface = { url = "github:linux-surface/linux-surface"; flake = false; };
lepton = { url = "github:black7375/Firefox-UI-Fix"; flake = false; };
lmod = { url = "github:TACC/Lmod"; flake = false; };
mumax = { url = "github:CHN-beta/mumax"; flake = false; };
kylin-virtual-keyboard = { url = "git+https://gitee.com/openkylin/kylin-virtual-keyboard.git"; flake = false; };
};
outputs = inputs:
{
packages.x86_64-linux = let devices = builtins.attrNames (builtins.readDir ./devices); in
let
localLib = import ./local/lib inputs.nixpkgs.lib;
in
{
default = inputs.nixpkgs.legacyPackages.x86_64-linux.writeText "systems"
(builtins.concatStringsSep "\n" (builtins.map
(system: builtins.toString inputs.self.outputs.nixosConfigurations.${system}.config.system.build.toplevel)
devices));
}
// (
builtins.listToAttrs (builtins.map
(system:
{
name = system;
value = inputs.self.outputs.nixosConfigurations.${system}.config.system.build.toplevel;
})
devices)
);
nixosConfigurations = builtins.listToAttrs (builtins.concatLists
[
(builtins.map
(system:
{
name = system;
value = let localLib = import ./local/lib inputs.nixpkgs.lib; in inputs.nixpkgs.lib.nixosSystem
packages.x86_64-linux =
{
default = inputs.nixpkgs.legacyPackages.x86_64-linux.writeText "systems"
(builtins.concatStringsSep "\n" (builtins.map
(system: builtins.toString inputs.self.outputs.nixosConfigurations.${system}.config.system.build.toplevel)
[ "pc" "vps6" "vps7" "nas" "surface" ]));
}
// (
builtins.listToAttrs (builtins.map
(system:
{
system = "x86_64-linux";
specialArgs = { topInputs = inputs; inherit localLib; };
modules = localLib.mkModules
[
(moduleInputs: { config.nixpkgs.overlays = [(prev: final:
# replace pkgs with final to avoid infinite recursion
{ localPackages = import ./local/pkgs (moduleInputs // { pkgs = final; }); })]; })
./modules
./devices/${system}
];
};
})
[ "nas" "pcarm" "vps6" "vps7" "xmupc1" "xmupc2" ])
(builtins.map
(system:
{
name = system;
value = let localLib = import ./local/lib inputs.nixpkgs-desktop.lib; in inputs.nixpkgs.lib.nixosSystem
{
system = "x86_64-linux";
specialArgs = { topInputs = inputs; inherit localLib; };
modules = localLib.mkModules
[
(moduleInputs: { config.nixpkgs.overlays = [(prev: final:
{ localPackages = import ./local/pkgs (moduleInputs // { pkgs = final; }); })]; })
./modules
./devices/${system}
];
};
})
[ "pc" "surface" ])
(builtins.map
(system:
{
name = system;
value = let localLib = import ./local/lib inputs.nixpkgs.lib; in inputs.nixpkgs.lib.nixosSystem
{
system = "aarch64-linux";
specialArgs = { topInputs = inputs; inherit localLib; };
modules = inputs.nixpkgs.lib.mkModules
[
(moduleInputs: { config.nixpkgs.overlays = [(prev: final:
{ localPackages = import ./local/pkgs (moduleInputs // { pkgs = final; }); })]; })
./modules
./devices/${system}
];
};
})
[ "pi3b" ])
]);
# sudo HTTPS_PROXY=socks5://127.0.0.1:10884 nixos-install --flake .#bootstrap --option substituters http://127.0.0.1:5000 --option require-sigs false --option system-features gccarch-silvermont
# nix-serve -p 5000
# nix copy --substitute-on-destination --to ssh://server /run/current-system
# nix copy --to ssh://nixos@192.168.122.56 ./result
# sudo nixos-install --flake .#bootstrap
# --option substituters http://192.168.122.1:5000 --option require-sigs false
# sudo chattr -i var/empty
# nix-shell -p ssh-to-age --run 'cat /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age'
# sudo nixos-rebuild switch --flake .#vps6 --log-format internal-json -v |& nom --json
# boot.shell_on_fail systemd.setenv=SYSTEMD_SULOGIN_FORCE=1
# sudo usbipd
# ssh -R 3240:127.0.0.1:3240 root@192.168.122.57
# modprobe vhci-hcd
# sudo usbip bind -b 3-6
# usbip attach -r 127.0.0.1 -b 3-6
# systemd-cryptenroll --fido2-device=auto /dev/vda2
# systemd-cryptsetup attach root /dev/vda2
# ssh-keygen -t rsa -C root@pe -f /mnt/nix/persistent/etc/ssh/ssh_host_rsa_key
# ssh-keygen -t ed25519 -C root@pe -f /mnt/nix/persistent/etc/ssh/ssh_host_ed25519_key
# systemd-machine-id-setup --root=/mnt/nix/persistent
deploy =
{
sshUser = "root";
user = "root";
fastConnection = true;
autoRollback = false;
magicRollback = false;
nodes = builtins.listToAttrs (builtins.map
(node:
{
name = node;
value =
{
hostname = node;
profiles.system.path = inputs.self.nixosConfigurations.${node}.pkgs.deploy-rs.lib.activate.nixos
inputs.self.nixosConfigurations.${node};
};
})
[ "vps6" "vps7" "nas" "surface" "xmupc1" "xmupc2" "pi3b" ]
name = system;
value = inputs.self.outputs.nixosConfigurations.${system}.config.system.build.toplevel;
})
[ "pc" "vps6" "vps7" "nas" "surface" "xmupc1" ])
);
# ssh-keygen -t rsa -C root@pe -f /mnt/nix/persistent/etc/ssh/ssh_host_rsa_key
# ssh-keygen -t ed25519 -C root@pe -f /mnt/nix/persistent/etc/ssh/ssh_host_ed25519_key
# systemd-machine-id-setup --root=/mnt/nix/persistent
nixosConfigurations = builtins.listToAttrs (builtins.map
(system:
{
name = system;
value = inputs.nixpkgs.lib.nixosSystem
{
system = "x86_64-linux";
specialArgs = { topInputs = inputs; inherit localLib; };
modules = localLib.mkModules
[
(moduleInputs:
{
config.nixpkgs.overlays = [(final: prev: { localPackages =
import ./local/pkgs { inherit (moduleInputs) lib; pkgs = final; topInputs = inputs; };})];
})
./modules
./devices/${system}
];
};
})
[ "pc" "vps6" "vps7" "nas" "surface" "xmupc1" ]);
# sudo HTTPS_PROXY=socks5://127.0.0.1:10884 nixos-install --flake .#bootstrap --option substituters http://127.0.0.1:5000 --option require-sigs false --option system-features gccarch-silvermont
# nix-serve -p 5000
# nix copy --substitute-on-destination --to ssh://server /run/current-system
# nix copy --to ssh://nixos@192.168.122.56 ./result
# sudo nixos-install --flake .#bootstrap
# --option substituters http://192.168.122.1:5000 --option require-sigs false
# sudo chattr -i var/empty
# nix-shell -p ssh-to-age --run 'cat /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age'
# sudo nixos-rebuild switch --flake .#vps6 --log-format internal-json -v |& nom --json
# boot.shell_on_fail systemd.setenv=SYSTEMD_SULOGIN_FORCE=1
# sudo usbipd
# ssh -R 3240:127.0.0.1:3240 root@192.168.122.57
# modprobe vhci-hcd
# sudo usbip bind -b 3-6
# usbip attach -r 127.0.0.1 -b 3-6
# systemd-cryptenroll --fido2-device=auto /dev/vda2
# systemd-cryptsetup attach root /dev/vda2
deploy =
{
sshUser = "root";
user = "root";
fastConnection = true;
autoRollback = false;
magicRollback = false;
nodes = builtins.listToAttrs (builtins.map
(node:
{
name = node;
value =
{
hostname = node;
profiles.system.path = inputs.self.nixosConfigurations.${node}.pkgs.deploy-rs.lib.activate.nixos
inputs.self.nixosConfigurations.${node};
};
})
[ "vps6" "vps7" "nas" "surface" ]);
};
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks inputs.self.deploy) inputs.deploy-rs.lib;
overlays.default = final: prev:
{ localPackages = (import ./local/pkgs { inherit (inputs) lib; pkgs = final; }); };
config.archive = false;
};
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks inputs.self.deploy) inputs.deploy-rs.lib;
overlays.default = final: prev:
{ localPackages = (import ./local/pkgs { inherit (inputs) lib; pkgs = final; topInputs = inputs; }); };
config.archive = false;
devShell.x86_64-linux = let inherit (inputs.self.nixosConfigurations.pc) pkgs; in pkgs.mkShell
{
packages = with pkgs; [ pkg-config cmake ninja clang-tools_17 ];
buildInputs =
(with pkgs; [ fmt boost magic-enum libbacktrace eigen range-v3 ])
++ (with pkgs.localPackages; [ concurrencpp tgbot-cpp nameof ]);
# hardeningDisable = [ "all" ];
# NIX_DEBUG = "1";
};
};
}

View File

@@ -1,6 +1,6 @@
lib: rec
lib:
{
attrsToList = attrs: builtins.map (name: { inherit name; value = attrs.${name}; }) (builtins.attrNames attrs);
attrsToList = Attrs: builtins.map ( name: { inherit name; value = Attrs.${name}; } ) ( builtins.attrNames Attrs );
mkConditional = condition: trueResult: falseResult: let inherit (lib) mkMerge mkIf; in
mkMerge [ ( mkIf condition trueResult ) ( mkIf (!condition) falseResult ) ];
@@ -12,9 +12,9 @@ lib: rec
mkModules = moduleList:
(builtins.map
(
let handle = module: let type = builtins.typeOf module; in
if type == "path" || type == "string" then (handle (import module))
else if type == "lambda" then ({ pkgs, utils, ... }@inputs: (module inputs))
let handle = module:
if ( builtins.typeOf module ) == "path" then (handle (import module))
else if ( builtins.typeOf module ) == "lambda" then ({ pkgs, utils, ... }@inputs: (module inputs))
else module;
in handle
)
@@ -37,21 +37,4 @@ lib: rec
findIndex = e: list:
let findIndex_ = i: list: if (builtins.elemAt list i) == e then i else findIndex_ (i + 1) list;
in findIndex_ 0 list;
# return a list of path, including:
# - all .nix file in the directory except for default.nix
# - all directories containing a default.nix
findModules = path:
mkModules (builtins.filter (path: path != null) (builtins.map
(subPath:
if subPath.value == "regular" && subPath.name != "default.nix"
then if lib.strings.hasSuffix ".nix" subPath.name
then "${path}/${subPath.name}"
else null
else if subPath.value == "directory"
then if (builtins.readDir "${path}/${subPath.name}")."default.nix" or null == "regular"
then "${path}/${subPath.name}"
else null
else null)
(attrsToList (builtins.readDir path))));
}

View File

@@ -1,25 +0,0 @@
{ version ? "4.2.0", stdenv, fetchurl, lib }:
let versions =
{
"4.1.0" = "1k9anln9hmdjflrkq4iacrmhma7gfrfj6d0b8ywxys0wfpdvy12v";
"4.2.0" = "1aycw6ygzr1db6xf3z7v5lpznhs8j7gcpkawd304vcj5qw75cnpd";
};
in stdenv.mkDerivation
{
pname = "aocc";
inherit version;
src = fetchurl
{
url = "https://download.amd.com/developer/eula/aocc/aocc-"
+ builtins.concatStringsSep "-" (lib.lists.take 2 (builtins.splitVersion version))
+ "/aocc-compiler-${version}.tar";
sha256 = versions.${version};
};
dontBuild = true;
installPhase =
''
mkdir -p $out
cp -r bin include lib lib32 libexec share $out
'';
dontFixup = true;
}

View File

@@ -1,28 +0,0 @@
{ version ? "4.2.0", stdenv, fetchurl, lib }:
let versions =
{
"4.1.0" = "04780c2zks0g76c4n4a2cbbhs1qz4lza4ffiw1fj0md3f1lxihr5";
"4.2.0" = "0p4x0zza6y18hjjs1971gyc5kjd2f8nzzynp2jabhl2vxiys2nnj";
};
in stdenv.mkDerivation
{
pname = "aocl";
inherit version;
src = fetchurl
{
url = "https://download.amd.com/developer/eula/aocl/aocl-"
+ builtins.concatStringsSep "-" (lib.lists.take 2 (builtins.splitVersion version))
+ "/aocl-linux-aocc-${version}.tar.gz";
sha256 = versions.${version};
};
dontBuild = true;
installPhase =
''
installDir=$(mktemp -d)
bash ./install.sh -t $installDir
mkdir -p $out
cp -r $installDir/${version}/aocc/lib_LP64 $out/lib
cp -r $installDir/${version}/aocc/include_LP64 $out/include
'';
dontFixup = true;
}

View File

@@ -1,45 +0,0 @@
cmake_minimum_required(VERSION 3.14)
project(biu LANGUAGES CXX)
enable_testing()
include(GNUInstallDirs)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message("Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
find_package(magic_enum REQUIRED)
find_package(fmt REQUIRED)
find_package(Boost REQUIRED COMPONENTS headers iostreams)
# find_package(concurrencpp REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(range-v3 REQUIRED)
find_path(NAMEOF_INCLUDE_DIR nameof.hpp REQUIRED)
# find_path(TGBOTCPP_INCLUDE_DIR tgbot/tgbot.h REQUIRED)
# find_library(TGBOTCPP_LIB libTgBot.a REQUIRED)
# find_path(BACKTRACE_INCLUDE_DIR backtrace.h REQUIRED)
# find_library(BACKTRACE_LIB backtrace REQUIRED)
# add_library(biu SHARED src/common.cpp src/logger.cpp src/string.cpp)
add_library(biu SHARED src/common.cpp)
target_include_directories(biu PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
${NAMEOF_INCLUDE_DIR} ${TGBOTCPP_INCLUDE_DIR})
target_link_libraries(biu PUBLIC
magic_enum::magic_enum
fmt::fmt
Boost::headers Boost::iostreams
# concurrencpp::concurrencpp
Eigen3::Eigen
range-v3::range-v3)
# ${TGBOTCPP_LIB} ${BACKTRACE_LIB})
set_property(TARGET biu PROPERTY CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF)
install(TARGETS biu EXPORT biuConfig)
install(EXPORT biuConfig NAMESPACE ${PROJECT_NAME}:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/biu)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
get_property(ImportedTargets DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS)
message("Imported targets: ${ImportedTargets}")
message("List of compile features: ${CMAKE_CXX_COMPILE_FEATURES}")

View File

@@ -1,10 +1,17 @@
{
stdenv, cmake,
magic-enum, fmt, boost, eigen, range-v3, nameof
}: stdenv.mkDerivation
stdenv, fetchFromGitHub, cmake, pkg-config, ninja,
fmt, boost, magic-enum, libbacktrace, concurrencpp, tgbot-cpp, nameof, eigen, range-v3
}: stdenv.mkDerivation rec
{
name = "biu";
src = ./.;
buildInputs = [ magic-enum fmt boost eigen range-v3 nameof ];
nativeBuildInputs = [ cmake ];
name = "libbiu";
src = fetchFromGitHub
{
owner = "CHN-beta";
repo = "biu";
rev = "8ed2e52968f98d3a6ddbd01e86e57604ba3a7f54";
sha256 = "OqQ+QkjjIbpve/xn/DJA7ONw/bBg5zGNr+VJjc3o+K8=";
};
nativeBuildInputs = [ cmake pkg-config ninja ];
buildInputs = [ fmt boost magic-enum libbacktrace concurrencpp tgbot-cpp nameof eigen range-v3 ];
propagatedBuildInputs = buildInputs;
}

View File

@@ -1,10 +0,0 @@
# pragma once
// # include <biu/atomic/atomic.tpp>
// # include <biu/called_by.hpp>
# include <biu/common.tpp>
// # include <biu/concepts.tpp>
// # include <biu/format.tpp>
// # include <biu/logger.tpp>
// # include <biu/smartref.tpp>
// # include <biu/string.tpp>
# include <biu/eigen.hpp>

View File

@@ -1,41 +0,0 @@
# pragma once
# include <biu/logger.hpp>
namespace biu::detail_
{
template <DecayedType ValueType> class AtomicBase<ValueType, true>
: public Logger::ObjectMonitor<Atomic<ValueType, true>>, protected AtomicBase<ValueType, false>
{
using DeepBase_ = AtomicBase<ValueType, false>;
using DeepBase_::AtomicBase;
public: class TimeoutException : public Logger::Exception<TimeoutException>
{
using Logger::Exception<TimeoutException>::Exception;
};
protected: template
<
bool ReturnFunctionResult,
typename ConditionFunction = std::nullptr_t, typename Duration = std::nullptr_t, bool Nothrow = false
> static auto apply_
(
auto&& atomic, auto&& function,
ConditionFunction&& condition_function = nullptr, Duration timeout = nullptr
) -> DeepBase_::template ApplyReturnType_
<decltype(function), decltype(atomic), ReturnFunctionResult, ConditionFunction, Duration, Nothrow>
requires DeepBase_::template ApplyConstraint_
<decltype(function), decltype(atomic), ConditionFunction, Duration>;
protected: template <bool Nothrow = false, typename Duration = std::nullptr_t> static auto wait_
(auto&& atomic, auto&& condition_function, Duration timeout = nullptr)
-> DeepBase_::template WaitReturnType_<decltype(atomic), decltype(condition_function), Duration, Nothrow>
requires DeepBase_::template WaitConstraint_<decltype(condition_function), Duration>;
protected: template
<bool Nothrow = false, typename ConditionFunction = std::nullptr_t, typename Duration = std::nullptr_t>
static auto lock_
(auto&& atomic, ConditionFunction&& condition_function = nullptr, Duration timeout = nullptr)
-> DeepBase_::template LockReturnType_<decltype(atomic), Duration, Nothrow>
requires DeepBase_::template LockConstraint_<ConditionFunction, Duration>;
};
}

View File

@@ -1,267 +0,0 @@
# pragma once
# include <mutex>
# include <optional>
# include <condition_variable>
# include <cstddef>
# include <experimental/memory>
# include <biu/common.hpp>
# include <biu/concepts.hpp>
# include <biu/called_by.hpp>
namespace biu
{
template <DecayedType ValueType, bool UseLogger = true> class Atomic;
namespace detail_
{
template <DecayedType ValueType, bool UseLogger> class AtomicBase;
template <DecayedType ValueType> class AtomicBase<ValueType, false>
{
protected: mutable std::recursive_mutex Mutex_;
protected: mutable std::condition_variable_any ConditionVariable_;
protected: ValueType Value_;
AtomicBase() = default;
AtomicBase(const ValueType& value);
AtomicBase(ValueType&& value);
public: class TimeoutException : public std::exception
{
protected: std::string Message_;
public: explicit TimeoutException(std::string message);
public: const char* what() const noexcept override;
};
// Apply a function to stored value.
// Wait for some time (if provided) until condition funciton returns true (if provided)
// before applying the function.
protected: template
<
typename Function, typename Atomic,
typename ConditionFunction = std::nullptr_t, typename Duration = std::nullptr_t
>
constexpr static bool ApplyConstraint_ =
(
(std::invocable<Function, MoveQualifiers<Atomic, ValueType>> && std::is_null_pointer_v<ConditionFunction>)
|| (
InvocableWithResult<ConditionFunction, bool, const ValueType&>
&& (std::is_null_pointer_v<Duration> || SpecializationOf<Duration, std::chrono::duration>)
)
);
protected: template
<
typename Function, typename Atomic, bool ReturnFunctionResult,
typename ConditionFunction = std::nullptr_t, typename Duration = std::nullptr_t,
bool Nothrow = false
> using ApplyReturnType_ = std::conditional_t
<
Nothrow,
std::conditional_t
<
ReturnFunctionResult && !std::is_void_v<std::invoke_result<Function, ValueType>>,
std::optional<std::remove_cvref_t<FallbackIfNoTypeDeclared<std::invoke_result
<Function, MoveQualifiers<Atomic, ValueType>, int>>>>,
bool
>,
std::conditional_t
<
ReturnFunctionResult,
std::invoke_result_t<Function, MoveQualifiers<Atomic, ValueType>>,
Atomic&&
>
>;
protected: template
<
bool ReturnFunctionResult,
typename ConditionFunction = std::nullptr_t, typename Duration = std::nullptr_t,
bool Nothrow = false
> static auto apply_
(
auto&& atomic, auto&& function,
ConditionFunction&& condition_function = nullptr, Duration timeout = nullptr
) -> ApplyReturnType_
<decltype(function), decltype(atomic), ReturnFunctionResult, ConditionFunction, Duration, Nothrow>
requires ApplyConstraint_<decltype(function), decltype(atomic), ConditionFunction, Duration>;
// Wait until condition funciton returns true, with an optional timeout
protected: template <typename ConditionFunction, typename Duration = std::nullptr_t>
constexpr static bool WaitConstraint_
= (InvocableWithResult<ConditionFunction, bool, const ValueType&>
&& (std::is_null_pointer_v<Duration> || SpecializationOf<Duration, std::chrono::duration>));
protected: template
<typename Atomic, typename ConditionFunction, typename Duration = std::nullptr_t, bool Nothrow = false>
using WaitReturnType_
= std::conditional_t<Nothrow && !std::is_null_pointer_v<Duration>, bool, Atomic&&>;
protected: template <bool Nothrow = false, typename Duration = std::nullptr_t> static auto wait_
(auto&& atomic, auto&& condition_function, Duration timeout = nullptr)
-> WaitReturnType_<decltype(atomic), decltype(condition_function), Duration, Nothrow>
requires WaitConstraint_<decltype(condition_function), Duration>;
protected: template <typename ConditionFunction = std::nullptr_t, typename Duration = std::nullptr_t>
constexpr static bool LockConstraint_
= std::is_null_pointer_v<ConditionFunction> ||
(
InvocableWithResult<ConditionFunction, bool, const ValueType&>
&& (std::is_null_pointer_v<Duration> || SpecializationOf<Duration, std::chrono::duration>)
);
protected: template <typename Atomic, typename Duration = std::nullptr_t, bool Nothrow = false>
using LockReturnType_
= std::conditional_t
<
Nothrow && !std::is_null_pointer_v<Duration>,
std::optional<std::conditional_t
<
std::is_const_v<Atomic>,
typename std::remove_reference_t<Atomic>::template Guard<true>,
typename std::remove_reference_t<Atomic>::template Guard<false>
>>,
std::conditional_t
<
std::is_const_v<Atomic>,
typename std::remove_reference_t<Atomic>::template Guard<true>,
typename std::remove_reference_t<Atomic>::template Guard<false>
>
>;
protected: template
<bool Nothrow = false, typename ConditionFunction = std::nullptr_t, typename Duration = std::nullptr_t>
static auto lock_
(auto&& atomic, ConditionFunction&& condition_function = nullptr, Duration timeout = nullptr)
-> LockReturnType_<decltype(atomic), Duration, Nothrow>
requires LockConstraint_<ConditionFunction, Duration>;
};
}
// Thread safe wrapper of custom class
template <DecayedType ValueType, bool UseLogger> class Atomic : public detail_::AtomicBase<ValueType, UseLogger>
{
public: Atomic() = default;
public: Atomic(const ValueType& value);
public: Atomic(ValueType&& value);
public: template <bool OtherUseLogger> Atomic(const Atomic<ValueType, OtherUseLogger>& other);
public: template <bool OtherUseLogger> Atomic(Atomic<ValueType, OtherUseLogger>&& other);
public: Atomic<ValueType, UseLogger>& operator=(const ValueType& value);
public: Atomic<ValueType, UseLogger>& operator=(ValueType&& value);
public: template <bool OtherUseLogger>
Atomic<ValueType, UseLogger>& operator=(const Atomic<ValueType, OtherUseLogger>& other);
public: template <bool OtherUseLogger>
Atomic<ValueType, UseLogger>& operator=(Atomic<ValueType, OtherUseLogger>&& other);
public: ValueType get() const&;
public: ValueType get() &&;
public: operator ValueType() const&;
public: operator ValueType() &&;
protected: using DeepBase_ = detail_::AtomicBase<ValueType, false>;
public: template <bool ReturnFunctionResult = false> auto apply(auto&& function) const&
-> DeepBase_::template ApplyReturnType_<decltype(function), decltype(*this), ReturnFunctionResult>
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this)>;
public: template <bool ReturnFunctionResult = false> auto apply(auto&& function) &
-> DeepBase_::template ApplyReturnType_<decltype(function), decltype(*this), ReturnFunctionResult>
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this)>;
public: template <bool ReturnFunctionResult = false> auto apply(auto&& function) &&
-> DeepBase_::template ApplyReturnType_<decltype(function), decltype(*this), ReturnFunctionResult>
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this)>;
public: template <bool ReturnFunctionResult = false>
auto apply(auto&& function, auto&& condition_function) const&
-> DeepBase_::template ApplyReturnType_
<decltype(function), decltype(*this), ReturnFunctionResult, decltype(condition_function)>
requires DeepBase_::template ApplyConstraint_
<decltype(function), decltype(*this), decltype(condition_function)>;
public: template <bool ReturnFunctionResult = false> auto apply(auto&& function, auto&& condition_function) &
-> DeepBase_::template ApplyReturnType_
<decltype(function), decltype(*this), ReturnFunctionResult, decltype(condition_function)>
requires DeepBase_::template ApplyConstraint_
<decltype(function), decltype(*this), decltype(condition_function)>;
public: template <bool ReturnFunctionResult = false> auto apply(auto&& function, auto&& condition_function) &&
-> DeepBase_::template ApplyReturnType_
<decltype(function), decltype(*this), ReturnFunctionResult, decltype(condition_function)>
requires DeepBase_::template ApplyConstraint_
<decltype(function), decltype(*this), decltype(condition_function)>;
public: template <bool ReturnFunctionResult = false, bool Nothrow = false>
auto apply(auto&& function, auto&& condition_function, auto timeout) const&
-> DeepBase_::template ApplyReturnType_
<
decltype(function), decltype(*this), ReturnFunctionResult,
decltype(condition_function), decltype(timeout), Nothrow
> requires DeepBase_::template ApplyConstraint_
<decltype(function), decltype(*this), decltype(condition_function), decltype(timeout)>;
public: template <bool ReturnFunctionResult = false, bool Nothrow = false>
auto apply(auto&& function, auto&& condition_function, auto timeout) &
-> DeepBase_::template ApplyReturnType_
<
decltype(function), decltype(*this), ReturnFunctionResult,
decltype(condition_function), decltype(timeout), Nothrow
> requires DeepBase_::template ApplyConstraint_
<decltype(function), decltype(*this), decltype(condition_function), decltype(timeout)>;
public: template <bool ReturnFunctionResult = false, bool Nothrow = false>
auto apply(auto&& function, auto&& condition_function, auto timeout) &&
-> DeepBase_::template ApplyReturnType_
<
decltype(function), decltype(*this), ReturnFunctionResult,
decltype(condition_function), decltype(timeout), Nothrow
> requires DeepBase_::template ApplyConstraint_
<decltype(function), decltype(*this), decltype(condition_function), decltype(timeout)>;
public: auto wait(auto&& condition_function) const&
-> DeepBase_::template WaitReturnType_<decltype(*this), decltype(condition_function)>
requires DeepBase_::template WaitConstraint_<decltype(condition_function)>;
public: auto wait(auto&& condition_function) &
-> DeepBase_::template WaitReturnType_<decltype(*this), decltype(condition_function)>
requires DeepBase_::template WaitConstraint_<decltype(condition_function)>;
public: auto wait(auto&& condition_function) &&
-> DeepBase_::template WaitReturnType_<decltype(*this), decltype(condition_function)>
requires DeepBase_::template WaitConstraint_<decltype(condition_function)>;
public: template <bool Nothrow = false> auto wait(auto&& condition_function, auto timeout) const&
-> DeepBase_::template WaitReturnType_
<decltype(*this), decltype(condition_function), decltype(timeout), Nothrow>
requires DeepBase_::template WaitConstraint_<decltype(condition_function), decltype(timeout)>;
public: template <bool Nothrow = false> auto wait(auto&& condition_function, auto timeout) &
-> DeepBase_::template WaitReturnType_
<decltype(*this), decltype(condition_function), decltype(timeout), Nothrow>
requires DeepBase_::template WaitConstraint_<decltype(condition_function), decltype(timeout)>;
public: template <bool Nothrow = false> auto wait(auto&& condition_function, auto timeout) &&
-> DeepBase_::template WaitReturnType_
<decltype(*this), decltype(condition_function), decltype(timeout), Nothrow>
requires DeepBase_::template WaitConstraint_<decltype(condition_function), decltype(timeout)>;
// Attain lock from outside when constructing, and release when destructing.
// For non-const variant, When destructing, ConditionVariable_.notify_all() is called.
public: template <bool Const> class Guard
{
protected: std::unique_lock<std::recursive_mutex> Lock_;
protected: std::experimental::observer_ptr
<std::conditional_t<Const, const Atomic<ValueType, UseLogger>, Atomic<ValueType, UseLogger>>> Value_;
public: template <bool OtherConst> Guard(const Guard<OtherConst>& other) requires (Const || !OtherConst);
public: Guard
(decltype(Lock_)&& lock, decltype(Value_) value, CalledBy<detail_::AtomicBase<ValueType, UseLogger>>);
public: ~Guard();
public: std::conditional_t<Const, const ValueType&, ValueType&> operator*() const&;
public: std::conditional_t<Const, const ValueType*, ValueType*> operator->() const&;
public: std::conditional_t<Const, const ValueType&, ValueType&> value() const&;
public: auto operator*() const&& = delete;
public: auto operator->() const&& = delete;
public: auto value() const&& = delete;
};
public: auto lock() const& -> DeepBase_::template LockReturnType_<decltype(*this)>
requires DeepBase_::template LockConstraint_<>;
public: auto lock() & -> DeepBase_::template LockReturnType_<decltype(*this)>
requires DeepBase_::template LockConstraint_<>;
public: auto lock() const&& = delete;
public: auto lock(auto&& condition_function) const&
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(condition_function)>
requires DeepBase_::template LockConstraint_<decltype(condition_function)>;
public: auto lock(auto&& condition_function) &
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(condition_function)>
requires DeepBase_::template LockConstraint_<decltype(condition_function)>;
public: auto lock(auto&& condition_function) const&& = delete;
public: template <bool Nothrow = false> auto lock(auto&& condition_function, auto timeout) const&
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(timeout), Nothrow>
requires DeepBase_::template LockConstraint_<decltype(condition_function), decltype(timeout)>;
public: template <bool Nothrow = false> auto lock(auto&& condition_function, auto timeout) &
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(timeout), Nothrow>
requires DeepBase_::template LockConstraint_<decltype(condition_function), decltype(timeout)>;
public: template <bool Nothrow = false> auto lock(auto&& condition_function, auto timeout) const&& = delete;
};
}

View File

@@ -1,366 +0,0 @@
# pragma once
# include <biu/atomic/nolog.hpp>
namespace biu
{
template <DecayedType ValueType> detail_::AtomicBase<ValueType, false>::AtomicBase(const ValueType& value)
: Value_{value} {}
template <DecayedType ValueType> detail_::AtomicBase<ValueType, false>::AtomicBase(ValueType&& value)
: Value_{std::move(value)} {}
template <DecayedType ValueType>
detail_::AtomicBase<ValueType, false>::TimeoutException::TimeoutException(std::string)
: Message_{"TimeoutException"} {}
template <DecayedType ValueType>
const char* detail_::AtomicBase<ValueType, false>::TimeoutException::what() const noexcept
{return Message_.c_str();}
template <DecayedType ValueType>
template <bool ReturnFunctionResult, typename ConditionFunction, typename Duration, bool Nothrow>
auto detail_::AtomicBase<ValueType, false>::apply_
(auto&& atomic, auto&& function, ConditionFunction&& condition_function, Duration timeout)
-> ApplyReturnType_
<decltype(function), decltype(atomic), ReturnFunctionResult, ConditionFunction, Duration, Nothrow>
requires ApplyConstraint_<decltype(function), decltype(atomic), ConditionFunction, Duration>
{
std::unique_lock lock{atomic.Mutex_};
// try to meet the condition
if constexpr (!std::is_null_pointer_v<ConditionFunction>)
{
if constexpr (std::is_null_pointer_v<Duration>)
atomic.ConditionVariable_.wait(lock, [&]
{return std::forward<ConditionFunction>(condition_function)(std::as_const(atomic.Value_));});
else if (!atomic.ConditionVariable_.wait_for(lock, timeout, [&]
{return std::forward<ConditionFunction>(condition_function)(std::as_const(atomic.Value_));}))
{
if constexpr (Nothrow)
{
if constexpr
(ReturnFunctionResult && !std::is_void_v<std::invoke_result_t<decltype(function), ValueType>>)
return std::nullopt;
else return false;
}
else throw TimeoutException{};
}
}
// apply the function and return
if constexpr (ReturnFunctionResult && !std::is_void_v<std::invoke_result_t<decltype(function), ValueType>>)
{
auto&& result = std::forward<decltype(function)>(function)
(static_cast<MoveQualifiers<decltype(atomic), ValueType>&&>(atomic.Value_));
if constexpr (!std::is_const_v<decltype(atomic)>) atomic.ConditionVariable_.notify_all();
return std::forward<decltype(result)>(result);
}
else
{
std::forward<decltype(function)>(function)
(static_cast<MoveQualifiers<decltype(atomic), ValueType>&&>(atomic.Value_));
if constexpr (!std::is_const_v<decltype(atomic)>) atomic.ConditionVariable_.notify_all();
if constexpr (ReturnFunctionResult && std::is_void_v<std::invoke_result_t<decltype(function), ValueType>>)
return;
else return std::forward<decltype(atomic)>(atomic);
}
}
template <DecayedType ValueType> template <bool Nothrow, typename Duration>
auto detail_::AtomicBase<ValueType, false>::wait_(auto&& atomic, auto&& condition_function, Duration timeout)
-> WaitReturnType_<decltype(atomic), decltype(condition_function), Duration, Nothrow>
requires WaitConstraint_<decltype(condition_function), Duration>
{
std::unique_lock lock{atomic.Mutex_};
if constexpr (std::is_null_pointer_v<Duration>)
{
atomic.ConditionVariable_.wait(lock, [&]
{return std::forward<decltype(condition_function)>(condition_function)(std::as_const(atomic.Value_));});
return std::forward<decltype(atomic)>(atomic);
}
else
{
if (!atomic.ConditionVariable_.wait_for(lock, timeout, [&]
{return std::forward<decltype(condition_function)>(condition_function)(std::as_const(atomic.Value_));}))
{
if constexpr (Nothrow) return false;
else throw TimeoutException{};
}
else
{
if constexpr (Nothrow) return true;
else return std::forward<decltype(atomic)>(atomic);
}
}
}
template <DecayedType ValueType> template <bool Nothrow, typename ConditionFunction, typename Duration>
auto detail_::AtomicBase<ValueType, false>::lock_
(auto&& atomic, ConditionFunction&& condition_function, Duration timeout)
-> LockReturnType_<decltype(atomic), Duration, Nothrow> requires LockConstraint_<ConditionFunction, Duration>
{
if constexpr (std::is_null_pointer_v<ConditionFunction>)
return {std::unique_lock{atomic.Mutex_}, std::experimental::make_observer(&atomic), {}};
else if constexpr (std::is_null_pointer_v<Duration>)
{
std::unique_lock lock{atomic.Mutex_};
atomic.ConditionVariable_.wait(lock, [&]
{return std::forward<ConditionFunction>(condition_function)(std::as_const(atomic.Value_));});
return {std::move(lock), std::experimental::make_observer(&atomic), {}};
}
else
{
std::unique_lock lock{atomic.Mutex_};
if (!atomic.ConditionVariable_.wait_for(lock, timeout, [&]
{return std::forward<ConditionFunction>(condition_function)(std::as_const(atomic.Value_));}))
{
if constexpr (Nothrow) return std::nullopt;
else throw TimeoutException{};
}
else
return {{std::move(lock), std::experimental::make_observer(&atomic), {}}};
}
}
template <DecayedType ValueType, bool UseLogger> Atomic<ValueType, UseLogger>::Atomic(const ValueType& value)
: detail_::AtomicBase<ValueType, UseLogger>{value} {}
template <DecayedType ValueType, bool UseLogger> Atomic<ValueType, UseLogger>::Atomic(ValueType&& value)
: detail_::AtomicBase<ValueType, UseLogger>{std::move(value)} {}
template <DecayedType ValueType, bool UseLogger> template <bool OtherUseLogger>
Atomic<ValueType, UseLogger>::Atomic(const Atomic<ValueType, OtherUseLogger>& other)
: detail_::AtomicBase<ValueType, UseLogger>{other} {}
template <DecayedType ValueType, bool UseLogger> template <bool OtherUseLogger>
Atomic<ValueType, UseLogger>::Atomic(Atomic<ValueType, OtherUseLogger>&& other)
: detail_::AtomicBase<ValueType, UseLogger>{std::move(other)} {}
template <DecayedType ValueType, bool UseLogger>
Atomic<ValueType, UseLogger>& Atomic<ValueType, UseLogger>::operator=(const ValueType& value)
{
std::scoped_lock lock{DeepBase_::Mutex_};
DeepBase_::Value_ = value;
DeepBase_::ConditionVariable_.notify_all();
return *this;
}
template <DecayedType ValueType, bool UseLogger>
Atomic<ValueType, UseLogger>& Atomic<ValueType, UseLogger>::operator=(ValueType&& value)
{
std::scoped_lock lock{DeepBase_::Mutex_};
DeepBase_::Value_ = std::move(value);
DeepBase_::ConditionVariable_.notify_all();
return *this;
}
template <DecayedType ValueType, bool UseLogger> template <bool OtherUseLogger>
Atomic<ValueType, UseLogger>& operator=(const Atomic<ValueType, OtherUseLogger>& other)
{
std::scoped_lock lock{DeepBase_::Mutex_};
DeepBase_::Value_ = value;
DeepBase_::ConditionVariable_.notify_all();
return *this;
}
template <DecayedType ValueType, bool UseLogger> template <bool OtherUseLogger>
Atomic<ValueType, UseLogger>& operator=(Atomic<ValueType, OtherUseLogger>&& other)
{
std::scoped_lock lock{DeepBase_::Mutex_};
DeepBase_::Value_ = std::move(value);
DeepBase_::ConditionVariable_.notify_all();
return *this;
}
template <DecayedType ValueType, bool UseLogger> ValueType Atomic<ValueType, UseLogger>::get() const&
{
std::scoped_lock lock{DeepBase_::Mutex_};
return DeepBase_::Value_;
}
template <DecayedType ValueType, bool UseLogger> ValueType Atomic<ValueType, UseLogger>::get() &&
{
std::scoped_lock lock{DeepBase_::Mutex_};
return std::move(DeepBase_::Value_);
}
template <DecayedType ValueType, bool UseLogger> Atomic<ValueType, UseLogger>::operator ValueType() const&
{return get();}
template <DecayedType ValueType, bool UseLogger> Atomic<ValueType, UseLogger>::operator ValueType() &&
{return std::move(*this).get();}
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult>
auto Atomic<ValueType, UseLogger>::apply(auto&& function) const&
-> DeepBase_::template ApplyReturnType_<decltype(function), decltype(*this), ReturnFunctionResult>
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this)>
{return apply_<ReturnFunctionResult>(*this, std::forward<decltype(function)>(function));}
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult>
auto Atomic<ValueType, UseLogger>::apply(auto&& function) &
-> DeepBase_::template ApplyReturnType_<decltype(function), decltype(*this), ReturnFunctionResult>
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this)>
{return apply_<ReturnFunctionResult>(*this, std::forward<decltype(function)>(function));}
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult>
auto Atomic<ValueType, UseLogger>::apply(auto&& function) &&
-> DeepBase_::template ApplyReturnType_<decltype(function), decltype(*this), ReturnFunctionResult>
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this)>
{return apply_<ReturnFunctionResult>(std::move(*this), std::forward<decltype(function)>(function));}
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult>
auto Atomic<ValueType, UseLogger>::apply(auto&& function, auto&& condition_function) const&
-> DeepBase_::template ApplyReturnType_
<decltype(function), decltype(*this), ReturnFunctionResult, decltype(condition_function)>
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this), decltype(condition_function)>
{
return apply_<ReturnFunctionResult>
(
*this, std::forward<decltype(function)>(function),
std::forward<decltype(condition_function)>(condition_function)
);
}
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult>
auto Atomic<ValueType, UseLogger>::apply(auto&& function, auto&& condition_function) &
-> DeepBase_::template ApplyReturnType_
<decltype(function), decltype(*this), ReturnFunctionResult, decltype(condition_function)>
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this), decltype(condition_function)>
{
return apply_<ReturnFunctionResult>
(
*this, std::forward<decltype(function)>(function),
std::forward<decltype(condition_function)>(condition_function)
);
}
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult>
auto Atomic<ValueType, UseLogger>::apply(auto&& function, auto&& condition_function) &&
-> DeepBase_::template ApplyReturnType_
<decltype(function), decltype(*this), ReturnFunctionResult, decltype(condition_function)>
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this), decltype(condition_function)>
{
return apply_<ReturnFunctionResult>
(
std::move(*this), std::forward<decltype(function)>(function),
std::forward<decltype(condition_function)>(condition_function)
);
}
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult, bool Nothrow>
auto Atomic<ValueType, UseLogger>::apply(auto&& function, auto&& condition_function, auto timeout) const&
-> DeepBase_::template ApplyReturnType_
<
decltype(function), decltype(*this), ReturnFunctionResult,
decltype(condition_function), decltype(timeout), Nothrow
> requires DeepBase_::template ApplyConstraint_
<decltype(function), decltype(*this), decltype(condition_function), decltype(timeout)>
{
return apply_<ReturnFunctionResult, Nothrow>
(
*this, std::forward<decltype(function)>(function),
std::forward<decltype(condition_function)>(condition_function), timeout
);
}
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult, bool Nothrow>
auto Atomic<ValueType, UseLogger>::apply(auto&& function, auto&& condition_function, auto timeout) &
-> DeepBase_::template ApplyReturnType_
<
decltype(function), decltype(*this), ReturnFunctionResult,
decltype(condition_function), decltype(timeout), Nothrow
> requires DeepBase_::template ApplyConstraint_
<decltype(function), decltype(*this), decltype(condition_function), decltype(timeout)>
{
return apply_<ReturnFunctionResult, Nothrow>
(
*this, std::forward<decltype(function)>(function),
std::forward<decltype(condition_function)>(condition_function), timeout
);
}
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult, bool Nothrow>
auto Atomic<ValueType, UseLogger>::apply(auto&& function, auto&& condition_function, auto timeout) &&
-> DeepBase_::template ApplyReturnType_
<
decltype(function), decltype(*this), ReturnFunctionResult,
decltype(condition_function), decltype(timeout), Nothrow
> requires DeepBase_::template ApplyConstraint_
<decltype(function), decltype(*this), decltype(condition_function), decltype(timeout)>
{
return apply_<ReturnFunctionResult, Nothrow>
(
std::move(*this), std::forward<decltype(function)>(function),
std::forward<decltype(condition_function)>(condition_function), timeout
);
}
template <DecayedType ValueType, bool UseLogger>
auto Atomic<ValueType, UseLogger>::wait(auto&& condition_function) const&
-> DeepBase_::template WaitReturnType_<decltype(*this), decltype(condition_function)>
requires DeepBase_::template WaitConstraint_<decltype(condition_function)>
{return wait_(*this, std::forward<decltype(condition_function)>(condition_function));}
template <DecayedType ValueType, bool UseLogger>
auto Atomic<ValueType, UseLogger>::wait(auto&& condition_function) &
-> DeepBase_::template WaitReturnType_<decltype(*this), decltype(condition_function)>
requires DeepBase_::template WaitConstraint_<decltype(condition_function)>
{return wait_(*this, std::forward<decltype(condition_function)>(condition_function));}
template <DecayedType ValueType, bool UseLogger>
auto Atomic<ValueType, UseLogger>::wait(auto&& condition_function) &&
-> DeepBase_::template WaitReturnType_<decltype(*this), decltype(condition_function)>
requires DeepBase_::template WaitConstraint_<decltype(condition_function)>
{return wait_(std::move(*this), std::forward<decltype(condition_function)>(condition_function));}
template <DecayedType ValueType, bool UseLogger> template <bool Nothrow>
auto Atomic<ValueType, UseLogger>::wait(auto&& condition_function, auto timeout) const&
-> DeepBase_::template WaitReturnType_
<decltype(*this), decltype(condition_function), decltype(timeout), Nothrow>
requires DeepBase_::template WaitConstraint_<decltype(condition_function), decltype(timeout)>
{return wait_<Nothrow>(*this, std::forward<decltype(condition_function)>(condition_function), timeout);}
template <DecayedType ValueType, bool UseLogger> template <bool Nothrow>
auto Atomic<ValueType, UseLogger>::wait(auto&& condition_function, auto timeout) &
-> DeepBase_::template WaitReturnType_
<decltype(*this), decltype(condition_function), decltype(timeout), Nothrow>
requires DeepBase_::template WaitConstraint_<decltype(condition_function), decltype(timeout)>
{return wait_<Nothrow>(*this, std::forward<decltype(condition_function)>(condition_function), timeout);}
template <DecayedType ValueType, bool UseLogger> template <bool Nothrow>
auto Atomic<ValueType, UseLogger>::wait(auto&& condition_function, auto timeout) &&
-> DeepBase_::template WaitReturnType_
<decltype(*this), decltype(condition_function), decltype(timeout), Nothrow>
requires DeepBase_::template WaitConstraint_<decltype(condition_function), decltype(timeout)>
{
return wait_<Nothrow>
(std::move(*this), std::forward<decltype(condition_function)>(condition_function), timeout);
}
template <DecayedType ValueType, bool UseLogger> template <bool Const> template <bool OtherConst>
Atomic<ValueType, UseLogger>::Guard<Const>::Guard(const Guard<OtherConst>& other)
requires (Const || !OtherConst)
: Lock_{other.Lock_}, Value_{other.Value_} {}
template <DecayedType ValueType, bool UseLogger> template <bool Const>
Atomic<ValueType, UseLogger>::Guard<Const>::Guard
(decltype(Lock_)&& lock, decltype(Value_) value, CalledBy<detail_::AtomicBase<ValueType, UseLogger>>)
: Lock_{std::move(lock)}, Value_{value} {}
template <DecayedType ValueType, bool UseLogger> template <bool Const>
Atomic<ValueType, UseLogger>::Guard<Const>::~Guard()
{Value_->ConditionVariable_.notify_all();}
template <DecayedType ValueType, bool UseLogger> template <bool Const>
std::conditional_t<Const, const ValueType&, ValueType&>
Atomic<ValueType, UseLogger>::Guard<Const>::operator*() const&
{return Value_->Value_;}
template <DecayedType ValueType, bool UseLogger> template <bool Const>
std::conditional_t<Const, const ValueType*, ValueType*>
Atomic<ValueType, UseLogger>::Guard<Const>::operator->() const&
{return &Value_->Value_;}
template <DecayedType ValueType, bool UseLogger> template <bool Const>
std::conditional_t<Const, const ValueType&, ValueType&>
Atomic<ValueType, UseLogger>::Guard<Const>::value() const&
{return Value_->Value_;}
template <DecayedType ValueType, bool UseLogger> auto Atomic<ValueType, UseLogger>::lock() const&
-> DeepBase_::template LockReturnType_<decltype(*this)> requires DeepBase_::template LockConstraint_<>
{return lock_(*this);}
template <DecayedType ValueType, bool UseLogger> auto Atomic<ValueType, UseLogger>::lock() &
-> DeepBase_::template LockReturnType_<decltype(*this)> requires DeepBase_::template LockConstraint_<>
{return lock_(*this);}
template <DecayedType ValueType, bool UseLogger>
auto Atomic<ValueType, UseLogger>::lock(auto&& condition_function) const&
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(condition_function)>
requires DeepBase_::template LockConstraint_<decltype(condition_function)>
{return lock_(*this, condition_function);}
template <DecayedType ValueType, bool UseLogger>
auto Atomic<ValueType, UseLogger>::lock(auto&& condition_function) &
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(condition_function)>
requires DeepBase_::template LockConstraint_<decltype(condition_function)>
{return lock_(*this, condition_function);}
template <DecayedType ValueType, bool UseLogger> template <bool Nothrow>
auto Atomic<ValueType, UseLogger>::lock(auto&& condition_function, auto timeout) const&
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(timeout), Nothrow>
requires DeepBase_::template LockConstraint_<decltype(condition_function), decltype(timeout)>
{return lock_<Nothrow>(*this, condition_function, timeout);}
template <DecayedType ValueType, bool UseLogger> template <bool Nothrow>
auto Atomic<ValueType, UseLogger>::lock(auto&& condition_function, auto timeout) &
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(timeout), Nothrow>
requires DeepBase_::template LockConstraint_<decltype(condition_function), decltype(timeout)>
{return lock_<Nothrow>(*this, condition_function, timeout);}
}

View File

@@ -1,10 +0,0 @@
# pragma once
namespace biu
{
template <typename AllowedType> class CalledBy
{
protected: CalledBy() = default;
friend AllowedType;
};
}

View File

@@ -1,66 +0,0 @@
# pragma once
# include <regex>
# include <fmt/format.h>
# include <magic_enum.hpp>
namespace biu
{
std::size_t hash(auto&&... objs);
[[gnu::always_inline]] void unused(auto&&...);
using uint128_t = __uint128_t;
inline namespace literals
{
using namespace std::literals;
using namespace fmt::literals;
std::regex operator""_re(const char* str, std::size_t len);
}
inline namespace stream_operators { using namespace magic_enum::iostream_operators; }
struct CaseInsensitiveStringLessComparator
{
template <typename String> constexpr bool operator()(const String& s1, const String& s2) const;
};
namespace detail_
{
template <typename T> struct RemoveMemberPointerHelper { using Type = T; };
template <typename Class, typename Member> struct RemoveMemberPointerHelper<Member Class::*>
{ using Type = Member; };
}
template <typename MemberPointer> using RemoveMemberPointer
= typename detail_::RemoveMemberPointerHelper<MemberPointer>::Type;
[[noreturn]] void block_forever();
namespace detail_
{
template <typename From, typename To> struct MoveQualifiersHelper
{
protected: static constexpr bool Const_ = std::is_const_v<From>;
protected: static constexpr bool Volatile_ = std::is_volatile_v<From>;
protected: static constexpr bool Reference_ = std::is_reference_v<From>;
protected: static constexpr bool Lvalue_ = std::is_lvalue_reference_v<From>;
protected: using NoCvrefType_ = std::remove_cvref_t<To>;
protected: using NoCvType_
= std::conditional_t<Reference_, std::conditional_t<Lvalue_, NoCvrefType_&, NoCvrefType_&&>, NoCvrefType_>;
protected: using NoConstType_ = std::conditional_t<Volatile_, volatile NoCvType_, NoCvType_>;
public: using Type = std::conditional_t<Const_, const NoConstType_, NoConstType_>;
};
}
template <typename From, typename To> using MoveQualifiers
= typename detail_::MoveQualifiersHelper<From, To>::Type;
namespace detail_
{
template <typename T, typename Fallback = void> struct FallbackIfNoTypeDeclaredHelper { using Type = Fallback; };
template <typename T, typename Fallback> requires requires { typename T::Type; }
struct FallbackIfNoTypeDeclaredHelper<T, Fallback> { using Type = typename T::Type; };
template <typename T, typename Fallback> requires requires {typename T::type;}
struct FallbackIfNoTypeDeclaredHelper<T, Fallback> { using Type = typename T::type; };
}
template <typename T, typename Fallback = void> using FallbackIfNoTypeDeclared
= typename detail_::FallbackIfNoTypeDeclaredHelper<T, Fallback>::Type;
}

View File

@@ -1,24 +0,0 @@
# pragma once
# include <boost/functional/hash.hpp>
# include <biu/common.hpp>
namespace biu
{
inline void unused(auto&&...) {}
inline std::size_t hash(auto&&... objs)
{
std::size_t result = 0;
(boost::hash_combine(result, objs), ...);
return result;
}
template <typename String> inline constexpr bool CaseInsensitiveStringLessComparator::operator()
(const String& s1, const String& s2) const
{
return std::lexicographical_compare
(
s1.begin(), s1.end(), s2.begin(), s2.end(),
[](char c1, char c2){return std::tolower(c1) < std::tolower(c2);}
);
}
}

View File

@@ -1,47 +0,0 @@
# pragma once
# include <concepts>
# include <tuple>
# include <type_traits>
# include <complex>
namespace biu
{
template <typename T> concept DecayedType = std::same_as<std::decay_t<T>, T>;
namespace detail_::specialization_of_detail_
{
template <typename Tuple> struct DropFirstMemberOfTupleHelper;
template <typename First, typename... Others> struct DropFirstMemberOfTupleHelper<std::tuple<First, Others...>>
{using Type = std::tuple<Others...>;};
template <typename ProvidedArgs, typename ActualArgs> consteval bool check_provided_args();
template <typename Class, template <typename...> typename Template> struct SpecializationOfHelper
{template <typename... ProvidedArgs> consteval static bool check_provided_args();};
template <template <typename...> typename Template, typename... ActualArgs>
struct SpecializationOfHelper<Template<ActualArgs...>, Template>
{template <typename... ProvidedArgs> consteval static bool check_provided_args();};
}
template <typename Class, template <typename...> typename Template, typename... ProvidedArgs>
concept SpecializationOf
= detail_::specialization_of_detail_::SpecializationOfHelper<std::decay_t<Class>, Template>
::template check_provided_args<ProvidedArgs...>();
template <typename T> concept CompletedType = sizeof(T) == sizeof(T);
template <typename From, typename To> concept ImplicitlyConvertibleTo = std::is_convertible<From, To>::value;
template <typename To, typename From> concept ImplicitlyConvertibleFrom = std::is_convertible<From, To>::value;
template <typename From, typename To> concept ExplicitlyConvertibleTo = std::is_constructible<To, From>::value;
template <typename To, typename From> concept ExplicitlyConvertibleFrom = std::is_constructible<To, From>::value;
template <typename From, typename To> concept ConvertibleTo
= ImplicitlyConvertibleTo<From, To> || ExplicitlyConvertibleTo<From, To>;
template <typename From, typename To> concept ConvertibleFrom = ConvertibleTo<From, To>;
template <typename Function, auto... Args> concept ConstevalInvokable
= requires() {typename std::type_identity_t<int[(Function()(Args...), 1)]>;};
template <typename T> concept Enumerable = std::is_enum_v<T>;
template <typename Function, typename Result, typename... Args> concept InvocableWithResult
= std::is_invocable_r_v<Result, Function, Args...>;
template <typename T> concept Arithmetic = std::is_arithmetic<T>::value || SpecializationOf<T, std::complex>;
}

View File

@@ -1,34 +0,0 @@
# pragma once
# include <tuple>
# include <biu/concepts.hpp>
namespace biu
{
template <typename ProvidedArgs, typename ActualArgs> consteval bool
detail_::specialization_of_detail_::check_provided_args()
{
if constexpr (std::tuple_size_v<ProvidedArgs> == 0)
return true;
else if constexpr (std::tuple_size_v<ActualArgs> == 0)
return false;
else if constexpr
(std::same_as<std::tuple_element_t<0, ProvidedArgs>, std::tuple_element_t<0, ActualArgs>>)
return check_provided_args
<
typename DropFirstMemberOfTupleHelper<ProvidedArgs>::Type,
typename DropFirstMemberOfTupleHelper<ActualArgs>::Type
>();
else
return false;
}
template <typename Class, template <typename...> typename Template> template <typename... ProvidedArgs> consteval
bool detail_::specialization_of_detail_::SpecializationOfHelper<Class, Template>::check_provided_args()
{ return false; }
template <template <typename...> typename Template, typename... ActualArgs> template <typename... ProvidedArgs>
consteval bool detail_::specialization_of_detail_::SpecializationOfHelper
<Template<ActualArgs...>, Template>::check_provided_args()
{
return specialization_of_detail_::check_provided_args
<std::tuple<ProvidedArgs...>, std::tuple<ActualArgs...>>();
}
}

View File

@@ -1,54 +0,0 @@
# pragma once
# include <vector>
# include <span>
# include <Eigen/Dense>
# include <biu/concepts.hpp>
namespace biu
{
namespace detail_::eigen
{
// user-specified size of destination container: dynamic, unspecified(use default), or fixed
constexpr std::size_t dynamicSize = std::dynamic_extent, unspecifiedSize = std::dynamic_extent - 1;
static_assert(std::dynamic_extent == std::numeric_limits<std::size_t>::max());
// supported types of standard containers
template <typename T, typename Scalar> struct SpecializationOfArrayHelper : std::false_type {};
template <typename Scalar, std::size_t N>
struct SpecializationOfArrayHelper<std::array<Scalar, N>, Scalar> : std::true_type {};
template <typename Scalar, std::size_t N>
struct SpecializationOfArrayHelper<std::array<Scalar, N>, void> : std::true_type {};
template <typename T, typename Scalar = void> concept SpecializationOfArray =
SpecializationOfArrayHelper<T, Scalar>::value;
template <typename T, typename Scalar> concept StandardContainer =
SpecializationOf<T, std::vector, Scalar> || SpecializationOfArray<T, Scalar>;
// helper operator| to specify the size of the destination container
// usage: some_value | toEigen<Row, Col>
template <std::size_t Row, std::size_t Col> struct ToEigenHelper {};
template <std::size_t Row = unspecifiedSize, std::size_t Col = unspecifiedSize>
inline constexpr ToEigenHelper<Row, Col> toEigen;
// convert 1D standard container to Eigen::Vector
// if no size is specified, convert std::vector to dynamic-size Eigen::Vector,
// std::array to fixed-size Eigen::Vector;
// if size is std::dynamic_extent, always convert to dynamic-size Eigen::Vector
// if size is specified as a number, convert to fixed-size Eigen::Vector if specified size equals the size of the
// input, otherwise throw an error
template <template <int N> typename Callback, std::size_t ToSize> auto deduce_eigen_size(auto&& container);
template <Arithmetic T, StandardContainer<T> From, std::size_t ToSize> auto operator|
(const From&, const ToEigenHelper<ToSize, unspecifiedSize>&);
// convert 2D standard container to Eigen::Matrix
// the same rules as above apply
// besides, all rows must have the same size, otherwise throw an error
template
<
Arithmetic T, StandardContainer<T> FromPerRow, StandardContainer<FromPerRow> From,
std::size_t ToRow, std::size_t ToCol
>
auto operator|(const From&, const ToEigenHelper<ToRow, ToCol>&);
// TODO: implement fromEigen
}
inline namespace eigen { using detail_::eigen::toEigen; using detail_::eigen::operator|; }
}

View File

@@ -1,29 +0,0 @@
# pragma once
# include <biu/eigen.hpp>
// TODO: fix biu::logger
// # include <biu/logger.hpp>
# include <range/v3/view.hpp>
namespace biu
{
namespace detail_::eigen
{
template <template <int N> typename Callback, std::size_t ToSize> auto deduce_eigen_size(auto&& from)
{
if constexpr (ToSize == dynamicSize)
return Callback<Eigen::Dynamic>()(from.data(), from.size());
else if constexpr (ToSize == unspecifiedSize)
if constexpr (SpecializationOfArray<decltype(from)>)
return Callback<from.size()>()(from.data());
else
return Callback<Eigen::Dynamic>()(from.data(), from.size());
else
if (from.size() != ToSize)
// TODO: use biu::logger
throw std::invalid_argument("biu::toEigen: size mismatch");
else
return Callback<ToSize>()(from.data());
}
// TODO: implement 2D case
}
}

View File

@@ -1,72 +0,0 @@
# pragma once
# include <variant>
# include <experimental/memory>
# include <fmt/ostream.h>
# include <biu/string.hpp>
# include <biu/concepts.hpp>
namespace biu
{
template <typename T, typename Char = char> concept Formattable = fmt::is_formattable<T, Char>::value;
namespace detail_
{
template <typename Char, Char... c> struct FormatLiteralHelper : protected BasicStaticString<Char, c...>
{template <typename... Param> std::basic_string<Char> operator()(Param&&... param) const;};
}
namespace literals
{template <typename Char, Char... c> consteval detail_::FormatLiteralHelper<Char, c...> operator""_f();}
namespace detail_
{
template <typename T> concept OptionalWrap
= SpecializationOf<T, std::optional> || SpecializationOf<T, std::shared_ptr>
|| SpecializationOf<T, std::weak_ptr> || SpecializationOf<T, std::unique_ptr>
|| SpecializationOf<T, std::experimental::observer_ptr>;
template <typename Wrap> struct UnderlyingTypeOfOptionalWrap;
template <typename Wrap> requires requires() {typename Wrap::value_type;}
struct UnderlyingTypeOfOptionalWrap<Wrap>
{using Type = std::remove_cvref_t<typename Wrap::value_type>;};
template <typename Wrap> requires requires() {typename Wrap::element_type;}
struct UnderlyingTypeOfOptionalWrap<Wrap>
{using Type = std::remove_cvref_t<typename Wrap::element_type>;};
template <typename T> struct FormatterReuseProxy
{
constexpr auto parse(fmt::format_parse_context& ctx)
-> std::invoke_result_t<decltype(&fmt::format_parse_context::begin), fmt::format_parse_context>;
};
template <typename T>
requires (!SpecializationOf<T, std::weak_ptr> && std::default_initializable<fmt::formatter<T>>)
struct FormatterReuseProxy<T> : fmt::formatter<T> {};
}
}
namespace std
{
template <typename Char, typename... Ts> requires (sizeof...(Ts) > 0) basic_ostream<Char>& operator<<
(basic_ostream<Char>& os, const variant<Ts...>& value);
}
namespace fmt
{
using namespace biu::stream_operators;
template <typename Char, biu::detail_::OptionalWrap Wrap> struct formatter<Wrap, Char>
: biu::detail_::FormatterReuseProxy<typename biu::detail_::UnderlyingTypeOfOptionalWrap<Wrap>::Type>
{
template <typename FormatContext> auto format(const Wrap& wrap, FormatContext& ctx)
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>;
};
template <typename Char, biu::Enumerable T> struct formatter<T, Char>
{
bool full = false;
constexpr auto parse(fmt::format_parse_context& ctx)
-> std::invoke_result_t<decltype(&fmt::format_parse_context::begin), fmt::format_parse_context>;
template <typename FormatContext> auto format(const T& value, FormatContext& ctx)
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>;
};
template <typename Char, typename... Ts> struct formatter<std::variant<Ts...>, Char>
: basic_ostream_formatter<Char> {};
}

View File

@@ -1,122 +0,0 @@
# pragma once
# include <nameof.hpp>
# include <biu/format.hpp>
namespace biu
{
template <typename Char, Char... c> template <typename... Param>
std::basic_string<Char> detail_::FormatLiteralHelper<Char, c...>::operator() (Param&&... param) const
{return fmt::format(BasicStaticString<Char, c...>::StringView, std::forward<Param>(param)...);}
template <typename Char, Char... c> consteval
detail_::FormatLiteralHelper<Char, c...> literals::operator""_f()
{return {};}
template <typename T> constexpr
auto detail_::FormatterReuseProxy<T>::parse(fmt::format_parse_context& ctx)
-> std::invoke_result_t<decltype(&fmt::format_parse_context::begin), fmt::format_parse_context>
{
if (ctx.begin() != ctx.end() && *ctx.begin() != '}')
throw fmt::format_error
(
"{} do not support to be format, so the wrapper should not have any format syntax."_f
(nameof::nameof_full_type<T>())
);
return ctx.begin();
}
}
namespace std
{
template <typename Char, typename... Ts> requires (sizeof...(Ts) > 0)
basic_ostream<Char>& operator<<(basic_ostream<Char>& os, const variant<Ts...>& value)
{
using namespace biu::literals;
auto try_print = [&]<typename T>
{
if (holds_alternative<T>(value))
{
if constexpr (biu::Formattable<T, Char>)
os << "({}: {})"_f(nameof::nameof_full_type<T>(), get<T>(value));
else
os << "({}: {})"_f(nameof::nameof_full_type<T>(), "non-null unformattable value");
}
};
(try_print.template operator()<Ts>(), ...);
return os;
}
}
namespace fmt
{
template <typename Char, biu::detail_::OptionalWrap Wrap> template <typename FormatContext>
auto formatter<Wrap, Char>::format(const Wrap& wrap, FormatContext& ctx)
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>
{
using namespace biu::literals;
using namespace biu::stream_operators;
using value_t = biu::detail_::UnderlyingTypeOfOptionalWrap<Wrap>::Type;
auto format_value_type = [&, this](const value_t& value)
{
if constexpr (!biu::Formattable<value_t, Char>)
return format_to(ctx.out(), "non-null unformattable value");
else if constexpr (std::default_initializable<formatter<value_t>>)
biu::detail_::FormatterReuseProxy<value_t>::format(value, ctx);
else
format_to(ctx.out(), "{}", value);
};
format_to(ctx.out(), "(");
if constexpr (biu::SpecializationOf<Wrap, std::optional>)
{
if (wrap)
format_value_type(*wrap);
else
format_to(ctx.out(), "null");
}
else if constexpr (biu::SpecializationOf<Wrap, std::weak_ptr>)
{
if (auto shared = wrap.lock())
{
format_to(ctx.out(), "{} ", ptr(shared.get()));
format_value_type(*shared);
}
else
format_to(ctx.out(), "null");
}
else
{
if (wrap)
{
format_to(ctx.out(), "{} ", ptr(wrap.get()));
format_value_type(*wrap);
}
else
format_to(ctx.out(), "null");
}
return format_to(ctx.out(), ")");
}
template <typename Char, biu::Enumerable T> constexpr
auto formatter<T, Char>::parse(format_parse_context& ctx)
-> std::invoke_result_t<decltype(&format_parse_context::begin), format_parse_context>
{
auto it = ctx.begin();
if (it != ctx.end() && *it == 'f')
{
full = true;
it++;
}
if (it != ctx.end() && *it != '}')
throw format_error{"syntax error."};
return it;
}
template <typename Char, biu::Enumerable T> template <typename FormatContext>
auto formatter<T, Char>::format(const T& value, FormatContext& ctx)
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>
{
if (full)
return format_to(ctx.out(), "{}::{}", nameof::nameof_type<T>(), nameof::nameof_enum(value));
else
return format_to(ctx.out(), "{}", nameof::nameof_enum(value));
}
}

View File

@@ -1,103 +0,0 @@
# pragma once
# include <map>
# include <boost/stacktrace.hpp>
# include <biu/atomic/nolog.hpp>
namespace biu
{
class Logger
{
// All the member function corresponding to stacktrace should be inlined
// All the public function (including public function of member class) should be thread safe.
public: Logger() = delete;
// Setup output stream and log level in a thread-safe way
public: enum class Level
{
None,
Error,
Access,
Info,
Debug
};
protected: struct LoggerConfigType_
{
std::experimental::observer_ptr<std::ostream> Stream;
std::shared_ptr<std::ostream> StreamStorage;
Logger::Level Level;
};
protected: static Atomic<std::optional<LoggerConfigType_>, false> LoggerConfig_;
public: static void init(std::experimental::observer_ptr<std::ostream> stream, Level level);
public: static void init(std::shared_ptr<std::ostream> stream, Level level);
// Send a telegram message if token and chat id are set, all the functions are thread-safe
protected: static Atomic<std::optional<std::pair<std::string, std::string>>, false> TelegramConfig_;
public: static void telegram_init(const std::string& token, const std::string& chat_id);
public: static void telegram_notify(const std::string& message);
public: static void telegram_notify_async(const std::string& message);
// Monitor the lifetime of an object
// usage: struct my_class : protected Logger::ObjectMonitor<my_class> {}
public: template <typename T> class ObjectMonitor
{
protected: const std::chrono::time_point<std::chrono::steady_clock> CreateTime_;
// call log<Debug>("create {type} at {address}.");
protected: [[gnu::always_inline]] ObjectMonitor();
// call log<Debug>("destroy {type} at {address} after {duration} ms.");
protected: [[gnu::always_inline]] virtual ~ObjectMonitor();
};
template <typename T> friend class ObjectMonitor;
// List of objects that is being monitored by ObjectMonitor, {address, type}
protected: static Atomic<std::multimap<const void*, std::string_view>, false> Objects_;
public: template <typename FinalException> class Exception : public std::exception
{
protected: const std::string Message_;
protected: const boost::stacktrace::stacktrace Stacktrace_;
public: explicit Exception(const std::string& message);
public: const char* what() const noexcept final {return Message_.c_str();}
};
// Monitor the start and end of a function, as well as corresponding thread.
// This object should be construct at the beginning of the function, and should never be passed to another
// function or thread.
public: class Guard
{
protected: thread_local static unsigned Indent_;
protected: const std::chrono::time_point<std::chrono::steady_clock> StartTime_;
// if sizeof...(Param) > 0, call log<Debug>("begin function with {arguments}.");
// else call log<Debug>("begin function.");
public: template <typename... Param> [[gnu::always_inline]] explicit Guard(Param&&... param);
// call log<Debug>("end function after {duration} ms.")
public: [[gnu::always_inline]] virtual ~Guard();
// call log<Debug>("reached after {duration} ms.")
public: [[gnu::always_inline]] void operator()() const;
// call log<Debug>("return {return} after {duration} ms.")
public: template <typename T> [[gnu::always_inline]] T rtn(T&& value) const;
// print the following message if LoggerConfig_ is set and the level is higher than the level of the
// LoggerConfig_
// [ {time} {thread} {indent} {filename}:{line} {function_name} ] {message}
public: template <Level L> [[gnu::always_inline]] void log(const std::string& message) const;
public: template <typename FinalException> [[gnu::always_inline]] void print_exception
(
const std::string& type, const std::string& message, const boost::stacktrace::stacktrace& stacktrace,
CalledBy<Exception<FinalException>>
) const;
};
friend class Guard;
// list of threads which is being monitored by Guard and number of Guard created in this thread so far
protected: static Atomic<std::map<std::size_t, std::size_t>, false> Threads_;
};
}

View File

@@ -1,143 +0,0 @@
# pragma once
# define BOOST_STACKTRACE_USE_BACKTRACE
# include <fmt/chrono.h>
# include <biu/logger.hpp>
# include <biu/common.hpp>
# include <biu/format.hpp>
namespace biu
{
template <typename T> Logger::ObjectMonitor<T>::ObjectMonitor()
: CreateTime_{std::chrono::steady_clock::now()}
{
Guard guard;
guard.log<Level::Debug>("create {} at {}."_f(nameof::nameof_full_type<T>(), fmt::ptr(this)));
auto&& lock = Objects_.lock();
lock->emplace(this, nameof::nameof_full_type<T>());
}
template <typename T> Logger::ObjectMonitor<T>::~ObjectMonitor()
{
Guard guard;
guard.log<Level::Debug>("destroy {} at {} after {} ms."_f
(
nameof::nameof_full_type<T>(), fmt::ptr(this),
std::chrono::duration_cast<std::chrono::milliseconds>
(std::chrono::steady_clock::now() - CreateTime_).count()
));
auto&& lock = Objects_.lock();
auto range = lock->equal_range(this);
for (auto it = range.first; it != range.second; it++)
if (it->second == nameof::nameof_full_type<T>())
{
lock->erase(it);
return;
}
guard.log<Level::Error>
("{} {} not found in Logger::Objects."_f(fmt::ptr(this), nameof::nameof_full_type<T>()));
}
template <typename FinalException> Logger::Exception<FinalException>::Exception(const std::string& message)
{
Logger::Guard log{message};
log.print_exception(nameof::nameof_full_type<FinalException>(), message, Stacktrace_);
}
template <typename... Param> inline Logger::Guard::Guard(Param&&... param)
: StartTime_{std::chrono::steady_clock::now()}
{
Indent_++;
auto&& lock = Threads_.lock();
auto thread_id = std::hash<std::thread::id>{}(std::this_thread::get_id());
if (lock->contains(thread_id))
lock.value()[thread_id]++;
else
lock->emplace(thread_id, 1);
if constexpr (sizeof...(Param) > 0)
{
std::stringstream ss;
std::vector<std::string> params = {"{}"_f(std::forward<Param>(param))...};
ss << "begin function with {";
for (auto& param : params)
ss << param << ", ";
ss.seekp(-2, ss.cur);
ss << "}.";
log<Level::Debug>(ss.str());
}
else
log<Level::Debug>("begin function.");
}
inline Logger::Guard::~Guard()
{
log<Level::Debug>("end function after {} ms."_f(std::chrono::duration_cast<std::chrono::milliseconds>
(std::chrono::steady_clock::now() - StartTime_).count()));
Indent_--;
auto&& lock = Threads_.lock();
auto thread_id = std::hash<std::thread::id>{}(std::this_thread::get_id());
if (lock->contains(thread_id))
{
lock.value()[thread_id]--;
if (lock.value()[thread_id] == 0)
lock->erase(thread_id);
}
else [[unlikely]]
log<Level::Debug>("{:08x} not found in Logger::Threads."_f
(std::hash<std::thread::id>{}(std::this_thread::get_id()) % std::numeric_limits<std::uint64_t>::max()));
}
inline void Logger::Guard::operator()() const
{
log<Level::Debug>("reached after {} ms."_f
(
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - StartTime_).count()
));
}
template <typename T> inline T Logger::Guard::rtn(T&& value) const
{
log<Level::Debug>("return {} after {} ms."_f
(
std::forward<T>(value),
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - StartTime_).count()
));
return std::forward<T>(value);
}
template <Logger::Level L> inline void Logger::Guard::log(const std::string& message) const
{
if (auto&& lock = LoggerConfig_.lock(); *lock && lock.value()->Level >= L)
{
static_assert(std::same_as<std::size_t, std::uint64_t>);
auto time = std::chrono::system_clock::now();
boost::stacktrace::stacktrace stack;
*lock.value()->Stream << "[ {:%Y-%m-%d %H:%M:%S}:{:03} {:08x} {:04} {}:{} {} ] {}\n"_f
(
time,
std::chrono::time_point_cast<std::chrono::milliseconds>(time).time_since_epoch().count() % 1000,
std::hash<std::thread::id>{}(std::this_thread::get_id())
% std::numeric_limits<std::uint64_t>::max(),
Indent_,
stack[0].source_file().empty() ? "??"s : stack[0].source_file(),
stack[0].source_line() == 0 ? "??"s : "{}"_f(stack[0].source_line()),
stack[0].name(),
message
) << std::flush;
}
}
template <typename FinalException> inline void Logger::Guard::print_exception
(
const std::string& type, const std::string& message, const boost::stacktrace::stacktrace& stacktrace,
CalledBy<Exception<FinalException>>
) const
{
log<Level::Error>("{}: {}"_f(type, message));
if (auto&& lock = LoggerConfig_.lock(); *lock && lock.value()->Level >= Logger::Level::Error)
{
static_assert(std::same_as<std::size_t, std::uint64_t>);
for (auto frame : stacktrace)
*lock.value()->Stream << "\tfrom {}:{} {}\n"_f
(
frame.source_file().empty() ? "??"s : frame.source_file(),
frame.source_line() == 0 ? "??"s : "{}"_f(frame.source_line()),
frame.name()
);
*lock.value()->Stream << std::flush;
}
}
}

View File

@@ -1,18 +0,0 @@
# pragma once
# include <memory>
# include <type_traits>
namespace biu
{
// store a reference to an lvalue, or a value (instead of a reference) copy or moved from an rvalue
template <typename T> class SmartRef
{
protected: std::unique_ptr<T> Ptr_;
protected: T& Ref_;
public: SmartRef(T& val);
public: template <typename... Us> requires (std::is_constructible_v<T, Us...>) SmartRef(Us&&... val);
public: T& operator*();
public: T* operator->();
};
}

View File

@@ -1,13 +0,0 @@
# pragma once
# include <utility>
# include <biu/smartref.hpp>
namespace biu
{
template <typename T> inline SmartRef<T>::SmartRef(T& val) : Ref_(val) {}
template <typename T> template <typename... Us> requires (std::is_constructible_v<T, Us...>)
inline SmartRef<T>::SmartRef(Us&&... val)
: Ptr_(std::make_unique<T>(std::forward<Us>(val)...)), Ref_(*Ptr_) {}
template <typename T> inline T& SmartRef<T>::operator*() {return Ref_;}
template <typename T> inline T* SmartRef<T>::operator->() {return &Ref_;}
}

View File

@@ -1,111 +0,0 @@
# pragma once
# include <regex>
# include <array>
# include <string>
# include <string_view>
# include <iostream>
# include <concurrencpp/concurrencpp.h>
# include <biu/concepts.hpp>
# include <biu/smartref.hpp>
namespace biu
{
// Store a string in a static member of a class; or, use a class to represent a string.
template <DecayedType Char, Char... c> struct BasicStaticString
{
static constexpr std::array<Char, sizeof...(c)> Array{c...};
static constexpr std::basic_string_view<Char> StringView{Array.data(), sizeof...(c)};
};
template <char... c> using StaticString = BasicStaticString<char, c...>;
inline namespace stream_operators
{
template <typename Char, Char... c>
std::basic_ostream<Char>& operator<<(std::basic_ostream<Char>& os, BasicStaticString<Char, c...>);
}
inline namespace literals
{ template <typename Char, Char... c> consteval BasicStaticString<Char, c...> operator""_ss(); }
namespace detail_
{
template <typename C, typename T> struct SpecializationOfBasicStaticStringHelper : std::false_type {};
template <typename C, C... c>
struct SpecializationOfBasicStaticStringHelper<C, BasicStaticString<C, c...>> : std::true_type {};
template <typename C, C... c>
struct SpecializationOfBasicStaticStringHelper<void, BasicStaticString<C, c...>> : std::true_type {};
template <typename T, typename C> concept SpecializationOfBasicStaticString
= SpecializationOfBasicStaticStringHelper<std::decay_t<C>, std::decay_t<T>>::value;
}
template <typename T, typename C = void> concept SpecializationOfBasicStaticString
= detail_::SpecializationOfBasicStaticString<T, C>
&& detail_::SpecializationOfBasicStaticString<T, void>;
template <typename T> concept SpecializationOfStaticString = SpecializationOfBasicStaticString<T, char>;
// Store a string in a fixed-size array
template <DecayedType Char, std::size_t N> struct BasicFixedString
{
Char Data[N];
constexpr static const std::size_t Size = N - 1;
constexpr BasicFixedString(const Char (&str)[N]);
};
template <std::size_t N> using FixedString = BasicFixedString<char, N>;
inline namespace stream_operators
{
template <typename Char, std::size_t N> std::basic_ostream<Char>& operator<<
(std::basic_ostream<Char>& os, const BasicFixedString<Char, N>& str);
}
inline namespace literals { template <BasicFixedString FS> constexpr decltype(FS) operator""_fs(); }
namespace detail_
{
template <typename C, typename T> struct SpecializationOfBasicFixedStringHelper : std::false_type {};
template <typename C, std::size_t N>
struct SpecializationOfBasicFixedStringHelper<C, BasicFixedString<C, N>> : std::true_type {};
template <typename C, std::size_t N>
struct SpecializationOfBasicFixedStringHelper<void, BasicFixedString<C, N>> : std::true_type {};
template <typename T, typename C> concept SpecializationOfBasicFixedString
= SpecializationOfBasicFixedStringHelper<std::decay_t<C>, std::decay_t<T>>::value;
}
template <typename T, typename C = void> concept SpecializationOfBasicFixedString
= detail_::SpecializationOfBasicFixedString<T, C>
&& detail_::SpecializationOfBasicFixedString<T, void>;
template <typename T> concept SpecializationOfFixedString = SpecializationOfBasicFixedString<T, char>;
// Store a string with at most N characters
template <DecayedType Char, std::size_t N> struct BasicVariableString
{
Char Data[N];
std::size_t Size;
constexpr static const std::size_t MaxSize = N - 1;
template <std::size_t M> requires (M<=N) constexpr BasicVariableString(const Char (&str)[M]);
};
template <std::size_t N> using VariableString = BasicVariableString<char, N>;
inline namespace stream_operators
{
template <typename Char, std::size_t N> std::basic_ostream<Char>& operator<<
(std::basic_ostream<Char>& os, const BasicVariableString<Char, N>& str);
}
namespace detail_
{
template <typename C, typename T> struct SpecializationOfBasicVariableStringHelper : std::false_type {};
template <typename C, std::size_t N>
struct SpecializationOfBasicVariableStringHelper<C, BasicVariableString<C, N>> : std::true_type {};
template <typename C, std::size_t N>
struct SpecializationOfBasicVariableStringHelper<void, BasicVariableString<C, N>> : std::true_type {};
template <typename T, typename C> concept SpecializationOfBasicVariableString
= SpecializationOfBasicVariableStringHelper<std::decay_t<C>, std::decay_t<T>>::value;
}
template <typename T, typename C = void> concept SpecializationOfBasicVariableString
= detail_::SpecializationOfBasicVariableString<T, C>
&& detail_::SpecializationOfBasicVariableString<T, void>;
template <typename T> concept SpecializationOfVariableString = SpecializationOfBasicVariableString<T, char>;
namespace string
{
// Find specific content in a string. Return unmatched content before the match and the match result every
// time. If match reached the end, the second returned value will be std::sregex_iterator().
concurrencpp::generator<std::pair<std::string_view, std::sregex_iterator>> find
(SmartRef<const std::string> data, SmartRef<const std::regex> regex);
// Use a regex to find all matches and replace them with a callback function
std::string replace
(const std::string& data, const std::regex& regex, std::function<std::string(const std::smatch&)> function);
}
}

View File

@@ -1,30 +0,0 @@
# pragma once
# include <biu/string.hpp>
namespace biu
{
template <typename Char, Char... c> inline std::basic_ostream<Char>& stream_operators::operator<<
(std::basic_ostream<Char>& os, BasicStaticString<Char, c...>)
{ return os << std::basic_string_view{c...}; }
template <typename Char, Char... c> consteval BasicStaticString<Char, c...> literals::operator""_ss()
{ return {}; }
template <DecayedType Char, std::size_t N> constexpr
BasicFixedString<Char, N>::BasicFixedString(const Char (&str)[N])
{ std::copy_n(str, N, Data); }
template <typename Char, std::size_t N> std::basic_ostream<Char>& stream_operators::operator<<
(std::basic_ostream<Char>& os, const BasicFixedString<Char, N>& str)
{ return os << std::basic_string_view<Char>(str.Data, str.Size); }
template <BasicFixedString FS> constexpr decltype(FS) literals::operator""_fs()
{ return FS; }
template <DecayedType Char, std::size_t N> template <std::size_t M> requires (M<=N) constexpr
BasicVariableString<Char, N>::BasicVariableString(const Char (&str)[M]) : Size(M)
{
std::fill(Data, Data + N, '\0');
std::copy_n(str, M, Data);
}
template <typename Char, std::size_t N> std::basic_ostream<Char>& stream_operators::operator<<
(std::basic_ostream<Char>& os, const BasicVariableString<Char, N>& str)
{ return os << std::basic_string_view<Char>(str.Data, str.Size); }
}

View File

@@ -1,14 +0,0 @@
# include <future>
# include <utility>
# include <biu.hpp>
namespace biu
{
std::regex literals::operator""_re(const char* str, std::size_t len)
{ return std::regex{str, len}; }
void block_forever()
{
std::promise<void>().get_future().wait();
std::unreachable();
}
}

View File

@@ -1,36 +0,0 @@
# include <tgbot/tgbot.h>
# include <biu.hpp>
namespace biu
{
Atomic<std::optional<typename Logger::LoggerConfigType_>, false> Logger::LoggerConfig_;
void Logger::init(std::experimental::observer_ptr<std::ostream> stream, Level level)
{
auto&& lock = LoggerConfig_.lock();
lock->emplace(stream, nullptr, level);
}
void Logger::init(std::shared_ptr<std::ostream> stream, Level level)
{
auto&& lock = LoggerConfig_.lock();
lock->emplace(std::experimental::make_observer(stream.get()), stream, level);
}
Atomic<std::optional<std::pair<std::string, std::string>>, false> Logger::TelegramConfig_;
void Logger::telegram_init(const std::string& token, const std::string& chat_id)
{TelegramConfig_ = std::make_pair(token, chat_id);}
void Logger::telegram_notify(const std::string& message)
{
if (auto&& lock = TelegramConfig_.lock(); *lock)
{
TgBot::Bot bot{lock.value()->first};
bot.getApi().sendMessage(lock.value()->first, message);
}
}
void Logger::telegram_notify_async(const std::string& message)
{std::thread{Logger::telegram_notify, message}.detach();}
Atomic<std::multimap<const void*, std::string_view>, false> Logger::Objects_;
thread_local unsigned Logger::Guard::Indent_ = 0;
Atomic<std::map<std::size_t, std::size_t>, false> Logger::Threads_;
}

View File

@@ -1,53 +0,0 @@
# include <fmt/chrono.h>
# include <biu.hpp>
namespace biu
{
concurrencpp::generator<std::pair<std::string_view, std::sregex_iterator>> string::find
(SmartRef<const std::string> data, SmartRef<const std::regex> regex)
{
Logger::Guard log;
std::string::const_iterator unmatched_prefix_begin = data->cbegin(), unmatched_prefix_end;
std::sregex_iterator regit;
while (true)
{
if (regit == std::sregex_iterator{})
regit = std::sregex_iterator{data->begin(), data->end(), *regex};
else
regit++;
if (regit == std::sregex_iterator{})
{
unmatched_prefix_end = data->cend();
log.log<Logger::Level::Debug>("distance: {}"_f(std::distance(unmatched_prefix_begin, unmatched_prefix_end)));
}
else
unmatched_prefix_end = (*regit)[0].first;
co_yield
{
std::string_view
{
&*unmatched_prefix_begin,
static_cast<std::size_t>(std::distance(unmatched_prefix_begin, unmatched_prefix_end))
},
regit
};
if (regit == std::sregex_iterator{})
break;
unmatched_prefix_begin = (*regit)[0].second;
}
}
std::string string::replace
(const std::string& data, const std::regex& regex, std::function<std::string(const std::smatch&)> function)
{
Logger::Guard log;
std::string result;
for (auto matched : find(data, regex))
{
result.append(matched.first);
if (matched.second != std::sregex_iterator{})
result.append(function(*matched.second));
}
return result;
}
}

View File

@@ -1,11 +0,0 @@
{ stdenv, src }: stdenv.mkDerivation
{
name = "blurred-wallpaper";
inherit src;
phases = [ "installPhase" ];
installPhase =
''
mkdir -p $out/share/plasma/wallpapers/a2n.blur
cp -r $src/* $out/share/plasma/wallpapers/a2n.blur
'';
}

View File

@@ -0,0 +1,18 @@
{ lib, stdenv, fetchFromGitHub, fetchurl, cmake }: stdenv.mkDerivation rec
{
pname = "chromiumos-touch-keyboard";
version = "1.4.1";
src = fetchFromGitHub
{
owner = "CHN-beta";
repo = "chromiumos_touch_keyboard";
rev = "32b72240ccac751a1b983152f65aa5b19503ffcf";
sha256 = "eFesDSBS2VzTOVfepgXYGynWvkrCSdCV9C/gcG/Ocbg=";
};
cmakeFlags = [ "-DCMAKE_CXX_FLAGS=-Wno-error=stringop-truncation" ];
nativeBuildInputs = [ cmake ];
postInstall =
''
cp $out/etc/touch_keyboard/layouts/YB1-X9x-pc105.csv $out/etc/touch_keyboard/layout.csv
'';
}

View File

@@ -1,88 +1,48 @@
inputs: rec
{ lib, pkgs, topInputs }: with pkgs; rec
{
typora = inputs.pkgs.callPackage ./typora {};
vesta = inputs.pkgs.callPackage ./vesta {};
rsshub = inputs.pkgs.callPackage ./rsshub { src = inputs.topInputs.rsshub; };
misskey = inputs.pkgs.callPackage ./misskey { nodejs = inputs.pkgs.nodejs_21; src = inputs.topInputs.misskey; };
mk-meili-mgn = inputs.pkgs.callPackage ./mk-meili-mgn {};
vaspkit = inputs.pkgs.callPackage ./vaspkit { inherit (inputs.localLib) attrsToList; };
v-sim = inputs.pkgs.callPackage ./v-sim { src = inputs.topInputs.v-sim; };
concurrencpp = inputs.pkgs.callPackage ./concurrencpp { src = inputs.topInputs.concurrencpp; };
eigengdb = inputs.pkgs.python3Packages.callPackage ./eigengdb {};
nodesoup = inputs.pkgs.callPackage ./nodesoup { src = inputs.topInputs.nodesoup; };
matplotplusplus = inputs.pkgs.callPackage ./matplotplusplus
{ inherit nodesoup glad; src = inputs.topInputs.matplotplusplus; };
zpp-bits = inputs.pkgs.callPackage ./zpp-bits { src = inputs.topInputs.zpp-bits; };
eigen = inputs.pkgs.callPackage ./eigen { src = inputs.topInputs.eigen; };
nameof = inputs.pkgs.callPackage ./nameof { src = inputs.topInputs.nameof; };
pslist = inputs.pkgs.callPackage ./pslist {};
glad = inputs.pkgs.callPackage ./glad {};
chromiumos-touch-keyboard = inputs.pkgs.callPackage ./chromiumos-touch-keyboard {};
yoga-support = inputs.pkgs.callPackage ./yoga-support {};
tgbot-cpp = inputs.pkgs.callPackage ./tgbot-cpp { src = inputs.topInputs.tgbot-cpp; };
citation-style-language = inputs.pkgs.callPackage ./citation-style-language
{ src = inputs.topInputs.citation-style-language; };
mirism = inputs.pkgs.callPackage ./mirism
typora = callPackage ./typora {};
vesta = callPackage ./vesta {};
oneapi = callPackage ./oneapi {};
rsshub = callPackage ./rsshub { src = topInputs.rsshub; };
misskey = callPackage ./misskey { nodejs = nodejs_21; src = topInputs.misskey; };
mk-meili-mgn = callPackage ./mk-meili-mgn {};
# vasp = callPackage ./vasp
# {
# stdenv = pkgs.lmix-pkgs.intel21Stdenv;
# intel-mpi = pkgs.lmix-pkgs.intel-oneapi-mpi_2021_9_0;
# ifort = pkgs.lmix-pkgs.intel-oneapi-ifort_2021_9_0;
# };
vasp = callPackage ./vasp
{
openmp = llvmPackages.openmp;
openmpi = pkgs.openmpi.override { cudaSupport = false; };
};
vaspkit = callPackage ./vaspkit { attrsToList = (import ../lib lib).attrsToList; };
v-sim = callPackage ./v-sim { src = topInputs.v-sim; };
concurrencpp = callPackage ./concurrencpp { stdenv = gcc13Stdenv; src = topInputs.concurrencpp; };
eigengdb = python3Packages.callPackage ./eigengdb {};
nodesoup = callPackage ./nodesoup { src = topInputs.nodesoup; };
matplotplusplus = callPackage ./matplotplusplus { inherit nodesoup glad; src = topInputs.matplotplusplus; };
zpp-bits = callPackage ./zpp-bits { src = topInputs.zpp-bits; };
eigen = callPackage ./eigen { src = topInputs.eigen; };
nameof = callPackage ./nameof { src = topInputs.nameof; };
pslist = callPackage ./pslist {};
glad = callPackage ./glad {};
chromiumos-touch-keyboard = callPackage ./chromiumos-touch-keyboard {};
yoga-support = callPackage ./yoga-support {};
tgbot-cpp = callPackage ./tgbot-cpp { src = topInputs.tgbot-cpp; };
biu = callPackage ./biu { inherit concurrencpp tgbot-cpp nameof; stdenv = gcc13Stdenv; };
citation-style-language = callPackage ./citation-style-language { src = topInputs.citation-style-language; };
mirism = callPackage ./mirism
{
inherit cppcoro nameof tgbot-cpp date;
nghttp2 = inputs.pkgs.callPackage "${inputs.topInputs."nixpkgs-23.05"}/pkgs/development/libraries/nghttp2"
{ enableAsioLib = true; };
nghttp2 = nghttp2-2305.override { enableAsioLib = true; };
};
cppcoro = inputs.pkgs.callPackage ./cppcoro { src = inputs.topInputs.cppcoro; };
date = inputs.pkgs.callPackage ./date { src = inputs.topInputs.date; };
esbonio = inputs.pkgs.python3Packages.callPackage ./esbonio {};
pix2tex = inputs.pkgs.python3Packages.callPackage ./pix2tex {};
pyreadline3 = inputs.pkgs.python3Packages.callPackage ./pyreadline3 {};
torchdata = inputs.pkgs.python3Packages.callPackage ./torchdata {};
torchtext = inputs.pkgs.python3Packages.callPackage ./torchtext { inherit torchdata; };
win11os-kde = inputs.pkgs.callPackage ./win11os-kde { src = inputs.topInputs.win11os-kde; };
fluent-kde = inputs.pkgs.callPackage ./fluent-kde { src = inputs.topInputs.fluent-kde; };
blurred-wallpaper = inputs.pkgs.callPackage ./blurred-wallpaper { src = inputs.topInputs.blurred-wallpaper; };
slate = inputs.pkgs.callPackage ./slate { src = inputs.topInputs.slate; };
nvhpc = inputs.pkgs.callPackage ./nvhpc {};
lmod = inputs.pkgs.callPackage ./lmod { src = inputs.topInputs.lmod; };
vasp = rec
{
source = inputs.pkgs.callPackage ./vasp/source.nix {};
gnu = inputs.pkgs.callPackage ./vasp/gnu
{
inherit (inputs.pkgs.llvmPackages) openmp;
inherit wannier90 additionalCommands;
hdf5 = inputs.pkgs.hdf5.override { mpiSupport = true; fortranSupport = true; };
};
gnu-mkl = inputs.pkgs.callPackage ./vasp/gnu-mkl
{
inherit (inputs.pkgs.llvmPackages) openmp;
inherit wannier90 additionalCommands;
hdf5 = inputs.pkgs.hdf5.override { mpiSupport = true; fortranSupport = true; };
};
nvidia = inputs.pkgs.callPackage ./vasp/nvidia
{ inherit lmod nvhpc wannier90 additionalCommands; hdf5 = hdf5-nvhpc; };
intel = inputs.pkgs.callPackage ./vasp/intel
{ inherit lmod oneapi wannier90 additionalCommands; hdf5 = hdf5-oneapi; };
amd = inputs.pkgs.callPackage ./vasp/amd
{ inherit aocc aocl wannier90 additionalCommands; hdf5 = hdf5-aocc; openmpi = openmpi-aocc; gcc = gcc-pie; };
wannier90 = inputs.pkgs.callPackage
"${inputs.topInputs.nixpkgs-unstable}/pkgs/by-name/wa/wannier90/package.nix" {};
hdf5-nvhpc = inputs.pkgs.callPackage ./vasp/hdf5-nvhpc { inherit lmod nvhpc; inherit (inputs.pkgs.hdf5) src; };
hdf5-oneapi = inputs.pkgs.callPackage ./vasp/hdf5-oneapi { inherit lmod oneapi; inherit (inputs.pkgs.hdf5) src; };
hdf5-aocc = inputs.pkgs.callPackage ./vasp/hdf5-aocc
{ inherit (inputs.pkgs.hdf5) src; inherit aocc; openmpi = openmpi-aocc; gcc = gcc-pie; };
openmpi-aocc = inputs.pkgs.callPackage ./vasp/openmpi-aocc { inherit aocc; gcc = gcc-pie; };
gcc-pie = inputs.pkgs.wrapCC (inputs.pkgs.gcc.cc.overrideAttrs (prev:
{ configureFlags = prev.configureFlags ++ [ "--enable-default-pie" ];}));
additionalCommands = let uid = inputs.config.nixos.user.uid.gb; in
''[ "$(${inputs.pkgs.coreutils}/bin/id -u)" -eq ${builtins.toString uid} ] && exit 1'';
};
oneapi = inputs.pkgs.callPackage ./oneapi {};
mumax = inputs.pkgs.callPackage ./mumax { src = inputs.topInputs.mumax; };
aocc = inputs.pkgs.callPackage ./aocc {};
aocl = inputs.pkgs.callPackage ./aocl {};
kylin-virtual-keyboard = inputs.pkgs.libsForQt5.callPackage ./kylin-virtual-keyboard
{ src = inputs.topInputs.kylin-virtual-keyboard; };
biu = inputs.pkgs.callPackage ./biu { inherit nameof; };
fromYaml = content: builtins.fromJSON (builtins.readFile
(inputs.pkgs.runCommand "toJSON" {}
"${inputs.pkgs.remarshal}/bin/yaml2json ${builtins.toFile "content.yaml" content} $out"));
cppcoro = callPackage ./cppcoro { src = topInputs.cppcoro; };
date = callPackage ./date { src = topInputs.date; };
esbonio = python3Packages.callPackage ./esbonio {};
pix2tex = python3Packages.callPackage ./pix2tex {};
pyreadline3 = python3Packages.callPackage ./pyreadline3 {};
torchdata = python3Packages.callPackage ./torchdata {};
torchtext = python3Packages.callPackage ./torchtext { inherit torchdata; };
}

View File

@@ -1,22 +0,0 @@
{ lib, stdenv, src }: stdenv.mkDerivation
{
name = "fluent-kde";
inherit src;
installPhase =
''
mkdir -p $out/share/aurorae/themes
cp -r $src/aurorae/* $out/share/aurorae/themes
mkdir -p $out/share/color-schemes
cp -r $src/color-schemes/*.colors $out/share/color-schemes
mkdir -p $out/share/Kvantum
cp -r $src/Kvantum/Fluent* $out/share/Kvantum
mkdir -p $out/share/plasma/desktoptheme
cp -r $src/plasma/desktoptheme/* $out/share/plasma/desktoptheme
mkdir -p $out/share/plasma/layout-templates
cp -r $src/plasma/layout-templates/* $out/share/plasma/layout-templates
mkdir -p $out/share/plasma/look-and-feel
cp -r $src/plasma/look-and-feel/com.github.vinceliuice.Fluent* $out/share/plasma/look-and-feel
mkdir -p $out/share/wallpapers
cp -r $src/wallpaper/* $out/share/wallpapers
'';
}

View File

@@ -1,17 +0,0 @@
{
stdenv, src, wrapQtAppsHook,
qtbase, gsettings-qt, pkg-config, kwindowsystem, fcitx5-qt, qmake, wrapGAppsHook, glib
}: stdenv.mkDerivation
{
name = "kylin-virtual-keyboard";
inherit src;
buildInputs = [ qtbase gsettings-qt kwindowsystem fcitx5-qt ];
nativeBuildInputs = [ wrapQtAppsHook pkg-config qmake wrapGAppsHook glib ];
qmakeFlags = [ "PREFIX=/" ];
installFlags = [ "INSTALL_ROOT=$(out)" ];
postInstall =
''
mv $out/usr/* $out
rm -rf $out/usr
'';
}

View File

@@ -1,14 +0,0 @@
{
stdenv, src,
tcl,
procps, bc, lua
}:
stdenv.mkDerivation
{
name = "lmod";
inherit src;
buildInputs = [ tcl ];
nativeBuildInputs = [ procps bc (lua.withPackages (ps: with ps; [ luaposix ])) ];
configurePhase = ''./configure --prefix=$out/share'';
postUnpack = "patchShebangs .";
}

View File

@@ -1,6 +1,6 @@
{
lib, stdenv, mkPnpmPackage, fetchurl, nodejs, writeShellScript, buildFHSEnv,
bash, cypress, vips, pkg-config, src, libtensorflow
bash, cypress, vips, pkg-config, src
}:
let
name = "misskey";
@@ -8,7 +8,6 @@ let
{
inherit name src nodejs;
copyPnpmStore = true;
extraIntegritySha256."https://github.com/aiscript-dev/aiscript-languageserver/releases/download/0.1.5/aiscript-dev-aiscript-languageserver-0.1.5.tgz" = "1mhnwa8h48bc21f0zv8q93aphiqz9i70r7m4xsa4sd1mlncfgyl7";
};
startScript = writeShellScript "misskey"
''
@@ -32,7 +31,6 @@ in
''
export HOME=$NIX_BUILD_TOP # Some packages need a writable HOME
export npm_config_nodedir=${nodejs}
pnpm config set reporter append-only
runHook preConfigure

View File

@@ -1,22 +0,0 @@
{ buildGoModule, cudatoolkit, src, config, cudaCapabilities ? config.cudaCapabilities, gcc, makeWrapper }:
# TODO: use addDriverRunpath
buildGoModule
{
name = "mumax";
inherit src;
vendorHash = null;
nativeBuildInputs = [ cudatoolkit gcc makeWrapper ];
CUDA_CC = builtins.concatStringsSep " " cudaCapabilities;
CPATH = "${cudatoolkit}/include";
LIBRARY_PATH = "${cudatoolkit}/lib/stubs";
doCheck = false;
postInstall =
''
rm $out/bin/{doc,test}
for i in $out/bin/*; do
if [ -f $i ]; then
wrapProgram $i --prefix LD_LIBRARY_PATH ":" "/run/opengl-driver/lib:${cudatoolkit}/lib"
fi
done
'';
}

View File

@@ -1,43 +0,0 @@
{
version ? "24.1",
stdenvNoCC, fetchurl, buildFHSEnv,
gfortran, flock
}:
let
versions =
{
"24.1" = "1n0x1x7ywvr3623ylvrjagayn44mbvfas3c3062p7y3asmgjx697";
"23.1" = "1xg933f4n1bw39y1x1vrjrbzpx36sbmjgvi332hfck3dbx0n982m";
};
releaseName = version:
let versions = builtins.splitVersion version;
in "nvhpc_20${builtins.elemAt versions 0}_${builtins.concatStringsSep "" versions}_Linux_x86_64_cuda_multi";
builder = buildFHSEnv
{
name = "builder";
targetPkgs = pkgs: with pkgs; [ coreutils ];
extraBwrapArgs = [ "--bind" "$out" "$out" ];
};
in stdenvNoCC.mkDerivation
{
pname = "nvhpc";
inherit version;
src = fetchurl
{
url = "https://developer.download.nvidia.com/hpc-sdk/${version}/${releaseName version}.tar.gz";
sha256 = versions.${version};
};
dontFixup = true;
dontBuild = true;
buildInputs = [ gfortran flock ];
installPhase =
''
export NVHPC_SILENT=true
export NVHPC_INSTALL_TYPE=single
export NVHPC_INSTALL_DIR=$out/share/nvhpc
# $out should exist before bwrap
mkdir -p $out
${builder}/bin/builder ./install
'';
requiredSystemFeatures = [ "gccarch-exact-${stdenvNoCC.hostPlatform.gcc.arch}" "big-parallel" ];
}

View File

@@ -1,90 +0,0 @@
{
version ? "2024.0",
stdenvNoCC, fetchurl, buildFHSEnv,
ncurses
}:
let
versions =
{
"2022.2" =
{
basekit =
{
id = "18673";
version = "2022.2.0.262";
sha256 = "03qx6sb58mkhc7iyc8va4y1ihj6l3155dxwmqj8dfw7j2ma7r5f6";
components =
[
"intel.oneapi.lin.dpcpp-ct"
"intel.oneapi.lin.dpcpp_dbg"
"intel.oneapi.lin.dpl"
"intel.oneapi.lin.tbb.devel"
"intel.oneapi.lin.ccl.devel"
"intel.oneapi.lin.dpcpp-cpp-compiler"
"intel.oneapi.lin.dpl"
"intel.oneapi.lin.mkl.devel"
];
};
hpckit =
{
id = "18679";
version = "2022.2.0.191";
sha256 = "0swz4w9bn58wwqjkqhjqnkcs8k8ms9nn9s8k7j5w6rzvsa6817d2";
};
};
"2024.0" =
{
basekit =
{
id = "163da6e4-56eb-4948-aba3-debcec61c064";
version = "2024.0.1.46";
sha256 = "1sp1fgjv8xj8qxf8nv4lr1x5cxz7xl5wv4ixmfmcg0gyk28cjq1g";
};
hpckit =
{
id = "67c08c98-f311-4068-8b85-15d79c4f277a";
version = "2024.0.1.38";
sha256 = "06vpdz51w2v4ncgk8k6y2srlfbbdqdmb4v4bdwb67zsg9lmf8fp9";
};
};
};
builder = buildFHSEnv
{
name = "builder";
targetPkgs = pkgs: with pkgs; [ coreutils zlib ];
extraBwrapArgs = [ "--bind" "$out" "$out" ];
runScript = "sh";
};
componentString = components: if components == null then "--components default" else
" --components " + (builtins.concatStringsSep ":" components);
in stdenvNoCC.mkDerivation rec
{
pname = "oneapi";
inherit version;
basekit = fetchurl
{
url = "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/${versions.${version}.basekit.id}/"
+ "l_BaseKit_p_${versions.${version}.basekit.version}_offline.sh";
sha256 = versions.${version}.basekit.sha256;
};
hpckit = fetchurl
{
url = "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/${versions.${version}.hpckit.id}/"
+ "l_HPCKit_p_${versions.${version}.hpckit.version}_offline.sh";
sha256 = versions.${version}.hpckit.sha256;
};
phases = [ "installPhase" ];
nativeBuildInputs = [ ncurses ];
installPhase =
''
mkdir -p $out
${builder}/bin/builder ${basekit} -a --silent --eula accept --install-dir $out/share/intel \
${componentString versions.${version}.basekit.components or null}
${builder}/bin/builder ${hpckit} -a --silent --eula accept --install-dir $out/share/intel \
${componentString versions.${version}.hpckit.components or null}
${builder}/bin/builder $out/share/intel/modulefiles-setup.sh --output-dir=$out/share/intel/modulefiles \
--ignore-latest
'';
dontFixup = true;
requiredSystemFeatures = [ "gccarch-exact-${stdenvNoCC.hostPlatform.gcc.arch}" "big-parallel" ];
}

View File

@@ -1,10 +0,0 @@
{ stdenv, src }: stdenv.mkDerivation
{
name = "slate";
src = "${src}/Slate.tar.gz";
installPhase =
''
mkdir -p $out/share/yakuake/skins/Slate
cp -r * $out/share/yakuake/skins/Slate
'';
}

View File

@@ -0,0 +1,42 @@
{ lib, stdenv, steam-run, fetchurl, writeShellScript }:
let
typora-dist = stdenv.mkDerivation rec
{
pname = "typora-dist";
version = "1.8.2-dev";
src = fetchurl
{
url = "https://download.typora.io/linux/typora_${version}_amd64.deb";
sha256 = "0abi9m8h8k0228ajag26lxk756a7aqqixg608k85gnkdmibnq6mv";
};
dontFixup = true;
unpackPhase =
''
ar x ${src}
tar xf data.tar.xz
'';
installPhase =
''
mkdir -p $out
mv usr/share $out
'';
};
in stdenv.mkDerivation rec
{
pname = "typora";
inherit (typora-dist) version;
BuildInputs = [ typora-dist steam-run ];
startScript = writeShellScript "typora" "${steam-run}/bin/steam-run ${typora-dist}/share/typora/Typora $@";
phases = [ "installPhase" ];
installPhase =
''
mkdir -p $out/bin $out/share/applications
ln -s ${startScript} $out/bin/typora
cp ${typora-dist}/share/applications/typora.desktop $out/share/applications
sed -i "s|Exec=.*|Exec=${startScript} %U|g" $out/share/applications/typora.desktop
sed -i "s|Icon=.*|Icon=${typora-dist}/share/icons/hicolor/256x256/apps/typora.png|g" \
$out/share/applications/typora.desktop
'';
}

View File

@@ -1,75 +0,0 @@
{
buildFHSEnv, writeScript, stdenvNoCC, requireFile, substituteAll,
aocc, rsync, which, hdf5, wannier90, aocl, openmpi, gcc, zlib, glibc, binutils, libpsm2,
additionalCommands ? ""
}:
let
sources = import ../source.nix { inherit requireFile; };
buildEnv = buildFHSEnv
{
name = "buildEnv";
targetPkgs = _: [ zlib aocc aocl openmpi gcc.cc gcc.cc.lib glibc.dev binutils.bintools ];
};
buildScript = writeScript "build"
''
mkdir -p bin
make DEPS=1 -j$NIX_BUILD_CORES
'';
include = version: substituteAll
{
src = ./makefile.include-${version};
gccArch = stdenvNoCC.hostPlatform.gcc.arch;
};
vasp = version: stdenvNoCC.mkDerivation rec
{
pname = "vasp-amd";
inherit version;
src = sources.${version};
configurePhase =
''
cp ${include version} makefile.include
cp ${../constr_cell_relax.F} src/constr_cell_relax.F
'';
buildInputs = [ wannier90 ];
nativeBuildInputs = [ rsync which ];
AMDBLIS_ROOT = aocl;
AMDLIBFLAME_ROOT = aocl;
AMDSCALAPACK_ROOT = aocl;
AMDFFTW_ROOT = aocl;
HDF5_ROOT = hdf5;
WANNIER90_ROOT = wannier90;
OMPI_CC = "clang";
OMPI_CXX = "clang++";
OMPI_FC = "flang";
buildPhase = "${buildEnv}/bin/buildEnv ${buildScript}";
installPhase =
''
mkdir -p $out/bin
for i in std gam ncl; do cp bin/vasp_$i $out/bin/vasp-$i; done
'';
dontFixup = true;
requiredSystemFeatures = [ "gccarch-exact-${stdenvNoCC.hostPlatform.gcc.arch}" "big-parallel" ];
};
startScript = version: writeScript "vasp-nvidia-${version}"
''
# if OMP_NUM_THREADS is not set, set it according to SLURM_CPUS_PER_TASK or to 1
if [ -z "''${OMP_NUM_THREADS-}" ]; then
if [ -n "''${SLURM_CPUS_PER_TASK-}" ]; then
OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
else
OMP_NUM_THREADS=1
fi
fi
export OMP_NUM_THREADS
${additionalCommands}
exec "$@"
'';
runEnv = version: buildFHSEnv
{
name = "vasp-amd-${builtins.replaceStrings ["."] [""] version}-env";
targetPkgs = _: [ zlib (vasp version) aocc aocl openmpi gcc.cc.lib hdf5 wannier90 libpsm2 ];
runScript = startScript version;
};
in builtins.mapAttrs (version: _: runEnv version) sources

View File

@@ -1,91 +0,0 @@
# Default precompiler options
CPP_OPTIONS = -DHOST=\"LinuxGNU\" \
-DMPI -DMPI_BLOCK=8000 -Duse_collective \
-DscaLAPACK \
-DCACHE_SIZE=4000 \
-Davoidalloc \
-Dvasp6 \
-Duse_bse_te \
-Dtbdyn \
-Dfock_dblbuf \
-D_OPENMP -Duse_shmem -Dshmem_bcast_buffer -Dshmem_rproj
CPP = flang -E -C -w $*$(FUFFIX) >$*$(SUFFIX) $(CPP_OPTIONS) -ffree-form
FC = mpif90 -fopenmp
FCL = mpif90 -fopenmp
FREE = -ffree-form -ffree-line-length-none
FFLAGS = -w -fno-fortran-main -Mbackslash
OFLAG = -O2
OFLAG_IN = $(OFLAG)
DEBUG = -O0
OBJECTS = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o
OBJECTS_O1 += fftw3d.o fftmpi.o fftmpiw.o
OBJECTS_O2 += fft3dlib.o
# For what used to be vasp.5.lib
CPP_LIB = $(CPP)
FC_LIB = $(FC)
CC_LIB = clang
CFLAGS_LIB = -O
FFLAGS_LIB = -O1
FREE_LIB = $(FREE)
OBJECTS_LIB = linpack_double.o getshmem.o
# For the parser library
CXX_PARS = clang++
LLIBS = -lstdc++
##
## Customize as of this point! Of course you may change the preceding
## part of this file as well if you like, but it should rarely be
## necessary ...
##
# When compiling on the target machine itself, change this to the
# relevant target when cross-compiling for another architecture
VASP_TARGET_CPU ?= -march=@gccArch@
FFLAGS += $(VASP_TARGET_CPU)
# BLAS (mandatory)
AMDBLIS_ROOT ?= /path/to/your/amdblis/installation
BLAS = -L${AMDBLIS_ROOT}/lib -lblis-mt
# LAPACK (mandatory)
AMDLIBFLAME_ROOT ?= /path/to/your/amdlibflame/installation
LAPACK = -L${AMDLIBFLAME_ROOT}/lib -lflame
# scaLAPACK (mandatory)
AMDSCALAPACK_ROOT ?= /path/to/your/amdscalapack/installation
SCALAPACK = -L${AMDSCALAPACK_ROOT}/lib -lscalapack
LLIBS += $(SCALAPACK) $(LAPACK) $(BLAS)
# FFTW (mandatory)
AMDFFTW_ROOT ?= /path/to/your/amdfftw/installation
LLIBS += -L$(AMDFFTW_ROOT)/lib -lfftw3 -lfftw3_omp
INCS += -I$(AMDFFTW_ROOT)/include
# HDF5-support (optional but strongly recommended)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT ?= /path/to/your/hdf5/installation
LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS += -I$(HDF5_ROOT)/include
# For the VASP-2-Wannier90 interface (optional)
CPP_OPTIONS += -DVASP2WANNIER90
WANNIER90_ROOT ?= /path/to/your/wannier90/installation
LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier
# For the fftlib library (recommended)
CPP_OPTIONS+= -Dsysv
FCL += fftlib.o
CXX_FFTLIB = clang++ -fopenmp -std=c++11 -DFFTLIB_THREADSAFE
INCS_FFTLIB = -I./include -I$(AMDFFTW_ROOT)/include
LIBS += fftlib
LLIBS += -ldl

View File

@@ -1,91 +0,0 @@
# Default precompiler options
CPP_OPTIONS = -DHOST=\"LinuxGNU\" \
-DMPI -DMPI_BLOCK=8000 -Duse_collective \
-DscaLAPACK \
-DCACHE_SIZE=4000 \
-Davoidalloc \
-Dvasp6 \
-Duse_bse_te \
-Dtbdyn \
-Dfock_dblbuf \
-D_OPENMP -Duse_shmem -Dshmem_bcast_buffer -Dshmem_rproj
CPP = flang -E -ffree-form -C -w $*$(FUFFIX) >$*$(SUFFIX) $(CPP_OPTIONS) -ffree-form
FC = mpif90 -fopenmp
FCL = mpif90 -fopenmp
FREE = -ffree-form -ffree-line-length-none
FFLAGS = -w -fno-fortran-main -Mbackslash
OFLAG = -O2
OFLAG_IN = $(OFLAG)
DEBUG = -O0
OBJECTS = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o
OBJECTS_O1 += fftw3d.o fftmpi.o fftmpiw.o
OBJECTS_O2 += fft3dlib.o
# For what used to be vasp.5.lib
CPP_LIB = $(CPP)
FC_LIB = $(FC)
CC_LIB = clang
CFLAGS_LIB = -O
FFLAGS_LIB = -O1
FREE_LIB = $(FREE)
OBJECTS_LIB = linpack_double.o getshmem.o
# For the parser library
CXX_PARS = clang++
LLIBS = -lstdc++
##
## Customize as of this point! Of course you may change the preceding
## part of this file as well if you like, but it should rarely be
## necessary ...
##
# When compiling on the target machine itself, change this to the
# relevant target when cross-compiling for another architecture
VASP_TARGET_CPU ?= -march=@gccArch@
FFLAGS += $(VASP_TARGET_CPU)
# BLAS (mandatory)
AMDBLIS_ROOT ?= /path/to/your/amdblis/installation
BLAS = -L${AMDBLIS_ROOT}/lib -lblis-mt
# LAPACK (mandatory)
AMDLIBFLAME_ROOT ?= /path/to/your/amdlibflame/installation
LAPACK = -L${AMDLIBFLAME_ROOT}/lib -lflame
# scaLAPACK (mandatory)
AMDSCALAPACK_ROOT ?= /path/to/your/amdscalapack/installation
SCALAPACK = -L${AMDSCALAPACK_ROOT}/lib -lscalapack
LLIBS += $(SCALAPACK) $(LAPACK) $(BLAS)
# FFTW (mandatory)
AMDFFTW_ROOT ?= /path/to/your/amdfftw/installation
LLIBS += -L$(AMDFFTW_ROOT)/lib -lfftw3 -lfftw3_omp
INCS += -I$(AMDFFTW_ROOT)/include
# HDF5-support (optional but strongly recommended)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT ?= /path/to/your/hdf5/installation
LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS += -I$(HDF5_ROOT)/include
# For the VASP-2-Wannier90 interface (optional)
CPP_OPTIONS += -DVASP2WANNIER90
WANNIER90_ROOT ?= /path/to/your/wannier90/installation
LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier
# For the fftlib library (recommended)
CPP_OPTIONS+= -Dsysv
FCL += fftlib.o
CXX_FFTLIB = clang++ -fopenmp -std=c++11 -DFFTLIB_THREADSAFE
INCS_FFTLIB = -I./include -I$(AMDFFTW_ROOT)/include
LIBS += fftlib
LLIBS += -ldl

View File

@@ -1,22 +0,0 @@
SUBROUTINE CONSTR_CELL_RELAX(FCELL)
USE prec
REAL(q) FCELL(3,3)
LOGICAL FILFLG
INTEGER ICELL(3,3)
INQUIRE(FILE='OPTCELL',EXIST=FILFLG)
IF (FILFLG) THEN
OPEN(67,FILE='OPTCELL',FORM='FORMATTED',STATUS='OLD')
DO J=1,3
READ(67,"(3I1)") (ICELL(I,J),I=1,3)
ENDDO
CLOSE(67)
DO J=1,3
DO I=1,3
IF (ICELL(I,J)==0) FCELL(I,J)=0.0
ENDDO
ENDDO
ENDIF
RETURN
END SUBROUTINE

View File

@@ -0,0 +1,77 @@
# {
# stdenv, requireFile, config, rsync, intel-mpi, ifort,
# mkl
# }:
# stdenv.mkDerivation rec
# {
# pname = "vasp";
# version = "6.4.0";
# # nix-store --query --hash $(nix store add-path ./vasp-6.4.0)
# src = requireFile
# {
# name = "${pname}-${version}";
# sha256 = "189i1l5q33ynmps93p2mwqf5fx7p4l50sls1krqlv8ls14s3m71f";
# hashMode = "recursive";
# message = "Source file not found.";
# };
# VASP_TARGET_CPU = if config ? oneapiArch then "-x${config.oneapiArch}" else "";
# MKLROOT = mkl;
# makeFlags = "DEPS=1";
# enableParallelBuilding = true;
# buildInputs = [ mkl intel-mpi ifort ];
# nativeBuildInputs = [ rsync ];
# configurePhase =
# ''
# cp arch/makefile.include.intel makefile.include
# echo "CPP_OPTIONS += -Duse_shmem -Dshmem_bcast_buffer -Dshmem_rproj" >> makefile.include
# echo "OBJECTS_LIB += getshmem.o" >> makefile.include
# mkdir -p bin
# '';
# installPhase =
# ''
# mkdir -p $out/bin
# for i in std gam ncl; do
# cp bin/vasp_$i $out/bin/vasp-cpu-${version}-$i
# done
# '';
# doStrip = false;
# doFixup = false;
# }
{
stdenvNoCC, requireFile, rsync, blas, scalapack, openmpi, openmp, gfortran, gcc, fftwMpi
}:
stdenvNoCC.mkDerivation rec
{
pname = "vasp";
version = "6.4.0";
# nix-store --query --hash $(nix store add-path ./vasp-6.4.0)
src = requireFile
{
name = "${pname}-${version}";
sha256 = "189i1l5q33ynmps93p2mwqf5fx7p4l50sls1krqlv8ls14s3m71f";
hashMode = "recursive";
message = "Source file not found.";
};
# VASP_TARGET_CPU = if config ? oneapiArch then "-x${config.oneapiArch}" else "";
# MKLROOT = mkl;
makeFlags = "DEPS=1";
enableParallelBuilding = true;
buildInputs = [ blas scalapack openmpi openmp gfortran gfortran.cc gcc fftwMpi.dev fftwMpi ];
nativeBuildInputs = [ rsync ];
FFTW_ROOT = fftwMpi.dev;
configurePhase =
''
cp ${./makefile.include/${version}-gnu} makefile.include
chmod +w makefile.include
echo "CPP_OPTIONS += -Duse_shmem -Dshmem_bcast_buffer -Dshmem_rproj" >> makefile.include
echo "OBJECTS_LIB += getshmem.o" >> makefile.include
mkdir -p bin
'';
installPhase =
''
mkdir -p $out/bin
for i in std gam ncl; do
cp bin/vasp_$i $out/bin/vasp-gnu-${version}-$i
done
'';
}

View File

@@ -1,57 +0,0 @@
{
stdenvNoCC, requireFile, writeShellApplication,
rsync, mkl, mpi, openmp, gfortran, gcc, fftwMpi, hdf5, wannier90,
additionalCommands ? ""
}:
let
sources = import ../source.nix { inherit requireFile; };
include = version: ./makefile.include-${version};
vasp = version: stdenvNoCC.mkDerivation rec
{
pname = "vasp-gnu-mkl";
inherit version;
src = sources.${version};
configurePhase =
''
cp ${include version} makefile.include
cp ${../constr_cell_relax.F} src/constr_cell_relax.F
mkdir -p bin
'';
enableParallelBuilding = true;
makeFlags = "DEPS=1";
buildInputs = [ mkl mpi openmp fftwMpi.dev fftwMpi hdf5 hdf5.dev wannier90 ];
nativeBuildInputs = [ rsync gfortran gfortran.cc gcc ];
FFTW_ROOT = fftwMpi.dev;
HDF5_ROOT = hdf5.dev;
WANNIER90_ROOT = wannier90;
MKLROOT = mkl;
installPhase =
''
mkdir -p $out/bin
for i in std gam ncl; do
cp bin/vasp_$i $out/bin/vasp-$i
done
'';
};
startScript = version: writeShellApplication
{
name = "vasp-gnu-${builtins.replaceStrings ["."] [""] version}-env";
runtimeInputs = [(vasp version)];
text =
''
# if OMP_NUM_THREADS is not set, set it according to SLURM_CPUS_PER_TASK or to 1
if [ -z "''${OMP_NUM_THREADS-}" ]; then
if [ -n "''${SLURM_CPUS_PER_TASK-}" ]; then
OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
else
OMP_NUM_THREADS=1
fi
fi
export OMP_NUM_THREADS
${additionalCommands}
exec "$@"
'';
};
in builtins.mapAttrs (version: _: startScript version) sources

View File

@@ -1,87 +0,0 @@
# Default precompiler options
CPP_OPTIONS = -DHOST=\"LinuxGNU\" \
-DMPI -DMPI_BLOCK=8000 -Duse_collective \
-DscaLAPACK \
-DCACHE_SIZE=4000 \
-Davoidalloc \
-Dvasp6 \
-Duse_bse_te \
-Dtbdyn \
-Dfock_dblbuf \
-D_OPENMP -Duse_shmem -Dshmem_bcast_buffer -Dshmem_rproj
CPP = gcc -E -C -w $*$(FUFFIX) >$*$(SUFFIX) $(CPP_OPTIONS)
FC = mpif90 -fopenmp
FCL = mpif90 -fopenmp
FREE = -ffree-form -ffree-line-length-none
FFLAGS = -w -ffpe-summary=none
OFLAG = -O2
OFLAG_IN = $(OFLAG)
DEBUG = -O0
OBJECTS = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o
OBJECTS_O1 += fftw3d.o fftmpi.o fftmpiw.o
OBJECTS_O2 += fft3dlib.o
# For what used to be vasp.5.lib
CPP_LIB = $(CPP)
FC_LIB = $(FC)
CC_LIB = gcc
CFLAGS_LIB = -O
FFLAGS_LIB = -O1
FREE_LIB = $(FREE)
OBJECTS_LIB = linpack_double.o getshmem.o
# For the parser library
CXX_PARS = g++
LLIBS = -lstdc++
##
## Customize as of this point! Of course you may change the preceding
## part of this file as well if you like, but it should rarely be
## necessary ...
##
# When compiling on the target machine itself, change this to the
# relevant target when cross-compiling for another architecture
# VASP_TARGET_CPU ?= -march=native
# FFLAGS += $(VASP_TARGET_CPU)
# For gcc-10 and higher (comment out for older versions)
FFLAGS += -fallow-argument-mismatch
# Intel MKL for FFTW, BLAS, LAPACK, and scaLAPACK
MKLROOT ?= /path/to/your/mkl/installation
LLIBS_MKL = -L$(MKLROOT)/lib/intel64 -Wl,--no-as-needed -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lmkl_scalapack_lp64 -lmkl_blacs_openmpi_lp64 -lgomp -lpthread -lm -ldl
INCS = -I$(MKLROOT)/include/fftw
# Use a separate scaLAPACK installation (optional but recommended in combination with OpenMPI)
# Comment out the two lines below if you want to use scaLAPACK from MKL instead
#SCALAPACK_ROOT ?= /path/to/your/scalapack/installation
#LLIBS_MKL = -L$(SCALAPACK_ROOT)/lib -lscalapack -L$(MKLROOT)/lib/intel64 -Wl,--no-as-needed -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl
LLIBS += $(LLIBS_MKL)
# HDF5-support (optional but strongly recommended)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT ?= /path/to/your/hdf5/installation
LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS += -I$(HDF5_ROOT)/include
# For the VASP-2-Wannier90 interface (optional)
CPP_OPTIONS += -DVASP2WANNIER90
WANNIER90_ROOT ?= /path/to/your/wannier90/installation
LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier
# For the fftlib library (hardly any benefit in combination with MKL's FFTs)
#CPP_OPTIONS+= -Dsysv
#FCL += fftlib.o
#CXX_FFTLIB = g++ -fopenmp -std=c++11 -DFFTLIB_USE_MKL -DFFTLIB_THREADSAFE
#INCS_FFTLIB = -I./include -I$(MKLROOT)/include/fftw
#LIBS += fftlib
#LLIBS += -ldl

View File

@@ -1,87 +0,0 @@
# Default precompiler options
CPP_OPTIONS = -DHOST=\"LinuxGNU\" \
-DMPI -DMPI_BLOCK=8000 -Duse_collective \
-DscaLAPACK \
-DCACHE_SIZE=4000 \
-Davoidalloc \
-Dvasp6 \
-Duse_bse_te \
-Dtbdyn \
-Dfock_dblbuf \
-D_OPENMP -Duse_shmem -Dshmem_bcast_buffer -Dshmem_rproj
CPP = gcc -E -C -w $*$(FUFFIX) >$*$(SUFFIX) $(CPP_OPTIONS)
FC = mpif90 -fopenmp
FCL = mpif90 -fopenmp
FREE = -ffree-form -ffree-line-length-none
FFLAGS = -w -ffpe-summary=none
OFLAG = -O3
OFLAG_IN = $(OFLAG)
DEBUG = -O0
OBJECTS = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o
OBJECTS_O1 += fftw3d.o fftmpi.o fftmpiw.o
OBJECTS_O2 += fft3dlib.o
# For what used to be vasp.5.lib
CPP_LIB = $(CPP)
FC_LIB = $(FC)
CC_LIB = gcc
CFLAGS_LIB = -O
FFLAGS_LIB = -O1
FREE_LIB = $(FREE)
OBJECTS_LIB = linpack_double.o getshmem.o
# For the parser library
CXX_PARS = g++
LLIBS = -lstdc++
##
## Customize as of this point! Of course you may change the preceding
## part of this file as well if you like, but it should rarely be
## necessary ...
##
# When compiling on the target machine itself, change this to the
# relevant target when cross-compiling for another architecture
# VASP_TARGET_CPU ?= -march=native
# FFLAGS += $(VASP_TARGET_CPU)
# For gcc-10 and higher (comment out for older versions)
FFLAGS += -fallow-argument-mismatch
# Intel MKL for FFTW, BLAS, LAPACK, and scaLAPACK
MKLROOT ?= /path/to/your/mkl/installation
LLIBS_MKL = -L$(MKLROOT)/lib/intel64 -Wl,--no-as-needed -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lmkl_scalapack_lp64 -lmkl_blacs_openmpi_lp64 -lgomp -lpthread -lm -ldl
INCS = -I$(MKLROOT)/include/fftw
# Use a separate scaLAPACK installation (optional but recommended in combination with OpenMPI)
# Comment out the two lines below if you want to use scaLAPACK from MKL instead
#SCALAPACK_ROOT ?= /path/to/your/scalapack/installation
#LLIBS_MKL = -L$(SCALAPACK_ROOT)/lib -lscalapack -L$(MKLROOT)/lib/intel64 -Wl,--no-as-needed -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl
LLIBS += $(LLIBS_MKL)
# HDF5-support (optional but strongly recommended)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT ?= /path/to/your/hdf5/installation
LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS += -I$(HDF5_ROOT)/include
# For the VASP-2-Wannier90 interface (optional)
CPP_OPTIONS += -DVASP2WANNIER90
WANNIER90_ROOT ?= /path/to/your/wannier90/installation
LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier
# For the fftlib library (hardly any benefit in combination with MKL's FFTs)
#CPP_OPTIONS+= -Dsysv
#FCL += fftlib.o
#CXX_FFTLIB = g++ -fopenmp -std=c++11 -DFFTLIB_USE_MKL -DFFTLIB_THREADSAFE
#INCS_FFTLIB = -I./include -I$(MKLROOT)/include/fftw
#LIBS += fftlib
#LLIBS += -ldl

View File

@@ -1,56 +0,0 @@
{
stdenvNoCC, requireFile, writeShellApplication,
rsync, blas, scalapack, mpi, openmp, gfortran, gcc, fftwMpi, hdf5, wannier90,
additionalCommands ? ""
}:
let
sources = import ../source.nix { inherit requireFile; };
include = version: ./makefile.include-${version};
vasp = version: stdenvNoCC.mkDerivation rec
{
pname = "vasp-gnu";
inherit version;
src = sources.${version};
configurePhase =
''
cp ${include version} makefile.include
cp ${../constr_cell_relax.F} src/constr_cell_relax.F
mkdir -p bin
'';
enableParallelBuilding = true;
makeFlags = "DEPS=1";
buildInputs = [ blas scalapack mpi openmp fftwMpi.dev fftwMpi hdf5 hdf5.dev wannier90 ];
nativeBuildInputs = [ rsync gfortran gfortran.cc gcc ];
FFTW_ROOT = fftwMpi.dev;
HDF5_ROOT = hdf5.dev;
WANNIER90_ROOT = wannier90;
installPhase =
''
mkdir -p $out/bin
for i in std gam ncl; do
cp bin/vasp_$i $out/bin/vasp-$i
done
'';
};
startScript = version: writeShellApplication
{
name = "vasp-gnu-${builtins.replaceStrings ["."] [""] version}-env";
runtimeInputs = [(vasp version)];
text =
''
# if OMP_NUM_THREADS is not set, set it according to SLURM_CPUS_PER_TASK or to 1
if [ -z "''${OMP_NUM_THREADS-}" ]; then
if [ -n "''${SLURM_CPUS_PER_TASK-}" ]; then
OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
else
OMP_NUM_THREADS=1
fi
fi
export OMP_NUM_THREADS
${additionalCommands}
exec "$@"
'';
};
in builtins.mapAttrs (version: _: startScript version) sources

View File

@@ -1,92 +0,0 @@
# Default precompiler options
CPP_OPTIONS = -DHOST=\"LinuxGNU\" \
-DMPI -DMPI_BLOCK=8000 -Duse_collective \
-DscaLAPACK \
-DCACHE_SIZE=4000 \
-Davoidalloc \
-Dvasp6 \
-Duse_bse_te \
-Dtbdyn \
-Dfock_dblbuf \
-D_OPENMP -Duse_shmem -Dshmem_bcast_buffer -Dshmem_rproj
CPP = gcc -E -C -w $*$(FUFFIX) >$*$(SUFFIX) $(CPP_OPTIONS)
FC = mpif90 -fopenmp
FCL = mpif90 -fopenmp
FREE = -ffree-form -ffree-line-length-none
FFLAGS = -w -ffpe-summary=none
OFLAG = -O2
OFLAG_IN = $(OFLAG)
DEBUG = -O0
OBJECTS = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o
OBJECTS_O1 += fftw3d.o fftmpi.o fftmpiw.o
OBJECTS_O2 += fft3dlib.o
# For what used to be vasp.5.lib
CPP_LIB = $(CPP)
FC_LIB = $(FC)
CC_LIB = gcc
CFLAGS_LIB = -O
FFLAGS_LIB = -O1
FREE_LIB = $(FREE)
OBJECTS_LIB = linpack_double.o getshmem.o
# For the parser library
CXX_PARS = g++
LLIBS = -lstdc++
##
## Customize as of this point! Of course you may change the preceding
## part of this file as well if you like, but it should rarely be
## necessary ...
##
# When compiling on the target machine itself, change this to the
# relevant target when cross-compiling for another architecture
# VASP_TARGET_CPU ?= -march=native
# FFLAGS += $(VASP_TARGET_CPU)
# For gcc-10 and higher (comment out for older versions)
FFLAGS += -fallow-argument-mismatch
# BLAS and LAPACK (mandatory)
# OPENBLAS_ROOT ?= /path/to/your/openblas/installation
# BLASPACK = -L$(OPENBLAS_ROOT)/lib -lopenblas
BLASPACK = -lblas
# scaLAPACK (mandatory)
# SCALAPACK_ROOT ?= /path/to/your/scalapack/installation
# SCALAPACK = -L$(SCALAPACK_ROOT)/lib -lscalapack
SCALAPACK = -lscalapack
LLIBS += $(SCALAPACK) $(BLASPACK)
# FFTW (mandatory)
FFTW_ROOT ?= /path/to/your/fftw/installation
LLIBS += -L$(FFTW_ROOT)/lib -lfftw3 -lfftw3_omp
INCS += -I$(FFTW_ROOT)/include
# HDF5-support (optional but strongly recommended)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT ?= /path/to/your/hdf5/installation
LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS += -I$(HDF5_ROOT)/include
# For the VASP-2-Wannier90 interface (optional)
CPP_OPTIONS += -DVASP2WANNIER90
WANNIER90_ROOT ?= /path/to/your/wannier90/installation
LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier
# For the fftlib library (recommended)
CPP_OPTIONS+= -Dsysv
FCL += fftlib.o
CXX_FFTLIB = g++ -fopenmp -std=c++11 -DFFTLIB_THREADSAFE
INCS_FFTLIB = -I./include -I$(FFTW_ROOT)/include
LIBS += fftlib
LLIBS += -ldl

View File

@@ -1,46 +0,0 @@
{
buildFHSEnv, writeScript, stdenvNoCC,
src,
aocc, cmake, openmpi, zlib, gcc, glibc, binutils, pkg-config
}:
let
buildEnv = buildFHSEnv
{
name = "buildEnv";
targetPkgs = _: [ zlib aocc gcc.cc.lib.lib glibc.dev binutils.bintools openmpi pkg-config ];
extraBwrapArgs = [ "--bind" "$out" "$out" ];
};
buildScript = writeScript "build"
''
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$out -DHDF5_INSTALL_CMAKE_DIR=$out/lib/cmake \
-DHDF5_BUILD_FORTRAN=ON -DHDF5_ENABLE_PARALLEL=ON ..
make -j$NIX_BUILD_CORES
make install
'';
in stdenvNoCC.mkDerivation
{
name = "hdf5-aocc";
inherit src;
dontConfigure = true;
enableParallelBuilding = true;
nativeBuildInputs = [ cmake ];
CC = "clang";
CXX = "clang++";
FC = "flang";
OMPI_CC = "clang";
OMPI_CXX = "clang++";
OMPI_FC = "flang";
CFLAGS = "-march=${stdenvNoCC.hostPlatform.gcc.arch} -O2";
CXXFLAGS = "-march=${stdenvNoCC.hostPlatform.gcc.arch} -O2";
FCFLAGS = "-march=${stdenvNoCC.hostPlatform.gcc.arch} -O2";
buildPhase =
''
mkdir -p $out
${buildEnv}/bin/buildEnv ${buildScript}
'';
dontInstall = true;
dontFixup = true;
requiredSystemFeatures = [ "gccarch-exact-${stdenvNoCC.hostPlatform.gcc.arch}" "big-parallel" ];
}

View File

@@ -1,40 +0,0 @@
{
buildFHSEnv, writeScript, stdenvNoCC,
src,
nvhpc, lmod, cmake, gfortran
}:
let
buildEnv = buildFHSEnv
{
name = "buildEnv";
targetPkgs = pkgs: with pkgs; [ zlib ];
extraBwrapArgs = [ "--bind" "$out" "$out" ];
};
buildScript = writeScript "build"
''
. ${lmod}/share/lmod/lmod/init/bash
module use ${nvhpc}/share/nvhpc/modulefiles
module load nvhpc
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$out -DHDF5_INSTALL_CMAKE_DIR=$out/lib/cmake \
-DHDF5_BUILD_FORTRAN=ON -DHDF5_ENABLE_PARALLEL=ON -DBUILD_SHARED_LIBS=ON ..
make -j$NIX_BUILD_CORES
make install
'';
in stdenvNoCC.mkDerivation
{
name = "hdf5-nvhpc";
inherit src;
dontConfigure = true;
enableParallelBuilding = true;
nativeBuildInputs = [ cmake gfortran ];
buildPhase =
''
mkdir -p $out
${buildEnv}/bin/buildEnv ${buildScript}
'';
dontInstall = true;
dontFixup = true;
requiredSystemFeatures = [ "gccarch-exact-${stdenvNoCC.hostPlatform.gcc.arch}" "big-parallel" ];
}

View File

@@ -1,48 +0,0 @@
{
buildFHSEnv, writeScript, stdenvNoCC, symlinkJoin,
src,
oneapi, lmod, cmake, gcc, glibc, binutils,
config, oneapiArch ? config.oneapiArch or "SSE3"
}:
let
gccFull = symlinkJoin { name = "gcc"; paths = [ gcc gcc.cc gcc.cc.lib glibc.dev binutils.bintools ]; };
buildEnv = buildFHSEnv
{
name = "buildEnv";
targetPkgs = pkgs: with pkgs; [ zlib (writeTextDir "etc/release" "") gccFull ];
extraBwrapArgs = [ "--bind" "$out" "$out" ];
};
buildScript = writeScript "build"
''
. ${lmod}/share/lmod/lmod/init/bash
module use ${oneapi}/share/intel/modulefiles
module load tbb compiler-rt oclfpga # dependencies
module load mpi mkl compiler
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$out -DHDF5_INSTALL_CMAKE_DIR=$out/lib/cmake \
-DHDF5_BUILD_FORTRAN=ON -DHDF5_ENABLE_PARALLEL=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=OFF \
-DBUILD_TESTING=OFF ..
make -j$NIX_BUILD_CORES
make install
'';
in stdenvNoCC.mkDerivation
{
name = "hdf5-oneapi";
inherit src;
dontConfigure = true;
enableParallelBuilding = true;
nativeBuildInputs = [ cmake ];
I_MPI_CC = "icx";
I_MPI_CXX = "icpx";
I_MPI_FC = "ifx";
I_MPI_F90 = "ifx";
buildPhase =
''
mkdir -p $out
${buildEnv}/bin/buildEnv ${buildScript}
'';
dontInstall = true;
dontFixup = true;
requiredSystemFeatures = [ "gccarch-exact-${stdenvNoCC.hostPlatform.gcc.arch}" "big-parallel" ];
}

View File

@@ -1,111 +0,0 @@
{
buildFHSEnv, writeScript, stdenvNoCC, requireFile, substituteAll, symlinkJoin, writeTextDir,
config, oneapiArch ? config.oneapiArch or "SSE3", additionalCommands ? "",
oneapi, gcc, glibc, lmod, rsync, which, wannier90, binutils, hdf5, zlib
}:
let
sources = import ../source.nix { inherit requireFile; };
buildEnv = buildFHSEnv
{
name = "buildEnv";
# make "module load mpi" success
targetPkgs = _: [ zlib (writeTextDir "etc/release" "") gccFull ];
};
buildScript = writeScript "build"
''
. ${lmod}/share/lmod/lmod/init/bash
module use ${oneapi}/share/intel/modulefiles
module load tbb compiler-rt oclfpga # dependencies
module load mpi mkl compiler
mkdir -p bin
make DEPS=1 -j$NIX_BUILD_CORES
'';
include = version: substituteAll
{
src = ./makefile.include-${version};
inherit oneapiArch;
};
gccFull = symlinkJoin { name = "gcc"; paths = [ gcc gcc.cc gcc.cc.lib glibc.dev binutils.bintools ]; };
vasp = version: stdenvNoCC.mkDerivation rec
{
pname = "vasp-intel";
inherit version;
src = sources.${version};
configurePhase =
''
cp ${include version} makefile.include
cp ${../constr_cell_relax.F} src/constr_cell_relax.F
'';
nativeBuildInputs = [ rsync which ];
HDF5_ROOT = hdf5;
WANNIER90_ROOT = wannier90;
buildPhase = "${buildEnv}/bin/buildEnv ${buildScript}";
installPhase =
''
mkdir -p $out/bin
for i in std gam ncl; do cp bin/vasp_$i $out/bin/vasp-$i; done
'';
dontFixup = true;
requiredSystemFeatures = [ "gccarch-exact-${stdenvNoCC.hostPlatform.gcc.arch}" "big-parallel" ];
};
startScript = { version, variant }: writeScript "vasp-intel-${version}"
''
. ${lmod}/share/lmod/lmod/init/bash
module use ${oneapi}/share/intel/modulefiles
module load tbb compiler-rt oclfpga # dependencies
module load mpi mkl compiler
# if OMP_NUM_THREADS is not set, set it according to SLURM_CPUS_PER_TASK or to 1
if [ -z "''${OMP_NUM_THREADS-}" ]; then
if [ -n "''${SLURM_CPUS_PER_TASK-}" ]; then
OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
else
OMP_NUM_THREADS=1
fi
fi
export OMP_NUM_THREADS
# if I_MPI_PIN_PROCESSOR_LIST is not set, set it to allcores
if [ -z "''${I_MPI_PIN_PROCESSOR_LIST-}" ]; then
I_MPI_PIN_PROCESSOR_LIST=allcores
fi
export I_MPI_PIN_PROCESSOR_LIST
# set I_MPI_PIN I_MPI_PIN_DOMAIN I_MPI_DEBUG if not set
export I_MPI_PIN=''${I_MPI_PIN-yes}
export I_MPI_PIN_DOMAIN=''${I_MPI_PIN_DOMAIN-omp}
export I_MPI_DEBUG=''${I_MPI_DEBUG-4}
# fork to bootstrap, do not use srun, causing it could not find proper ld
export I_MPI_HYDRA_BOOTSTRAP=''${I_MPI_HYDRA_BOOTSTRAP-fork}
# set OMP_STACKSIZE if not set
export OMP_STACKSIZE=''${OMP_STACKSIZE-512M}
${additionalCommands}
${
if variant == "env" then ''exec "$@"''
else
''
if [ -n "''${SLURM_JOB_ID-}" ]; then
exec mpirun -n $SLURM_NTASKS ${vasp version}/bin/vasp-${variant}
else
exec mpirun -n 1 ${vasp version}/bin/vasp-${variant}
fi
''
}
'';
runEnv = { version, variant }: let shortVersion = builtins.replaceStrings ["."] [""] version; in buildFHSEnv
{
name = "vasp-intel-${shortVersion}${if variant == "" then "" else "-${variant}"}";
targetPkgs = _: [ zlib (vasp version) (writeTextDir "etc/release" "") gccFull ];
runScript = startScript { inherit version; variant = if variant == "" then "std" else variant; };
};
in builtins.mapAttrs
(version: _: symlinkJoin
{
name = "vasp-intel-${version}";
paths = builtins.map (variant: runEnv { inherit version variant; }) [ "" "env" "std" "gam" "ncl" ];
})
sources

View File

@@ -1,83 +0,0 @@
# Default precompiler options
CPP_OPTIONS = -DHOST=\"LinuxIFC\" \
-DMPI -DMPI_BLOCK=8000 -Duse_collective \
-DscaLAPACK \
-DCACHE_SIZE=4000 \
-Davoidalloc \
-Dvasp6 \
-Duse_bse_te \
-Dtbdyn \
-Dfock_dblbuf \
-D_OPENMP -Duse_shmem -Dshmem_bcast_buffer -Dshmem_rproj
CPP = fpp -f_com=no -free -w0 $*$(FUFFIX) $*$(SUFFIX) $(CPP_OPTIONS)
FC = mpiifx -qopenmp
FCL = mpiifx
FREE = -free -names lowercase
FFLAGS = -assume byterecl -w
OFLAG = -O2
OFLAG_IN = $(OFLAG)
DEBUG = -O0
OBJECTS = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o
OBJECTS_O1 += fftw3d.o fftmpi.o fftmpiw.o
OBJECTS_O2 += fft3dlib.o
# For what used to be vasp.5.lib
CPP_LIB = $(CPP)
FC_LIB = $(FC)
CC_LIB = icx
CFLAGS_LIB = -O
FFLAGS_LIB = -O1
FREE_LIB = $(FREE)
OBJECTS_LIB = linpack_double.o getshmem.o
# For the parser library
CXX_PARS = icpx
LLIBS = -lstdc++
##
## Customize as of this point! Of course you may change the preceding
## part of this file as well if you like, but it should rarely be
## necessary ...
##
# When compiling on the target machine itself, change this to the
# relevant target when cross-compiling for another architecture
VASP_TARGET_CPU ?= -x@oneapiArch@
FFLAGS += $(VASP_TARGET_CPU)
# Intel MKL for FFTW, BLAS, LAPACK, and scaLAPACK
# (Note: for Intel Parallel Studio's MKL use -mkl instead of -qmkl)
FCL += -qmkl
MKLROOT ?= /path/to/your/mkl/installation
LLIBS += -L$(MKLROOT)/lib/intel64 -lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64
INCS =-I$(MKLROOT)/include/fftw
# Use a separate scaLAPACK installation (optional but recommended in combination with OpenMPI)
# Comment out the two lines below if you want to use scaLAPACK from MKL instead
# SCALAPACK_ROOT ?= /path/to/your/scalapack/installation
# LLIBS += -L${SCALAPACK_ROOT}/lib -lscalapack
# HDF5-support (optional but strongly recommended)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT ?= /path/to/your/hdf5/installation
LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS += -I$(HDF5_ROOT)/include
# For the VASP-2-Wannier90 interface (optional)
CPP_OPTIONS += -DVASP2WANNIER90
WANNIER90_ROOT ?= /path/to/your/wannier90/installation
LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier
# For the fftlib library (hardly any benefit in combination with MKL's FFTs)
#CPP_OPTION += -Dsysv
#FCL = mpif90 fftlib.o -qmkl
#CXX_FFTLIB = icpc -qopenmp -std=c++11 -DFFTLIB_USE_MKL -DFFTLIB_THREADSAFE
#INCS_FFTLIB = -I./include -I$(MKLROOT)/include/fftw
#LIBS += fftlib

View File

@@ -1,83 +0,0 @@
# Default precompiler options
CPP_OPTIONS = -DHOST=\"LinuxIFC\" \
-DMPI -DMPI_BLOCK=8000 -Duse_collective \
-DscaLAPACK \
-DCACHE_SIZE=4000 \
-Davoidalloc \
-Dvasp6 \
-Duse_bse_te \
-Dtbdyn \
-Dfock_dblbuf \
-D_OPENMP -Duse_shmem -Dshmem_bcast_buffer -Dshmem_rproj
CPP = fpp -f_com=no -free -w0 $*$(FUFFIX) $*$(SUFFIX) $(CPP_OPTIONS)
FC = mpiifx -qopenmp
FCL = mpiifx
FREE = -free -names lowercase
FFLAGS = -assume byterecl -w
OFLAG = -O2
OFLAG_IN = $(OFLAG)
DEBUG = -O0
OBJECTS = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o
OBJECTS_O1 += fftw3d.o fftmpi.o fftmpiw.o
OBJECTS_O2 += fft3dlib.o
# For what used to be vasp.5.lib
CPP_LIB = $(CPP)
FC_LIB = $(FC)
CC_LIB = icx
CFLAGS_LIB = -O
FFLAGS_LIB = -O1
FREE_LIB = $(FREE)
OBJECTS_LIB = linpack_double.o getshmem.o
# For the parser library
CXX_PARS = icpx
LLIBS = -lstdc++
##
## Customize as of this point! Of course you may change the preceding
## part of this file as well if you like, but it should rarely be
## necessary ...
##
# When compiling on the target machine itself, change this to the
# relevant target when cross-compiling for another architecture
VASP_TARGET_CPU ?= -x@oneapiArch@
FFLAGS += $(VASP_TARGET_CPU)
# Intel MKL for FFTW, BLAS, LAPACK, and scaLAPACK
# (Note: for Intel Parallel Studio's MKL use -mkl instead of -qmkl)
FCL += -qmkl
MKLROOT ?= /path/to/your/mkl/installation
LLIBS += -L$(MKLROOT)/lib/intel64 -lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64
INCS =-I$(MKLROOT)/include/fftw
# Use a separate scaLAPACK installation (optional but recommended in combination with OpenMPI)
# Comment out the two lines below if you want to use scaLAPACK from MKL instead
# SCALAPACK_ROOT ?= /path/to/your/scalapack/installation
# LLIBS += -L${SCALAPACK_ROOT}/lib -lscalapack
# HDF5-support (optional but strongly recommended)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT ?= /path/to/your/hdf5/installation
LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS += -I$(HDF5_ROOT)/include
# For the VASP-2-Wannier90 interface (optional)
CPP_OPTIONS += -DVASP2WANNIER90
WANNIER90_ROOT ?= /path/to/your/wannier90/installation
LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier
# For the fftlib library (hardly any benefit in combination with MKL's FFTs)
#CPP_OPTION += -Dsysv
#FCL = mpif90 fftlib.o -qmkl
#CXX_FFTLIB = icpc -qopenmp -std=c++11 -DFFTLIB_USE_MKL -DFFTLIB_THREADSAFE
#INCS_FFTLIB = -I./include -I$(MKLROOT)/include/fftw
#LIBS += fftlib

View File

@@ -8,7 +8,7 @@ CPP_OPTIONS = -DHOST=\"LinuxGNU\" \
-Duse_bse_te \
-Dtbdyn \
-Dfock_dblbuf \
-D_OPENMP -Duse_shmem -Dshmem_bcast_buffer -Dshmem_rproj
-D_OPENMP
CPP = gcc -E -C -w $*$(FUFFIX) >$*$(SUFFIX) $(CPP_OPTIONS)
@@ -35,7 +35,7 @@ CFLAGS_LIB = -O
FFLAGS_LIB = -O1
FREE_LIB = $(FREE)
OBJECTS_LIB = linpack_double.o getshmem.o
OBJECTS_LIB = linpack_double.o
# For the parser library
CXX_PARS = g++
@@ -68,25 +68,27 @@ SCALAPACK = -lscalapack
LLIBS += $(SCALAPACK) $(BLASPACK)
# FFTW (mandatory)
FFTW_ROOT ?= /path/to/your/fftw/installation
LLIBS += -L$(FFTW_ROOT)/lib -lfftw3 -lfftw3_omp
# FFTW_ROOT ?= /path/to/your/fftw/installation
# LLIBS += -L$(FFTW_ROOT)/lib -lfftw3 -lfftw3_omp
LLIBS += -lfftw3 -lfftw3_omp
INCS += -I$(FFTW_ROOT)/include
# HDF5-support (optional but strongly recommended)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT ?= /path/to/your/hdf5/installation
LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS += -I$(HDF5_ROOT)/include
#CPP_OPTIONS+= -DVASP_HDF5
#HDF5_ROOT ?= /path/to/your/hdf5/installation
#LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
#INCS += -I$(HDF5_ROOT)/include
# For the VASP-2-Wannier90 interface (optional)
CPP_OPTIONS += -DVASP2WANNIER90
WANNIER90_ROOT ?= /path/to/your/wannier90/installation
LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier
#CPP_OPTIONS += -DVASP2WANNIER90
#WANNIER90_ROOT ?= /path/to/your/wannier90/installation
#LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier
# For the fftlib library (recommended)
CPP_OPTIONS+= -Dsysv
FCL += fftlib.o
CXX_FFTLIB = g++ -fopenmp -std=c++11 -DFFTLIB_THREADSAFE
INCS_FFTLIB = -I./include -I$(FFTW_ROOT)/include
# INCS_FFTLIB = -I./include -I$(FFTW_ROOT)/include
INCS_FFTLIB = -I./include
LIBS += fftlib
LLIBS += -ldl

View File

@@ -1,96 +0,0 @@
{
buildFHSEnv, writeScript, stdenvNoCC, requireFile, substituteAll, symlinkJoin,
config, cudaCapabilities ? config.cudaCapabilities, nvhpcArch ? config.nvhpcArch or "px", additionalCommands ? "",
nvhpc, lmod, mkl, gfortran, rsync, which, hdf5, wannier90, zlib
}:
let
sources = import ../source.nix { inherit requireFile; };
buildEnv = buildFHSEnv
{
name = "buildEnv";
targetPkgs = _: [ zlib ];
};
buildScript = writeScript "build"
''
. ${lmod}/share/lmod/lmod/init/bash
module use ${nvhpc}/share/nvhpc/modulefiles
module load nvhpc
mkdir -p bin
make DEPS=1 -j$NIX_BUILD_CORES
'';
include = version: substituteAll
{
src = ./makefile.include-${version};
cudaCapabilities = builtins.concatStringsSep "," (builtins.map
(cap: "cc${builtins.replaceStrings ["."] [""] cap}")
cudaCapabilities);
inherit nvhpcArch;
};
vasp = version: stdenvNoCC.mkDerivation rec
{
pname = "vasp-nvidia";
inherit version;
src = sources.${version};
configurePhase =
''
cp ${include version} makefile.include
cp ${../constr_cell_relax.F} src/constr_cell_relax.F
'';
enableParallelBuilding = true;
buildInputs = [ mkl hdf5 wannier90 ];
nativeBuildInputs = [ gfortran rsync which ];
MKLROOT = mkl;
HDF5_ROOT = hdf5;
WANNIER90_ROOT = wannier90;
buildPhase = "${buildEnv}/bin/buildEnv ${buildScript}";
installPhase =
''
mkdir -p $out/bin
for i in std gam ncl; do cp bin/vasp_$i $out/bin/vasp-$i; done
'';
dontFixup = true;
requiredSystemFeatures = [ "gccarch-exact-${stdenvNoCC.hostPlatform.gcc.arch}" "big-parallel" ];
};
startScript = { version, variant }: writeScript "vasp-nvidia-${version}"
''
. ${lmod}/share/lmod/lmod/init/bash
module use ${nvhpc}/share/nvhpc/modulefiles
module load nvhpc
# if OMP_NUM_THREADS is not set, set it according to SLURM_CPUS_PER_TASK or to 1
if [ -z "''${OMP_NUM_THREADS-}" ]; then
if [ -n "''${SLURM_CPUS_PER_TASK-}" ]; then
OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
else
OMP_NUM_THREADS=1
fi
fi
export OMP_NUM_THREADS
${additionalCommands}
${
if variant == "env" then ''exec "$@"''
else
''
if [ -n "''${SLURM_JOB_ID-}" ]; then
exec mpirun --bind-to none ${vasp version}/bin/vasp-${variant}
else
exec mpirun -np 1 ${vasp version}/bin/vasp-${variant}
fi
''
}
'';
runEnv = { version, variant }: let shortVersion = builtins.replaceStrings ["."] [""] version; in buildFHSEnv
{
name = "vasp-nvidia-${shortVersion}${if variant == "" then "" else "-${variant}"}";
targetPkgs = _: [ zlib (vasp version) ];
runScript = startScript { inherit version; variant = if variant == "" then "std" else variant; };
};
in builtins.mapAttrs
(version: _: symlinkJoin
{
name = "vasp-nvidia-${version}";
paths = builtins.map (variant: runEnv { inherit version variant; }) [ "" "env" "std" "gam" "ncl" ];
})
sources

View File

@@ -1,109 +0,0 @@
# Default precompiler options
CPP_OPTIONS = -DHOST=\"LinuxNV\" \
-DMPI -DMPI_BLOCK=8000 -Duse_collective \
-DscaLAPACK \
-DCACHE_SIZE=4000 \
-Davoidalloc \
-Dvasp6 \
-Duse_bse_te \
-Dtbdyn \
-Dqd_emulate \
-Dfock_dblbuf \
-D_OPENMP \
-D_OPENACC \
-DUSENCCL -DUSENCCLP2P -Duse_shmem -Dshmem_bcast_buffer -Dshmem_rproj
CPP = nvfortran -Mpreprocess -Mfree -Mextend -E $(CPP_OPTIONS) $*$(FUFFIX) > $*$(SUFFIX)
# N.B.: you might need to change the cuda-version here
# to one that comes with your NVIDIA-HPC SDK
FC = mpif90 -acc -gpu=@cudaCapabilities@ -mp
FCL = mpif90 -acc -gpu=@cudaCapabilities@ -mp -c++libs
FREE = -Mfree
FFLAGS = -Mbackslash -Mlarge_arrays
OFLAG = -fast
DEBUG = -Mfree -O0 -traceback
OBJECTS = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o
LLIBS = -cudalib=cublas,cusolver,cufft,nccl -cuda
# Redefine the standard list of O1 and O2 objects
SOURCE_O1 := pade_fit.o
SOURCE_O2 := pead.o
# For what used to be vasp.5.lib
CPP_LIB = $(CPP)
FC_LIB = nvfortran
CC_LIB = nvc -w
CFLAGS_LIB = -O
FFLAGS_LIB = -O1 -Mfixed
FREE_LIB = $(FREE)
OBJECTS_LIB = linpack_double.o getshmem.o
# For the parser library
CXX_PARS = nvc++ --no_warnings
##
## Customize as of this point! Of course you may change the preceding
## part of this file as well if you like, but it should rarely be
## necessary ...
##
# When compiling on the target machine itself , change this to the
# relevant target when cross-compiling for another architecture
VASP_TARGET_CPU ?= -tp=@nvhpcArch@
FFLAGS += $(VASP_TARGET_CPU)
# Specify your NV HPC-SDK installation (mandatory)
#... first try to set it automatically
NVROOT =$(shell which nvfortran | awk -F /compilers/bin/nvfortran '{ print $$1 }')
# If the above fails, then NVROOT needs to be set manually
#NVHPC ?= /opt/nvidia/hpc_sdk
#NVVERSION = 21.11
#NVROOT = $(NVHPC)/Linux_x86_64/$(NVVERSION)
## Improves performance when using NV HPC-SDK >=21.11 and CUDA >11.2
OFLAG_IN = -fast -Mwarperf
SOURCE_IN := nonlr.o
# Software emulation of quadruple precsion (mandatory)
QD ?= $(NVROOT)/compilers/extras/qd
LLIBS += -L$(QD)/lib -lqdmod -lqd
INCS += -I$(QD)/include/qd
# Intel MKL for FFTW, BLAS, LAPACK, and scaLAPACK
MKLROOT ?= /path/to/your/mkl/installation
LLIBS_MKL = -Mmkl -L$(MKLROOT)/lib -lmkl_scalapack_lp64 -lmkl_blacs_openmpi_lp64
INCS += -I$(MKLROOT)/include/fftw
# Use a separate scaLAPACK installation (optional but recommended in combination with OpenMPI)
# Comment out the two lines below if you want to use scaLAPACK from MKL instead
# SCALAPACK_ROOT ?= /path/to/your/scalapack/installation
# LLIBS_MKL = -L$(SCALAPACK_ROOT)/lib -lscalapack -Mmkl
LLIBS += $(LLIBS_MKL)
# HDF5-support (optional but strongly recommended)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT ?= /path/to/your/hdf5/installation
LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS += -I$(HDF5_ROOT)/include
# For the VASP-2-Wannier90 interface (optional)
CPP_OPTIONS += -DVASP2WANNIER90
WANNIER90_ROOT ?= /path/to/your/wannier90/installation
LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier
# For the fftlib library (hardly any benefit for the OpenACC GPU port, especially in combination with MKL's FFTs)
#CPP_OPTIONS+= -Dsysv
#FCL += fftlib.o
#CXX_FFTLIB = nvc++ -mp --no_warnings -std=c++11 -DFFTLIB_USE_MKL -DFFTLIB_THREADSAFE
#INCS_FFTLIB = -I./include -I$(MKLROOT)/include/fftw
#LIBS += fftlib
#LLIBS += -ldl

View File

@@ -1,109 +0,0 @@
# Default precompiler options
CPP_OPTIONS = -DHOST=\"LinuxNV\" \
-DMPI -DMPI_INPLACE -DMPI_BLOCK=8000 -Duse_collective \
-DscaLAPACK \
-DCACHE_SIZE=4000 \
-Davoidalloc \
-Dvasp6 \
-Duse_bse_te \
-Dtbdyn \
-Dqd_emulate \
-Dfock_dblbuf \
-D_OPENMP \
-D_OPENACC \
-DUSENCCL -DUSENCCLP2P -Duse_shmem -Dshmem_bcast_buffer -Dshmem_rproj
CPP = nvfortran -Mpreprocess -Mfree -Mextend -E $(CPP_OPTIONS) $*$(FUFFIX) > $*$(SUFFIX)
# N.B.: you might need to change the cuda-version here
# to one that comes with your NVIDIA-HPC SDK
FC = mpif90 -acc -gpu=@cudaCapabilities@ -mp
FCL = mpif90 -acc -gpu=@cudaCapabilities@ -mp -c++libs
FREE = -Mfree
FFLAGS = -Mbackslash -Mlarge_arrays
OFLAG = -fast
DEBUG = -Mfree -O0 -traceback
OBJECTS = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o
LLIBS = -cudalib=cublas,cusolver,cufft,nccl -cuda
# Redefine the standard list of O1 and O2 objects
SOURCE_O1 := pade_fit.o minimax_dependence.o
SOURCE_O2 := pead.o
# For what used to be vasp.5.lib
CPP_LIB = $(CPP)
FC_LIB = nvfortran
CC_LIB = nvc -w
CFLAGS_LIB = -O
FFLAGS_LIB = -O1 -Mfixed
FREE_LIB = $(FREE)
OBJECTS_LIB = linpack_double.o getshmem.o
# For the parser library
CXX_PARS = nvc++ --no_warnings
##
## Customize as of this point! Of course you may change the preceding
## part of this file as well if you like, but it should rarely be
## necessary ...
##
# When compiling on the target machine itself , change this to the
# relevant target when cross-compiling for another architecture
VASP_TARGET_CPU ?= -tp=@nvhpcArch@
FFLAGS += $(VASP_TARGET_CPU)
# Specify your NV HPC-SDK installation (mandatory)
#... first try to set it automatically
NVROOT =$(shell which nvfortran | awk -F /compilers/bin/nvfortran '{ print $$1 }')
# If the above fails, then NVROOT needs to be set manually
#NVHPC ?= /opt/nvidia/hpc_sdk
#NVVERSION = 21.11
#NVROOT = $(NVHPC)/Linux_x86_64/$(NVVERSION)
## Improves performance when using NV HPC-SDK >=21.11 and CUDA >11.2
OFLAG_IN = -fast -Mwarperf
SOURCE_IN := nonlr.o
# Software emulation of quadruple precsion (mandatory)
QD ?= $(NVROOT)/compilers/extras/qd
LLIBS += -L$(QD)/lib -lqdmod -lqd
INCS += -I$(QD)/include/qd
# Intel MKL for FFTW, BLAS, LAPACK, and scaLAPACK
MKLROOT ?= /path/to/your/mkl/installation
LLIBS_MKL = -Mmkl -L$(MKLROOT)/lib -lmkl_scalapack_lp64 -lmkl_blacs_openmpi_lp64
INCS += -I$(MKLROOT)/include/fftw
# Use a separate scaLAPACK installation (optional but recommended in combination with OpenMPI)
# Comment out the two lines below if you want to use scaLAPACK from MKL instead
# SCALAPACK_ROOT ?= /path/to/your/scalapack/installation
# LLIBS_MKL = -L$(SCALAPACK_ROOT)/lib -lscalapack -Mmkl
LLIBS += $(LLIBS_MKL)
# HDF5-support (optional but strongly recommended)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT ?= /path/to/your/hdf5/installation
LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS += -I$(HDF5_ROOT)/include
# For the VASP-2-Wannier90 interface (optional)
CPP_OPTIONS += -DVASP2WANNIER90
WANNIER90_ROOT ?= /path/to/your/wannier90/installation
LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier
# For the fftlib library (hardly any benefit for the OpenACC GPU port, especially in combination with MKL's FFTs)
#CPP_OPTIONS+= -Dsysv
#FCL += fftlib.o
#CXX_FFTLIB = nvc++ -mp --no_warnings -std=c++11 -DFFTLIB_USE_MKL -DFFTLIB_THREADSAFE
#INCS_FFTLIB = -I./include -I$(MKLROOT)/include/fftw
#LIBS += fftlib
#LLIBS += -ldl

View File

@@ -1,45 +0,0 @@
{
lib, buildFHSEnv, writeScript, stdenvNoCC,
openmpi,
aocc, cmake, libnl, pmix, libpsm2, libfabric, zlib, numactl, ucx, ucc, libevent, hwloc, rdma-core, perl, glibc, binutils, gcc
}:
let
buildEnv = buildFHSEnv
{
name = "buildEnv";
targetPkgs = _: [ zlib aocc gcc.cc.lib.lib glibc.dev binutils.bintools libnl numactl ucx ucc libevent hwloc rdma-core libpsm2 libfabric perl ];
extraBwrapArgs = [ "--bind" "$out" "$out" ];
};
buildScript = writeScript "build"
''
./configure --prefix=$out --disable-mca-dso
make -j$NIX_BUILD_CORES
make install
'';
in stdenvNoCC.mkDerivation
{
name = "openmpi-aocc";
inherit (openmpi) src postPatch;
dontConfigure = true;
CC = "clang";
CXX = "clang++";
FC = "flang";
OMPI_CC = "clang";
OMPI_CXX = "clang++";
OMPI_FC = "flang";
CFLAGS = "-march=${stdenvNoCC.hostPlatform.gcc.arch} -O2";
CXXFLAGS = "-march=${stdenvNoCC.hostPlatform.gcc.arch} -O2";
FCFLAGS = "-march=${stdenvNoCC.hostPlatform.gcc.arch} -O2";
enableParallelBuilding = true;
buildPhase =
''
runHook preBuild
mkdir -p $out
${buildEnv}/bin/buildEnv ${buildScript}
runHook postBuild
'';
postBuild = with openmpi; postInstall + postFixup;
dontInstall = true;
dontFixup = true;
requiredSystemFeatures = [ "gccarch-exact-${stdenvNoCC.hostPlatform.gcc.arch}" "big-parallel" ];
}

View File

@@ -1,16 +0,0 @@
{ requireFile }:
let
hashes =
{
# nix-store --query --hash $(nix store add-path ./vasp-6.4.0)
"6.3.1" = "1xdr5kjxz6v2li73cbx1ls5b1lnm6z16jaa4fpln7d3arnnr1mgx";
"6.4.0" = "189i1l5q33ynmps93p2mwqf5fx7p4l50sls1krqlv8ls14s3m71f";
};
sources = version: sha256: requireFile
{
name = "vasp-${version}";
inherit sha256;
hashMode = "recursive";
message = "Source file not found.";
};
in builtins.mapAttrs sources hashes

View File

@@ -7,15 +7,15 @@ let
hashMode = "recursive";
message = "POTCAR not found.";
};
unwrapped = stdenv.mkDerivation rec
unwrapped = stdenv.mkDerivation
{
pname = "vaspkit-unwrapped";
version = "1.5.1";
version = "1.4.1";
buildInputs = [ autoPatchelfHook stdenv.cc.cc ];
src = fetchurl
{
url = "mirror://sourceforge/vaspkit/Binaries/vaspkit.${version}.linux.x64.tar.gz";
sha256 = "1cbj1mv7vx18icwlk9d2vfavsfd653943xg2ywzd8b7pb43xrfs1";
url = "mirror://sourceforge/vaspkit/Binaries/vaspkit.1.4.1.linux.x64.tar.gz";
sha256 = "0i5m7nbvqk7hzxisyydjvs2l8lnvj9vsxa170783kv9zmp51lnvs";
};
installPhase =
''

View File

@@ -1,20 +0,0 @@
{ lib, stdenv, src }: stdenv.mkDerivation
{
name = "win11os-kde";
inherit src;
installPhase =
''
mkdir -p $out/share/aurorae/themes
cp -r $src/aurorae/* $out/share/aurorae/themes
mkdir -p $out/share/color-schemes
cp -r $src/color-schemes/*.colors $out/share/color-schemes
mkdir -p $out/share/Kvantum
cp -r $src/Kvantum/* $out/share/Kvantum
mkdir -p $out/share/plasma/desktoptheme
cp -r $src/plasma/desktoptheme/* $out/share/plasma/desktoptheme
mkdir -p $out/share/plasma/look-and-feel
cp -r $src/plasma/look-and-feel/* $out/share/plasma/look-and-feel
mkdir -p $out/share/wallpapers
cp -r $src/wallpaper/* $out/share/wallpapers
'';
}

View File

@@ -13,8 +13,6 @@ inputs:
topInputs.nur.nixosModules.nur
topInputs.nur-xddxdd.nixosModules.setupOverlay
topInputs.impermanence.nixosModules.impermanence
topInputs.nix-flatpak.nixosModules.nix-flatpak
topInputs.chaotic.nixosModules.default
(inputs:
{
config =
@@ -23,9 +21,12 @@ inputs:
[
topInputs.qchem.overlays.default
topInputs.nixd.overlays.default
topInputs.nix-alien.overlays.default
topInputs.napalm.overlays.default
topInputs.pnpm2nix-nzbr.overlays.default
topInputs.lmix.overlays.default
topInputs.aagl.overlays.default
(import "${topInputs.dguibert-nur-packages}/overlays/nvhpc-overlay")
(final: prev:
{
nix-vscode-extensions = topInputs.nix-vscode-extensions.extensions."${prev.system}";
@@ -33,8 +34,9 @@ inputs:
nur-linyinfeng = (topInputs.nur-linyinfeng.overlays.default final prev).linyinfeng;
deploy-rs =
{ inherit (prev) deploy-rs; inherit ((topInputs.deploy-rs.overlay final prev).deploy-rs) lib; };
firefox-addons = (import "${topInputs.rycee}" { inherit (prev) pkgs; }).firefox-addons;
inherit (import topInputs.gricad { pkgs = final; }) intel-oneapi intel-oneapi-2022;
# needed by mirism
nghttp2-2305 =
inputs.pkgs.callPackage "${inputs.topInputs.nixpkgs-2305}/pkgs/development/libraries/nghttp2" {};
})
];
home-manager.sharedModules =
@@ -44,6 +46,6 @@ inputs:
];
};
})
./hardware ./packages ./system ./virtualization ./services ./bugs ./user
./hardware ./packages ./system ./virtualization ./services ./bugs ./users
];
}

View File

@@ -1,75 +1,228 @@
inputs:
{
imports = inputs.localLib.findModules ./.;
imports = inputs.localLib.mkModules [ ./legion.nix ];
options.nixos.hardware = let inherit (inputs.lib) mkOption types; in
{
bluetooth = mkOption { type = types.nullOr (types.submodule {}); default = {}; };
joystick = mkOption { type = types.nullOr (types.submodule {}); default = {}; };
printer = mkOption { type = types.nullOr (types.submodule {}); default = {}; };
sound = mkOption { type = types.nullOr (types.submodule {}); default = {}; };
bluetooth.enable = mkOption { type = types.bool; default = false; };
joystick.enable = mkOption { type = types.bool; default = false; };
printer.enable = mkOption { type = types.bool; default = false; };
sound.enable = mkOption { type = types.bool; default = false; };
cpus = mkOption { type = types.listOf (types.enum [ "intel" "amd" ]); default = []; };
gpus = mkOption { type = types.listOf (types.enum [ "intel" "nvidia" "amd" ]); default = []; };
prime =
{
enable = mkOption { type = types.bool; default = false; };
mode = mkOption { type = types.enum [ "offload" "sync" ]; default = "offload"; };
busId = mkOption { type = types.attrsOf types.str; default = {}; };
};
gamemode.drmDevice = mkOption { type = types.int; default = 0; };
halo-keyboard.enable = mkOption { type = types.bool; default = false; };
};
config = let inherit (inputs.config.nixos) hardware; in inputs.lib.mkMerge
[
# bluetooth
(inputs.lib.mkIf (hardware.bluetooth != null) { hardware.bluetooth.enable = true; })
# joystick
(inputs.lib.mkIf (hardware.joystick != null) { hardware = { xone.enable = true; xpadneo.enable = true; }; })
# printer
(
inputs.lib.mkIf (hardware.printer != null)
{
services =
config =
let
inherit (inputs.lib) mkMerge mkIf;
inherit (inputs.config.nixos) hardware;
inherit (builtins) listToAttrs map concatLists;
inherit (inputs.localLib) attrsToList;
in mkMerge
[
# bluetooth
(mkIf hardware.bluetooth.enable { hardware.bluetooth.enable = true; })
# joystick
(mkIf hardware.joystick.enable { hardware = { xone.enable = true; xpadneo.enable = true; }; })
# printer
(
mkIf hardware.printer.enable
{
printing =
services =
{
enable = true;
drivers = inputs.lib.mkIf (inputs.config.nixos.system.nixpkgs.arch == "x86_64") [ inputs.pkgs.cnijfilter2 ];
printing = { enable = true; drivers = [ inputs.pkgs.cnijfilter2 ]; };
avahi = { enable = true; nssmdns = true; openFirewall = true; };
};
avahi = { enable = true; nssmdns = true; openFirewall = true; };
};
}
)
# sound
(
inputs.lib.mkIf (hardware.sound != null)
{
hardware.pulseaudio.enable = false;
services.pipewire = { enable = true; alsa = { enable = true; support32Bit = true; }; pulse.enable = true; };
sound.enable = true;
security.rtkit.enable = true;
environment.etc."wireplumber/main.lua.d/50-alsa-config.lua".text =
let
content = builtins.readFile
(inputs.pkgs.wireplumber + "/share/wireplumber/main.lua.d/50-alsa-config.lua");
matched = builtins.match
".*\n([[:space:]]*)(--\\[\"session\\.suspend-timeout-seconds\"][^\n]*)[\n].*" content;
spaces = builtins.elemAt matched 0;
comment = builtins.elemAt matched 1;
config = ''["session.suspend-timeout-seconds"] = 0'';
in
builtins.replaceStrings [(spaces + comment)] [(spaces + config)] content;
}
)
# cpus
(
inputs.lib.mkIf (hardware.cpus != [])
{
hardware.cpu = builtins.listToAttrs
(map (name: { inherit name; value = { updateMicrocode = true; }; }) hardware.cpus);
boot.initrd.availableKernelModules =
let
modules =
}
)
# sound
(
mkIf hardware.sound.enable
{
hardware.pulseaudio.enable = false;
services.pipewire = { enable = true; alsa = { enable = true; support32Bit = true; }; pulse.enable = true; };
sound.enable = true;
security.rtkit.enable = true;
environment.etc."wireplumber/main.lua.d/50-alsa-config.lua".text =
let
content = builtins.readFile
(inputs.pkgs.wireplumber + "/share/wireplumber/main.lua.d/50-alsa-config.lua");
matched = builtins.match
".*\n([[:space:]]*)(--\\[\"session\\.suspend-timeout-seconds\"][^\n]*)[\n].*" content;
spaces = builtins.elemAt matched 0;
comment = builtins.elemAt matched 1;
config = ''["session.suspend-timeout-seconds"] = 0'';
in
builtins.replaceStrings [(spaces + comment)] [(spaces + config)] content;
}
)
# cpus
(
mkIf (hardware.cpus != [])
{
hardware.cpu = listToAttrs
(map (name: { inherit name; value = { updateMicrocode = true; }; }) hardware.cpus);
boot.initrd.availableKernelModules =
let
modules =
{
intel =
[
"intel_cstate" "aesni_intel" "intel_cstate" "intel_uncore" "intel_uncore_frequency" "intel_powerclamp"
];
amd = [];
};
in
concatLists (map (cpu: modules.${cpu}) hardware.cpus);
}
)
# gpus
(
mkIf (hardware.gpus != [])
{
boot.initrd.availableKernelModules =
let
modules =
{
intel = [ "i915" ];
nvidia = [ "nvidia" "nvidia_drm" "nvidia_modeset" "nvidia_uvm" ];
amd = [ "amdgpu" ];
};
in
concatLists (map (gpu: modules.${gpu}) hardware.gpus);
hardware =
{
opengl =
{
intel =
[
"intel_cstate" "aesni_intel" "intel_cstate" "intel_uncore" "intel_uncore_frequency" "intel_powerclamp"
];
amd = [];
enable = true;
driSupport = true;
extraPackages =
with inputs.pkgs;
let
packages =
{
intel = [ intel-compute-runtime intel-media-driver libvdpau-va-gl ]; # intel-vaapi-driver
nvidia = [ vaapiVdpau ];
amd = [ amdvlk rocmPackages.clr rocmPackages.clr.icd ];
};
in
concatLists (map (gpu: packages.${gpu}) hardware.gpus);
driSupport32Bit = true;
};
in
builtins.concatLists (map (cpu: modules.${cpu}) hardware.cpus);
}
)
];
nvidia = mkIf (builtins.elem "nvidia" hardware.gpus)
{
modesetting.enable = true;
powerManagement.enable = true;
dynamicBoost.enable = true;
nvidiaSettings = true;
package = inputs.config.boot.kernelPackages.nvidiaPackages.production;
};
};
}
)
(mkIf (builtins.elem "intel" hardware.gpus) { services.xserver.videoDrivers = [ "modesetting" ]; })
(mkIf (builtins.elem "amd" hardware.gpus) { services.xserver.videoDrivers = [ "modesetting" ]; })
# prime
(
mkIf hardware.prime.enable
{
hardware.nvidia = mkMerge
[
(
mkIf (hardware.prime.mode == "offload")
{
prime.offload = { enable = true; enableOffloadCmd = true; };
powerManagement = { finegrained = true; enable = true; };
}
)
(
mkIf (hardware.prime.mode == "sync")
{
prime = { sync.enable = true; };
# prime.forceFullCompositionPipeline = true;
}
)
{
prime = listToAttrs
(map (gpu: { inherit (gpu) value; name = "${gpu.name}BusId"; }) (attrsToList hardware.prime.busId));
}
];
}
)
{ programs.gamemode.settings.gpu.gpu_device = "${toString hardware.gamemode.drmDevice}"; }
# halo-keyboard
(mkIf hardware.halo-keyboard.enable
(
let
keyboard = inputs.pkgs.localPackages.chromiumos-touch-keyboard;
support = inputs.pkgs.localPackages.yoga-support;
in
{
services.udev.packages = [ keyboard support ];
systemd.services =
{
touch-keyboard-handler.serviceConfig =
{
Type = "simple";
WorkingDirectory = "/etc/touch_keyboard";
ExecStart = "${keyboard}/bin/touch_keyboard_handler";
};
yogabook-modes-handler.serviceConfig =
{
Type = "simple";
ExecStart = "${support}/bin/yogabook-modes-handler";
StandardOutput = "journal";
};
monitor-sensor =
{
wantedBy = [ "default.target" ];
serviceConfig =
{
Type = "simple";
ExecStart = "${inputs.pkgs.iio-sensor-proxy}/bin/monitor-sensor --hinge";
};
};
};
environment.etc."touch_keyboard".source = "${keyboard}/etc/touch_keyboard";
boot.initrd =
{
services.udev.packages = [ keyboard support ];
systemd =
{
extraBin =
{
touch_keyboard_handler = "${keyboard}/bin/touch_keyboard_handler";
yogabook-modes-handler = "${support}/bin/yogabook-modes-handler";
};
services =
{
touch-keyboard-handler =
{
serviceConfig =
{
Type = "simple";
WorkingDirectory = "/etc/touch_keyboard";
ExecStart = "${keyboard}/bin/touch_keyboard_handler";
};
};
yogabook-modes-handler.serviceConfig =
{
Type = "simple";
ExecStart = "${support}/bin/yogabook-modes-handler";
StandardOutput = "journal";
};
};
};
extraFiles."/etc/touch_keyboard".source = "${keyboard}/etc/touch_keyboard";
};
}
))
];
}

View File

@@ -1,95 +0,0 @@
inputs:
{
options.nixos.hardware.gpu = let inherit (inputs.lib) mkOption types; in
{
type = mkOption
{
type = types.nullOr (types.enum
[
# single gpu
"intel" "nvidia" "amd"
# hibrid gpu: use nvidia prime offload mode
"intel+nvidia" "amd+nvidia"
]);
default = null;
};
dynamicBoost = mkOption { type = types.bool; default = false; };
prime =
{
mode = mkOption { type = types.enum [ "offload" "sync" ]; default = "offload"; };
busId = mkOption { type = types.attrsOf types.nonEmptyStr; default = {}; };
};
};
config = let inherit (inputs.config.nixos.hardware) gpu; in inputs.lib.mkIf (gpu.type != null) (inputs.lib.mkMerge
[
# generic settings
(
let gpus = inputs.lib.strings.splitString "+" gpu.type; in
{
boot.initrd.availableKernelModules =
let modules =
{
intel = [ "i915" ];
nvidia = [ "nvidia" "nvidia_drm" "nvidia_modeset" ]; # nvidia-uvm should not be loaded
amd = [ "amdgpu" ];
};
in builtins.concatLists (builtins.map (gpu: modules.${gpu}) gpus);
hardware =
{
opengl =
{
enable = true;
driSupport = true;
driSupport32Bit = true;
extraPackages =
let packages = with inputs.pkgs;
{
intel = [ intel-vaapi-driver libvdpau-va-gl intel-media-driver ];
nvidia = [ vaapiVdpau ];
amd = [ amdvlk rocmPackages.clr rocmPackages.clr.icd ];
};
in builtins.concatLists (builtins.map (gpu: packages.${gpu}) gpus);
extraPackages32 =
let packages = { intel = []; nvidia = []; amd = [ inputs.pkgs.driversi686Linux.amdvlk ]; };
in builtins.concatLists (builtins.map (gpu: packages.${gpu}) gpus);
};
nvidia = inputs.lib.mkIf (builtins.elem "nvidia" gpus)
{
modesetting.enable = true;
powerManagement.enable = true;
dynamicBoost.enable = inputs.lib.mkIf gpu.dynamicBoost true;
nvidiaSettings = true;
forceFullCompositionPipeline = true;
# package = inputs.config.boot.kernelPackages.nvidiaPackages.production;
prime.allowExternalGpu = true;
};
};
boot =
{
kernelParams = inputs.lib.mkIf (builtins.elem "amd" gpus)
[ "radeon.cik_support=0" "amdgpu.cik_support=1" "radeon.si_support=0" "amdgpu.si_support=1" "iommu=pt" ];
blacklistedKernelModules = [ "nouveau" ];
};
environment.variables.VDPAU_DRIVER = inputs.lib.mkIf (builtins.elem "intel" gpus) "va_gl";
services.xserver.videoDrivers =
let driver = { intel = "modesetting"; amd = "amdgpu"; nvidia = "nvidia"; };
in builtins.map (gpu: driver.${gpu}) gpus;
}
)
# nvidia prime offload
(
inputs.lib.mkIf (inputs.lib.strings.hasSuffix "+nvidia" gpu.type) { hardware.nvidia =
{
prime =
{
offload = inputs.lib.mkIf (gpu.prime.mode == "offload") { enable = true; enableOffloadCmd = true; };
sync = inputs.lib.mkIf (gpu.prime.mode == "sync") { enable = true; };
}
// builtins.listToAttrs (builtins.map
(gpu: { name = "${if gpu.name == "amd" then "amdgpu" else gpu.name}BusId"; value = "PCI:${gpu.value}"; })
(inputs.localLib.attrsToList gpu.prime.busId));
powerManagement.finegrained = inputs.lib.mkIf (gpu.prime.mode == "offload") true;
};}
)
]);
}

View File

@@ -1,10 +1,16 @@
inputs:
{
options.nixos.hardware.legion = let inherit (inputs.lib) mkOption types; in mkOption
{ type = types.nullOr (types.submodule {}); default = null; };
config = let inherit (inputs.config.nixos.hardware) legion; in inputs.lib.mkIf (legion != null)
options.nixos.hardware.legion = let inherit (inputs.lib) mkOption types; in
{
environment.systemPackages = [ inputs.pkgs.lenovo-legion ];
boot.extraModulePackages = [ inputs.config.boot.kernelPackages.lenovo-legion-module ];
enable = mkOption { type = types.bool; default = false; };
};
config =
let
inherit (inputs.lib) mkIf;
inherit (inputs.config.nixos.hardware) legion;
in mkIf legion.enable
{
environment.systemPackages = [ inputs.pkgs.lenovo-legion ];
boot.extraModulePackages = [ inputs.config.boot.kernelPackages.lenovo-legion-module ];
};
}

View File

@@ -1,6 +1,12 @@
inputs:
{
imports = inputs.localLib.findModules ./.;
imports = inputs.localLib.mkModules
[
./server
./desktop
./desktop-fat
./workstation
];
options.nixos.packages =
let
inherit (inputs.lib) mkOption types;

View File

@@ -3,17 +3,14 @@ inputs:
config =
let
inherit (inputs.lib) mkIf;
in mkIf (builtins.elem "desktop" inputs.config.nixos.packages._packageSets)
in mkIf (builtins.elem "desktop-fat" inputs.config.nixos.packages._packageSets)
{
programs.chromium = { enable = true; extraOpts.PasswordManagerEnabled = false; };
nixos.user.sharedModules =
nixos.users.sharedModules =
[{
config.programs.chromium =
{
enable = true;
extensions =
# TODO: declartive way to install extensions, with fixed xpi file
# TODO: declartively config
[
{ id = "mpkodccbngfoacfalldjimigbofkhgjn"; } # Aria2 Explorer
{ id = "nngceckbapebfimnlniiiahkandclblb"; } # Bitwarden

View File

@@ -1,6 +1,10 @@
inputs:
{
imports = inputs.localLib.findModules ./.;
imports = inputs.localLib.mkModules
[
./chromium.nix
./steam.nix
];
config =
let
inherit (inputs.lib) mkIf;
@@ -13,7 +17,7 @@ inputs:
_packages =
[
# system management
etcher btrfs-assistant snapper-gui libsForQt5.qtstyleplugin-kvantum ventoy-full cpu-x
etcher btrfs-assistant snapper-gui libsForQt5.qtstyleplugin-kvantum ventoy-full
# password and key management
yubikey-manager yubikey-manager-qt yubikey-personalization yubikey-personalization-gui bitwarden
# download
@@ -24,7 +28,7 @@ inputs:
spotify yesplaymusic simplescreenrecorder imagemagick gimp netease-cloud-music-gtk vlc obs-studio
waifu2x-converter-cpp inkscape blender
# editor
unstablePackages.typora
localPackages.typora
# themes
orchis-theme plasma-overdose-kde-theme materia-kde-theme graphite-kde-theme arc-kde-theme materia-theme
# news
@@ -39,7 +43,6 @@ inputs:
# office
crow-translate zotero pandoc ydict libreoffice-qt texstudio poppler_utils pdftk gnuplot pdfchain hdfview
(texlive.combine { inherit (texlive) scheme-full; inherit (localPackages) citation-style-language; })
nextcloud-client
# math, physics and chemistry
octaveFull root ovito localPackages.vesta localPackages.vaspkit localPackages.v-sim
] ++ (with inputs.lib; filter isDerivation (attrValues plasma5Packages.kdeGear));

View File

@@ -1,6 +1,6 @@
inputs:
{
imports = inputs.localLib.findModules ./.;
imports = inputs.localLib.mkModules [ ./vscode.nix ];
config =
let
inherit (inputs.lib) mkIf;
@@ -17,7 +17,7 @@ inputs:
''
#!${bash}/bin/bash
if [ "$XDG_SESSION_TYPE" = "x11" ]; then
exec ${xclip}/bin/xclip -sel clip "$@"
exec ${xclip}/bin/xclip "$@"
else
exec ${wl-clipboard-x11}/bin/xclip "$@"
fi
@@ -30,22 +30,23 @@ inputs:
# media
mpv nomacs
# themes
tela-circle-icon-theme localPackages.win11os-kde localPackages.fluent-kde localPackages.blurred-wallpaper
localPackages.slate utterly-nord-plasma
# terminal
unstablePackages.warp-terminal
# development
adb-sync
# virtual keyboard
localPackages.kylin-virtual-keyboard
tela-circle-icon-theme
];
users.sharedModules =
[{
config.home.file.".config/baloofilerc".text =
''
[Basic Settings]
Indexing-Enabled=false
'';
}];
};
programs =
{
adb.enable = true;
wireshark = { enable = true; package = inputs.pkgs.wireshark; };
firefox = { enable = true; languagePacks = [ "zh-CN" "en-US" ]; };
vim.package = inputs.pkgs.vim-full;
yubikey-touch-detector.enable = true;
};
nixpkgs.config.packageOverrides = pkgs:
{

View File

@@ -1,59 +0,0 @@
inputs:
{
config = inputs.lib.mkIf (builtins.elem "desktop" inputs.config.nixos.packages._packageSets)
{
nixos.user.sharedModules = [{ config =
{
programs.firefox =
{
enable = true;
# TODO: switch to 24.05
# nativeMessagingHosts = [ inputs.pkgs.plasma-browser-integration ];
# TODO: switch to chromium as default browser
package = inputs.pkgs.firefox.override { nativeMessagingHosts = [ inputs.pkgs.plasma-browser-integration ]; };
policies.DefaultDownloadDirectory = "\${home}/Downloads";
profiles.default =
{
extensions = with inputs.pkgs.firefox-addons;
[
immersive-translate tampermonkey bitwarden cookies-txt dualsub firefox-color i-dont-care-about-cookies
metamask pakkujs switchyomega rsshub-radar rsspreview tabliss tree-style-tab ublock-origin wallabagger
wappalyzer grammarly plasma-integration
(
buildFirefoxXpiAddon rec
{
pname = "zotero-connector";
version = "5.0.119";
addonId = "zotero@chnm.gmu.edu";
url = "https://download.zotero.org/connector/firefox/release/Zotero_Connector-${version}.xpi";
sha256 = "17yhkp5nrx325q3amlasb4nsw0bldm8i2i9fh8ql2hwj8fmy25mr";
meta = {};
}
)
];
search = { default = "Google"; force = true; };
userChrome = builtins.readFile "${inputs.topInputs.lepton}/userChrome.css";
userContent = builtins.readFile "${inputs.topInputs.lepton}/userContent.css";
extraConfig = builtins.readFile "${inputs.topInputs.lepton}/user.js";
settings =
{
# general
"browser.search.region" = "CN";
"intl.locale.requested" = "zh-CN,en-US";
"browser.aboutConfig.showWarning" = false;
"browser.bookmarks.showMobileBookmarks" = true;
"browser.download.panel.shown" = true;
"browser.download.useDownloadDir" = true;
"browser.newtab.extensionControlled" = true;
"browser.toolbars.bookmarks.visibility" = "never";
# allow to apply userChrome.css
"toolkit.legacyUserProfileCustomizations.stylesheets" = true;
};
};
};
home.file.".mozilla/firefox/profiles.ini".force = true;
};}];
# still enable global firefox, to install language packs
programs.firefox = { enable = true; languagePacks = [ "zh-CN" "en-US" ]; };
};
}

View File

@@ -1,98 +0,0 @@
inputs:
{
imports = inputs.localLib.findModules ./.;
config.nixos.user.sharedModules = inputs.lib.mkIf inputs.config.nixos.system.gui.enable
[{
config.programs.plasma = inputs.lib.mkMerge
[
# TODO: autostart, panel, discard user changed settings
# general
{
enable = true;
configFile.plasma-localerc = { Formats.LANG = "en_US.UTF-8"; Translations.LANGUAGE = "zh_CN"; };
}
# kwin
{
kwin.titlebarButtons =
{
right = [ "help" "keep-below-windows" "keep-above-windows" "minimize" "maximize" "close" ];
left = [ "more-window-actions" ];
};
windows.allowWindowsToRememberPositions = false;
configFile =
{
plasmanotifyrc.Notifications.PopupPosition = "BottomRight";
kwinrc =
{
Tiling.padding = 4;
Wayland."InputMethod[$e]" = "/run/current-system/sw/share/applications/org.fcitx.Fcitx5.desktop";
Windows.RollOverDesktops = true;
Compositing = { AllowTearing = false; WindowsBlockCompositing = false; };
};
};
}
# baloo
{ configFile.baloofilerc."Basic Settings".Indexing-Enabled = false; }
# dolphin and file chooser
{
configFile =
{
dolphinrc =
{
General = { ShowFullPath = true; FilterBar = true; RememberOpenedTabs = false; };
PreviewSettings.Plugins = builtins.concatStringsSep ","
[
"blenderthumbnail"
"comicbookthumbnail"
"djvuthumbnail"
"ebookthumbnail"
"exrthumbnail"
"marble_thumbnail_geojson"
"marble_thumbnail_gpx"
"jpegthumbnail"
"marble_thumbnail_kmz"
"marble_thumbnail_kml"
"kraorathumbnail"
"windowsimagethumbnail"
"windowsexethumbnail"
"mltpreview"
"mobithumbnail"
"opendocumentthumbnail"
"marble_thumbnail_osm"
"palathumbcreator"
"gsthumbnail"
"rawthumbnail"
"svgthumbnail"
"imagethumbnail"
"fontthumbnail"
"directorythumbnail"
"textthumbnail"
"webarchivethumbnail"
"ffmpegthumbs"
"audiothumbnail"
];
};
kdeglobals."KFileDialog Settings" =
{
"Allow Expansion" = true;
"Automatically select filename extension" = true;
"Show Bookmarks" = true;
"Show Full Path" = true;
"Show Inline Previews" = true;
"Show Preview" = true;
"Show Speedbar" = true;
"Show hidden files" = true;
"Sort by" = "Name";
"Sort directories first" = true;
"Sort hidden files last" = true;
"View Style" = "DetailTree";
};
};
}
# krunner
{ configFile.krunnerrc = { General.FreeFloating = true; Plugins.baloosearchEnabled = false; }; }
# lock screen
{ configFile.kscreenlockerrc.Daemon.Autolock = false; }
];
}];
}

View File

@@ -1,84 +0,0 @@
inputs:
{
config = inputs.lib.mkIf inputs.config.nixos.system.gui.enable
{
nixos.user.sharedModules =
[(hmInputs: {
config =
{
programs.plasma =
{
overrideConfig = true;
overrideConfigFiles = [ "konsolerc" "yakuakerc" ];
configFile =
{
yakuakerc =
{
Appearance =
{
HideSkinBorders = true;
Skin = "Slate";
Translucency = true;
};
"Desktop Entry".DefaultProfile = "plasma-manager.profile";
Dialogs.FirstRun = false;
Window =
{
KeepOpen = false;
KeepOpenAfterLastSessionCloses = true;
ShowSystrayIcon = false;
};
};
konsolerc =
{
"Desktop Entry".DefaultProfile = "plasma-manager.profile";
"MainWindow.Toolbar sessionToolbar".ToolButtonStyle = "IconOnly";
};
};
dataFile."konsole/plasma-manager.profile" =
{
Appearance =
{
AntiAliasFonts = true;
BoldIntense = true;
ColorScheme = "Breeze";
Font = "FiraCode Nerd Font Mono,10,-1,5,50,0,0,0,0,0";
UseFontLineChararacters = true;
WordModeAttr = false;
};
"Cursor Options".CursorShape = 1;
General =
{
Name = "plasma-manager";
Parent = "FALLBACK/";
TerminalCenter = true;
TerminalMargin = 1;
};
"Interaction Options" =
{
AutoCopySelectedText = true;
TrimLeadingSpacesInSelectedText = true;
TrimTrailingSpacesInSelectedText = true;
UnderlineFilesEnabled = true;
};
Scrolling =
{
HistoryMode = 2;
ReflowLines = false;
};
"Terminal Features".BlinkingCursorEnabled = true;
};
};
home.file.".local/share/konsole/Breeze.colorscheme".text = builtins.replaceStrings
[ "Opacity=1" ] [ "Opacity=0.9\nBlur=true" ]
(builtins.readFile "${inputs.pkgs.konsole}/share/konsole/Breeze.colorscheme");
};
})];
environment.persistence =
let impermanence = inputs.config.nixos.system.impermanence;
in inputs.lib.mkIf impermanence.enable (inputs.lib.mkMerge (builtins.map
(user:
{ "${impermanence.root}".users.${user}.directories = [ ".local/share/konsole" ".local/share/yakuake" ]; })
inputs.config.nixos.user.users));
};
}

View File

@@ -22,7 +22,7 @@ inputs:
])
++ (with ms-vscode;
[
(cmake-tools.overrideAttrs { sourceRoot = "extension"; }) cpptools cpptools-extension-pack cpptools-themes hexeditor remote-explorer
cmake-tools cpptools cpptools-extension-pack cpptools-themes hexeditor remote-explorer
test-adapter-converter
])
++ (with ms-vscode-remote; [ remote-ssh remote-containers remote-ssh-edit ])
@@ -46,9 +46,6 @@ inputs:
shd101wyy.markdown-preview-enhanced
# vasp
mystery.vasp-support
yutengjing.open-in-external-app
# ChatGPT-like plugin
codeium.codeium
];
}
)];

Some files were not shown because too many files have changed in this diff Show More