treewide: alejandra -> nixfmt-rfc-style

This commit is contained in:
Guanran Wang 2024-08-25 23:02:35 +08:00
parent b36d666c02
commit 0b89e192b1
Signed by: nyancat
GPG key ID: 91F97D9ED12639CF
64 changed files with 541 additions and 377 deletions

View file

@ -201,11 +201,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1722181846, "lastModified": 1724599287,
"narHash": "sha256-/yyqi39qr7Z+Bkv8gVVqB5q/gu1cLna3TtzbADLzEbc=", "narHash": "sha256-M4OllWFNDcvgY2rgx/9uWn9jpunSb2CzmqPDcuS27SQ=",
"ref": "refs/heads/master", "ref": "refs/heads/master",
"rev": "214725ef364950e5b086f0cd3f7978f38655a58b", "rev": "a2f4145923cbbabb63e7749a49c86052a17389f7",
"revCount": 70, "revCount": 72,
"type": "git", "type": "git",
"url": "https://git.ny4.dev/nyancat/nvim" "url": "https://git.ny4.dev/nyancat/nvim"
}, },

View file

@ -83,11 +83,15 @@
}; };
}; };
outputs = inputs: outputs =
inputs.flake-utils.lib.eachDefaultSystem (system: let inputs:
inputs.flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = inputs.nixpkgs.legacyPackages.${system}; pkgs = inputs.nixpkgs.legacyPackages.${system};
treefmtEval = inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix; treefmtEval = inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
in { in
{
### nix fmt ### nix fmt
formatter = treefmtEval.config.build.wrapper; formatter = treefmtEval.config.build.wrapper;
@ -104,7 +108,8 @@
sops sops
]; ];
}; };
}) }
)
// { // {
### imports = []; ### imports = [];
nixosModules.default = ./nixos/modules; nixosModules.default = ./nixos/modules;
@ -120,12 +125,16 @@
./nixos/profiles/core ./nixos/profiles/core
./hosts/dust ./hosts/dust
]; ];
specialArgs = {inherit inputs;}; specialArgs = {
inherit inputs;
};
}; };
colmena = { colmena = {
meta = { meta = {
specialArgs = {inherit inputs;}; specialArgs = {
inherit inputs;
};
nixpkgs = import inputs.nixpkgs { nixpkgs = import inputs.nixpkgs {
system = "x86_64-linux"; # How does this work? system = "x86_64-linux"; # How does this work?
}; };

View file

@ -9,9 +9,26 @@
stats = { stats = {
common_subcommands = common_subcommands =
["nix" "nom" "nh" "podman" "docker" "atuin" "hugo" "adb"] [
"nix"
"nom"
"nh"
"podman"
"docker"
"atuin"
"hugo"
"adb"
]
# default # default
++ ["cargo" "go" "git" "npm" "yarn" "pnpm" "kubectl"]; ++ [
"cargo"
"go"
"git"
"npm"
"yarn"
"pnpm"
"kubectl"
];
}; };
}; };
}; };

View file

@ -1,4 +1,5 @@
{config, ...}: { { config, ... }:
{
programs.bash = { programs.bash = {
enable = true; enable = true;
historyFile = "${config.xdg.configHome}/bash/.bash_history"; historyFile = "${config.xdg.configHome}/bash/.bash_history";

View file

@ -2,7 +2,8 @@
lib, lib,
pkgs, pkgs,
... ...
}: let }:
let
package = pkgs.qt6Packages.fcitx5-with-addons.override { package = pkgs.qt6Packages.fcitx5-with-addons.override {
addons = with pkgs; [ addons = with pkgs; [
qt6Packages.fcitx5-chinese-addons qt6Packages.fcitx5-chinese-addons
@ -11,7 +12,8 @@
fcitx5-pinyin-zhwiki fcitx5-pinyin-zhwiki
]; ];
}; };
in { in
{
home.packages = [ home.packages = [
package package
]; ];

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
programs.firefox = { programs.firefox = {
enable = true; enable = true;
package = pkgs.firefox.override { package = pkgs.firefox.override {

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
programs.fish = { programs.fish = {
enable = true; enable = true;
interactiveShellInit = '' interactiveShellInit = ''

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
programs.git = rec { programs.git = rec {
enable = true; enable = true;
package = pkgs.gitFull; # overriding takes forever to compile package = pkgs.gitFull; # overriding takes forever to compile

View file

@ -2,7 +2,8 @@
pkgs, pkgs,
config, config,
... ...
}: { }:
{
programs.go.enable = true; programs.go.enable = true;
home.packages = with pkgs; [ home.packages = with pkgs; [
gopls gopls

View file

@ -3,7 +3,8 @@
lib, lib,
pkgs, pkgs,
... ...
}: { }:
{
programs.gpg = { programs.gpg = {
enable = true; enable = true;
homedir = "${config.xdg.dataHome}/gnupg"; homedir = "${config.xdg.dataHome}/gnupg";

View file

@ -2,7 +2,8 @@
pkgs, pkgs,
lib, lib,
... ...
}: { }:
{
programs.mpv = { programs.mpv = {
enable = true; enable = true;
config = { config = {
@ -22,14 +23,21 @@
modernx-zydezu modernx-zydezu
thumbfast thumbfast
]) ])
++ lib.optionals pkgs.stdenv.hostPlatform.isLinux (with pkgs.mpvScripts; [ ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux (
with pkgs.mpvScripts;
[
mpris mpris
]); ]
);
bindings = let bindings =
let
inherit (pkgs) anime4k; inherit (pkgs) anime4k;
setShader = message: files: ''no-osd change-list glsl-shaders set "${lib.concatStringsSep ":" files}"; show-text "${message}"''; setShader =
in { message: files:
''no-osd change-list glsl-shaders set "${lib.concatStringsSep ":" files}"; show-text "${message}"'';
in
{
"CTRL+1" = setShader "Anime4K: Mode A (Fast)" [ "CTRL+1" = setShader "Anime4K: Mode A (Fast)" [
"${anime4k}/Anime4K_Clamp_Highlights.glsl" "${anime4k}/Anime4K_Clamp_Highlights.glsl"
"${anime4k}/Anime4K_Restore_CNN_M.glsl" "${anime4k}/Anime4K_Restore_CNN_M.glsl"

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
home.packages = [ pkgs.nautilus ]; home.packages = [ pkgs.nautilus ];
dconf.settings = { dconf.settings = {
"org/gnome/nautilus/list-view".default-zoom-level = "small"; "org/gnome/nautilus/list-view".default-zoom-level = "small";

View file

@ -2,7 +2,8 @@
pkgs, pkgs,
inputs, inputs,
... ...
}: { }:
{
home.packages = [ home.packages = [
(inputs.neovim.packages.${pkgs.stdenv.hostPlatform.system}.default.override { (inputs.neovim.packages.${pkgs.stdenv.hostPlatform.system}.default.override {
viAlias = true; viAlias = true;

View file

@ -1,6 +1,6 @@
{pkgs, ...}: { { pkgs, ... }:
{
home.packages = with pkgs; [ home.packages = with pkgs; [
alejandra
colmena colmena
deadnix deadnix
nh nh

View file

@ -1,9 +1,12 @@
{config, ...}: { { config, ... }:
{
programs.ssh = { programs.ssh = {
enable = true; enable = true;
matchBlocks = let matchBlocks =
let
inherit (config.home) homeDirectory; inherit (config.home) homeDirectory;
in { in
{
"blacksteel".identityFile = "${homeDirectory}/.ssh/id_github_signing"; "blacksteel".identityFile = "${homeDirectory}/.ssh/id_github_signing";
"tyo0.ny4.dev".identityFile = "${homeDirectory}/.ssh/id_github_signing"; "tyo0.ny4.dev".identityFile = "${homeDirectory}/.ssh/id_github_signing";
}; };

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
programs.starship = { programs.starship = {
enable = true; enable = true;
}; };

View file

@ -4,7 +4,8 @@
inputs, inputs,
pkgs, pkgs,
... ...
}: { }:
{
imports = [ imports = [
../i3status-rust ../i3status-rust
../kanshi ../kanshi
@ -67,7 +68,8 @@
### Keybinds ### Keybinds
modifier = "Mod4"; modifier = "Mod4";
keybindings = let keybindings =
let
inherit (config.wayland.windowManager.sway.config) modifier; inherit (config.wayland.windowManager.sway.config) modifier;
in in
{ {
@ -117,7 +119,8 @@
} }
// //
# workspace binds # workspace binds
lib.listToAttrs (lib.concatMap (x: [ lib.listToAttrs (
lib.concatMap (x: [
{ {
name = "${modifier}+${x}"; name = "${modifier}+${x}";
value = "workspace ${x}"; value = "workspace ${x}";
@ -126,7 +129,8 @@
name = "${modifier}+Shift+${x}"; name = "${modifier}+Shift+${x}";
value = "move container to workspace ${x}"; value = "move container to workspace ${x}";
} }
]) (lib.genList (x: toString (x + 1)) 9)); ]) (lib.genList (x: toString (x + 1)) 9)
);
}; };
}; };
} }

View file

@ -3,15 +3,18 @@
lib, lib,
config, config,
... ...
}: { }:
{
imports = [ imports = [
../swaylock ../swaylock
]; ];
services.swayidle = let services.swayidle =
let
lock = lib.getExe config.programs.swaylock.package; lock = lib.getExe config.programs.swaylock.package;
brightness = lib.getExe pkgs.brightnessctl; brightness = lib.getExe pkgs.brightnessctl;
in { in
{
enable = true; enable = true;
timeouts = [ timeouts = [
{ {

View file

@ -2,7 +2,8 @@
inputs, inputs,
pkgs, pkgs,
... ...
}: { }:
{
programs.swaylock = { programs.swaylock = {
enable = true; enable = true;
settings = { settings = {

View file

@ -1,14 +1,17 @@
{pkgs, ...}: { { pkgs, ... }:
{
programs.thunderbird = { programs.thunderbird = {
enable = true; enable = true;
package = pkgs.thunderbird-128; package = pkgs.thunderbird-128;
profiles.default = { profiles.default = {
isDefault = true; isDefault = true;
extraConfig = '' extraConfig = ''
${builtins.readFile (builtins.fetchurl { ${builtins.readFile (
builtins.fetchurl {
url = "https://raw.githubusercontent.com/HorlogeSkynet/thunderbird-user.js/824edabe6303d6b85a32fcba96901706ed4c5922/user.js"; url = "https://raw.githubusercontent.com/HorlogeSkynet/thunderbird-user.js/824edabe6303d6b85a32fcba96901706ed4c5922/user.js";
sha256 = "0jg7i39yp21r66azlzk7978qj57rgb8c09d1hccpcw058isgymq6"; sha256 = "0jg7i39yp21r66azlzk7978qj57rgb8c09d1hccpcw058isgymq6";
})} }
)}
${builtins.readFile ./user-overrides.js} ${builtins.readFile ./user-overrides.js}
''; '';
}; };

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
home.packages = [ pkgs.tmux ]; home.packages = [ pkgs.tmux ];
xdg.configFile."tmux/tmux.conf".text = '' xdg.configFile."tmux/tmux.conf".text = ''

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
home.packages = [ pkgs.ydict ]; home.packages = [ pkgs.ydict ];
home.shellAliases = { home.shellAliases = {
"yd" = "ydict -c"; "yd" = "ydict -c";

View file

@ -2,7 +2,8 @@
lib, lib,
pkgs, pkgs,
... ...
}: { }:
{
home = { home = {
username = "guanranwang"; username = "guanranwang";
homeDirectory = "/home/guanranwang"; homeDirectory = "/home/guanranwang";
@ -33,11 +34,13 @@
fd fd
]; ];
programs.fish.functions = let programs.fish.functions =
let
jq = lib.getExe pkgs.jq; jq = lib.getExe pkgs.jq;
nix = lib.getExe pkgs.nix; nix = lib.getExe pkgs.nix;
curl = lib.getExe pkgs.curl; curl = lib.getExe pkgs.curl;
in { in
{
"pb" = '' "pb" = ''
${jq} -Rns '{text: inputs}' | \ ${jq} -Rns '{text: inputs}' | \
${curl} -s -H 'Content-Type: application/json' --data-binary @- https://pb.ny4.dev | \ ${curl} -s -H 'Content-Type: application/json' --data-binary @- https://pb.ny4.dev | \

View file

@ -1,7 +1,9 @@
{lib, ...}: { { lib, ... }:
{
nixpkgs.config = { nixpkgs.config = {
allowNonSource = false; allowNonSource = false;
allowNonSourcePredicate = pkg: allowNonSourcePredicate =
pkg:
lib.elem (lib.getName pkg) [ lib.elem (lib.getName pkg) [
"adoptopenjdk-hotspot-bin" "adoptopenjdk-hotspot-bin"
"cargo-bootstrap" "cargo-bootstrap"
@ -13,7 +15,8 @@
]; ];
allowUnfree = false; allowUnfree = false;
allowUnfreePredicate = pkg: allowUnfreePredicate =
pkg:
lib.elem (lib.getName pkg) [ lib.elem (lib.getName pkg) [
"broadcom-sta" "broadcom-sta"
"minecraft-server" "minecraft-server"

View file

@ -3,7 +3,8 @@
config, config,
pkgs, pkgs,
... ...
}: { }:
{
imports = [ imports = [
# OS # OS
../../nixos/profiles/sing-box ../../nixos/profiles/sing-box
@ -44,7 +45,8 @@
}; };
"cloudflared/secret" = { "cloudflared/secret" = {
restartUnits = [ "cloudflared-tunnel-6222a3e0-98da-4325-be19-0f86a7318a41.service" ]; restartUnits = [ "cloudflared-tunnel-6222a3e0-98da-4325-be19-0f86a7318a41.service" ];
owner = config.systemd.services."cloudflared-tunnel-6222a3e0-98da-4325-be19-0f86a7318a41".serviceConfig.User; owner =
config.systemd.services."cloudflared-tunnel-6222a3e0-98da-4325-be19-0f86a7318a41".serviceConfig.User;
}; };
}; };
@ -77,7 +79,10 @@
}; };
systemd.services.caddy.serviceConfig = { systemd.services.caddy.serviceConfig = {
SupplementaryGroups = ["mastodon" "matrix-synapse"]; SupplementaryGroups = [
"mastodon"
"matrix-synapse"
];
}; };
services.postgresql = { services.postgresql = {

View file

@ -2,7 +2,8 @@
inputs, inputs,
config, config,
... ...
}: { }:
{
imports = [ imports = [
inputs.nixpkgs.nixosModules.notDetected inputs.nixpkgs.nixosModules.notDetected
inputs.nixos-hardware.nixosModules.apple-macbook-pro inputs.nixos-hardware.nixosModules.apple-macbook-pro
@ -14,8 +15,17 @@
services.thermald.enable = true; services.thermald.enable = true;
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod"]; boot.initrd.availableKernelModules = [
boot.kernelModules = ["kvm-intel" "wl"]; "xhci_pci"
"ahci"
"usbhid"
"usb_storage"
"sd_mod"
];
boot.kernelModules = [
"kvm-intel"
"wl"
];
boot.extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ]; boot.extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ];
nixpkgs.hostPlatform = "x86_64-linux"; nixpkgs.hostPlatform = "x86_64-linux";

View file

@ -1,4 +1,5 @@
{config, ...}: { { config, ... }:
{
services.mastodon = { services.mastodon = {
enable = true; enable = true;
localDomain = "ny4.dev"; localDomain = "ny4.dev";

View file

@ -1,4 +1,5 @@
{config, ...}: { { config, ... }:
{
services.matrix-synapse = { services.matrix-synapse = {
enable = true; enable = true;
withJemalloc = true; withJemalloc = true;
@ -14,7 +15,10 @@
type = "http"; type = "http";
resources = [ resources = [
{ {
names = ["client" "federation"]; names = [
"client"
"federation"
];
compress = true; compress = true;
} }
]; ];
@ -29,7 +33,10 @@
issuer = "https://id.ny4.dev/realms/ny4"; issuer = "https://id.ny4.dev/realms/ny4";
client_id = "synapse"; client_id = "synapse";
client_secret_path = config.sops.secrets."synapse/oidc".path; client_secret_path = config.sops.secrets."synapse/oidc".path;
scopes = ["openid" "profile"]; scopes = [
"openid"
"profile"
];
user_mapping_provider.config = { user_mapping_provider.config = {
localpart_template = "{{ user.preferred_username }}"; localpart_template = "{{ user.preferred_username }}";
display_name_template = "{{ user.name }}"; display_name_template = "{{ user.name }}";

View file

@ -2,7 +2,8 @@
lib, lib,
pkgs, pkgs,
... ...
}: { }:
{
services.minecraft-server = { services.minecraft-server = {
enable = true; enable = true;
eula = true; eula = true;

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
# TODO: https://github.com/NixOS/nixpkgs/pull/287923 # TODO: https://github.com/NixOS/nixpkgs/pull/287923
# currently running qbittorrent-nox with tmux :c # currently running qbittorrent-nox with tmux :c
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View file

@ -1,9 +1,11 @@
{lib, ...}: { { lib, ... }:
{
nixpkgs.config = { nixpkgs.config = {
allowAliases = false; allowAliases = false;
allowNonSource = false; allowNonSource = false;
allowNonSourcePredicate = pkg: allowNonSourcePredicate =
pkg:
lib.elem (lib.getName pkg) [ lib.elem (lib.getName pkg) [
"cargo-bootstrap" "cargo-bootstrap"
"cef-binary" "cef-binary"
@ -15,7 +17,8 @@
]; ];
allowUnfree = false; allowUnfree = false;
allowUnfreePredicate = pkg: allowUnfreePredicate =
pkg:
lib.elem (lib.getName pkg) [ lib.elem (lib.getName pkg) [
"fcitx5-pinyin-minecraft" "fcitx5-pinyin-minecraft"
"fcitx5-pinyin-moegirl" "fcitx5-pinyin-moegirl"

View file

@ -2,7 +2,8 @@
lib, lib,
pkgs, pkgs,
... ...
}: { }:
{
imports = [ imports = [
../../nixos/profiles/sing-box ../../nixos/profiles/sing-box
../../nixos/profiles/wireless ../../nixos/profiles/wireless

View file

@ -1,11 +1,15 @@
let let
# compress-force: https://t.me/archlinuxcn_group/3054167 # compress-force: https://t.me/archlinuxcn_group/3054167
mountOptions = ["compress-force=zstd" "noatime"]; mountOptions = [
"compress-force=zstd"
"noatime"
];
cryptSettings = { cryptSettings = {
allowDiscards = true; allowDiscards = true;
bypassWorkqueues = true; bypassWorkqueues = true;
}; };
in { in
{
disko.devices = { disko.devices = {
disk = { disk = {
"one" = { "one" = {
@ -22,7 +26,10 @@ in {
type = "filesystem"; type = "filesystem";
format = "vfat"; format = "vfat";
mountpoint = "/boot"; mountpoint = "/boot";
mountOptions = ["defaults" "umask=007"]; mountOptions = [
"defaults"
"umask=007"
];
}; };
}; };
"cryptroot" = { "cryptroot" = {

View file

@ -1,4 +1,5 @@
{inputs, ...}: { { inputs, ... }:
{
imports = [ imports = [
inputs.nixpkgs.nixosModules.notDetected inputs.nixpkgs.nixosModules.notDetected
inputs.nixos-hardware.nixosModules.lenovo-thinkpad-x1-12th-gen inputs.nixos-hardware.nixosModules.lenovo-thinkpad-x1-12th-gen
@ -23,7 +24,13 @@
boot.kernelParams = [ "ia32_emulation=0" ]; boot.kernelParams = [ "ia32_emulation=0" ];
boot.initrd.availableKernelModules = ["xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod"]; boot.initrd.availableKernelModules = [
"xhci_pci"
"thunderbolt"
"nvme"
"usb_storage"
"sd_mod"
];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
imports = imports =
[ [
./theme.nix ./theme.nix

View file

@ -3,7 +3,8 @@
config, config,
lib, lib,
... ...
}: { }:
{
home.pointerCursor = { home.pointerCursor = {
name = "Adwaita"; name = "Adwaita";
package = pkgs.adwaita-icon-theme; package = pkgs.adwaita-icon-theme;

View file

@ -1,4 +1,5 @@
{lib, ...}: { { lib, ... }:
{
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types # https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
xdg.mimeApps = { xdg.mimeApps = {
enable = true; enable = true;

View file

@ -1,4 +1,5 @@
{lib, ...}: { { lib, ... }:
{
sops.age.sshKeyPaths = lib.mkForce [ "/persist/etc/ssh/ssh_host_ed25519_key" ]; sops.age.sshKeyPaths = lib.mkForce [ "/persist/etc/ssh/ssh_host_ed25519_key" ];
fileSystems."/persist".neededForBoot = true; fileSystems."/persist".neededForBoot = true;
environment.persistence."/persist" = { environment.persistence."/persist" = {

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
environment.systemPackages = [ pkgs.sbctl ]; environment.systemPackages = [ pkgs.sbctl ];
boot.lanzaboote = { boot.lanzaboote = {
enable = true; enable = true;

View file

@ -1,7 +1,9 @@
{lib, ...}: { { lib, ... }:
{
nixpkgs.config = { nixpkgs.config = {
allowNonSource = false; allowNonSource = false;
allowNonSourcePredicate = pkg: allowNonSourcePredicate =
pkg:
lib.elem (lib.getName pkg) [ lib.elem (lib.getName pkg) [
"adoptopenjdk-hotspot-bin" "adoptopenjdk-hotspot-bin"
"cargo-bootstrap" "cargo-bootstrap"
@ -12,8 +14,10 @@
]; ];
allowUnfree = false; allowUnfree = false;
allowUnfreePredicate = pkg: allowUnfreePredicate =
lib.elem (lib.getName pkg) [ pkg:
lib.elem (lib.getName pkg)
[
]; ];
permittedInsecurePackages = [ permittedInsecurePackages = [

View file

@ -3,7 +3,8 @@
modulesPath, modulesPath,
pkgs, pkgs,
... ...
}: { }:
{
imports = [ imports = [
"${modulesPath}/virtualisation/amazon-image.nix" "${modulesPath}/virtualisation/amazon-image.nix"
./anti-feature.nix ./anti-feature.nix
@ -53,7 +54,10 @@
### Services ### Services
networking.firewall.allowedUDPPorts = [ 443 ]; # hysteria networking.firewall.allowedUDPPorts = [ 443 ]; # hysteria
networking.firewall.allowedTCPPorts = [80 443]; # caddy networking.firewall.allowedTCPPorts = [
80
443
]; # caddy
systemd.tmpfiles.settings = { systemd.tmpfiles.settings = {
"10-www" = { "10-www" = {
@ -122,7 +126,12 @@
services.vnstat.enable = true; services.vnstat.enable = true;
systemd.services."no-bankrupt" = { systemd.services."no-bankrupt" = {
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";
path = with pkgs; [coreutils gawk vnstat systemd]; path = with pkgs; [
coreutils
gawk
vnstat
systemd
];
script = '' script = ''
TRAFF_TOTAL=1900 TRAFF_TOTAL=1900
TRAFF_USED=$(vnstat --oneline b | awk -F ';' '{print $11}') TRAFF_USED=$(vnstat --oneline b | awk -F ';' '{print $11}')

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
services.forgejo = { services.forgejo = {
enable = true; enable = true;
package = pkgs.forgejo; package = pkgs.forgejo;

View file

@ -1,4 +1,5 @@
{config, ...}: { { config, ... }:
{
services.hysteria = { services.hysteria = {
enable = true; enable = true;
settings = { settings = {

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
services.keycloak = { services.keycloak = {
enable = true; enable = true;
settings = { settings = {

View file

@ -1,4 +1,5 @@
{config, ...}: { { config, ... }:
{
services.miniflux = { services.miniflux = {
enable = true; enable = true;
adminCredentialsFile = config.sops.secrets."miniflux/environment".path; adminCredentialsFile = config.sops.secrets."miniflux/environment".path;

View file

@ -2,7 +2,8 @@
pkgs, pkgs,
config, config,
... ...
}: { }:
{
services.pixivfe = { services.pixivfe = {
enable = true; enable = true;
EnvironmentFile = config.sops.secrets."pixivfe/environment".path; EnvironmentFile = config.sops.secrets."pixivfe/environment".path;

View file

@ -2,7 +2,8 @@
pkgs, pkgs,
config, config,
... ...
}: { }:
{
services.searx = { services.searx = {
enable = true; enable = true;
package = pkgs.searxng; package = pkgs.searxng;

View file

@ -1,4 +1,5 @@
{config, ...}: { { config, ... }:
{
services.vaultwarden = { services.vaultwarden = {
enable = true; enable = true;
environmentFile = config.sops.secrets."vaultwarden/environment".path; environmentFile = config.sops.secrets."vaultwarden/environment".path;

View file

@ -1,4 +1,5 @@
{...}: { { ... }:
{
imports = [ imports = [
./services/hysteria.nix ./services/hysteria.nix
./services/pixivfe.nix ./services/pixivfe.nix

View file

@ -4,17 +4,22 @@
pkgs, pkgs,
utils, utils,
... ...
}: let }:
let
cfg = config.services.hysteria; cfg = config.services.hysteria;
settingsFormat = pkgs.formats.json { }; settingsFormat = pkgs.formats.json { };
in { in
{
options.services.hysteria = { options.services.hysteria = {
enable = lib.mkEnableOption "Hysteria, a powerful, lightning fast and censorship resistant proxy"; enable = lib.mkEnableOption "Hysteria, a powerful, lightning fast and censorship resistant proxy";
package = lib.mkPackageOption pkgs "hysteria" { }; package = lib.mkPackageOption pkgs "hysteria" { };
mode = lib.mkOption { mode = lib.mkOption {
type = lib.types.enum ["server" "client"]; type = lib.types.enum [
"server"
"client"
];
default = "server"; default = "server";
description = "Whether to use Hysteria as a client or a server."; description = "Whether to use Hysteria as a client or a server.";
}; };
@ -54,8 +59,16 @@ in {
StateDirectory = "hysteria"; StateDirectory = "hysteria";
### Hardening ### Hardening
AmbientCapabilities = ["CAP_NET_ADMIN" "CAP_NET_BIND_SERVICE" "CAP_NET_RAW"]; AmbientCapabilities = [
CapabilityBoundingSet = ["CAP_NET_ADMIN" "CAP_NET_BIND_SERVICE" "CAP_NET_RAW"]; "CAP_NET_ADMIN"
"CAP_NET_BIND_SERVICE"
"CAP_NET_RAW"
];
CapabilityBoundingSet = [
"CAP_NET_ADMIN"
"CAP_NET_BIND_SERVICE"
"CAP_NET_RAW"
];
NoNewPrivileges = true; NoNewPrivileges = true;
PrivateMounts = true; PrivateMounts = true;
PrivateTmp = true; PrivateTmp = true;

View file

@ -4,13 +4,17 @@
inputs, inputs,
pkgs, pkgs,
... ...
}: let }:
let
cfg = config.services.pixivfe; cfg = config.services.pixivfe;
in { in
{
options.services.pixivfe = { options.services.pixivfe = {
enable = lib.mkEnableOption "PixivFE, a privacy respecting frontend for Pixiv"; enable = lib.mkEnableOption "PixivFE, a privacy respecting frontend for Pixiv";
package = lib.mkPackageOption inputs.self.legacyPackages.${pkgs.stdenv.hostPlatform.system} "pixivfe" {}; package =
lib.mkPackageOption inputs.self.legacyPackages.${pkgs.stdenv.hostPlatform.system} "pixivfe"
{ };
openFirewall = lib.mkEnableOption "open ports in the firewall needed for the daemon to function"; openFirewall = lib.mkEnableOption "open ports in the firewall needed for the daemon to function";
@ -46,10 +50,7 @@ in {
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
assertions = [ assertions = [
{ {
assertion = assertion = if cfg.openFirewall then (cfg.settings ? PIXIVFE_PORT) else true;
if cfg.openFirewall
then (cfg.settings ? PIXIVFE_PORT)
else true;
message = '' message = ''
PIXIVFE_PORT must be specified for NixOS to open a port. PIXIVFE_PORT must be specified for NixOS to open a port.
@ -58,9 +59,10 @@ in {
} }
{ {
assertion = assertion =
if (cfg.EnvironmentFile == null) if (cfg.EnvironmentFile == null) then
then (cfg.settings ? PIXIVFE_UNIXSOCKET) || (cfg.settings ? PIXIVFE_PORT) (cfg.settings ? PIXIVFE_UNIXSOCKET) || (cfg.settings ? PIXIVFE_PORT)
else true; else
true;
message = '' message = ''
PIXIVFE_PORT or PIXIVFE_UNIXSOCKET must be set for PixivFE to run. PIXIVFE_PORT or PIXIVFE_UNIXSOCKET must be set for PixivFE to run.
@ -68,10 +70,7 @@ in {
''; '';
} }
{ {
assertion = assertion = if (cfg.EnvironmentFile == null) then cfg.settings ? PIXIVFE_TOKEN else true;
if (cfg.EnvironmentFile == null)
then cfg.settings ? PIXIVFE_TOKEN
else true;
message = '' message = ''
PIXIVFE_TOKEN must be set for PixivFE to run. PIXIVFE_TOKEN must be set for PixivFE to run.
@ -86,11 +85,9 @@ in {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" ]; after = [ "network-online.target" ];
wants = [ "network-online.target" ]; wants = [ "network-online.target" ];
environment = lib.mkIf (cfg.settings != null) (lib.mapAttrs (_: v: environment = lib.mkIf (cfg.settings != null) (
if lib.isBool v lib.mapAttrs (_: v: if lib.isBool v then lib.boolToString v else toString v) cfg.settings
then lib.boolToString v );
else toString v)
cfg.settings);
serviceConfig = { serviceConfig = {
inherit (cfg) EnvironmentFile; inherit (cfg) EnvironmentFile;
ExecStart = lib.getExe cfg.package; ExecStart = lib.getExe cfg.package;

View file

@ -4,7 +4,8 @@
inputs, inputs,
pkgs, pkgs,
... ...
}: { }:
{
imports = imports =
[ [
./hardening.nix ./hardening.nix
@ -29,7 +30,9 @@
users.guanranwang = import ../../../home; users.guanranwang = import ../../../home;
useGlobalPkgs = true; useGlobalPkgs = true;
useUserPackages = true; useUserPackages = true;
extraSpecialArgs = {inherit inputs;}; extraSpecialArgs = {
inherit inputs;
};
}; };
boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest;

View file

@ -3,7 +3,8 @@
config, config,
inputs, inputs,
... ...
}: { }:
{
nix.settings = { nix.settings = {
substituters = substituters =
(lib.optionals (config.time.timeZone == "Asia/Shanghai") [ (lib.optionals (config.time.timeZone == "Asia/Shanghai") [

View file

@ -1,4 +1,5 @@
{lib, ...}: { { lib, ... }:
{
services.zram-generator = { services.zram-generator = {
enable = true; enable = true;
settings.zram0 = { settings.zram0 = {

View file

@ -2,14 +2,16 @@
pkgs, pkgs,
config, config,
... ...
}: { }:
{
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
foot.terminfo foot.terminfo
]; ];
# TODO: colmena # TODO: colmena
services.openssh.settings.PermitRootLogin = "prohibit-password"; services.openssh.settings.PermitRootLogin = "prohibit-password";
users.users."root".openssh.authorizedKeys.keys = config.users.users.guanranwang.openssh.authorizedKeys.keys; users.users."root".openssh.authorizedKeys.keys =
config.users.users.guanranwang.openssh.authorizedKeys.keys;
time.timeZone = "UTC"; time.timeZone = "UTC";
} }

View file

@ -2,7 +2,8 @@
pkgs, pkgs,
config, config,
... ...
}: { }:
{
services.sing-box = { services.sing-box = {
enable = true; enable = true;
settings = { settings = {
@ -94,9 +95,11 @@
httpsProxy = "http://127.0.0.1:1080/"; httpsProxy = "http://127.0.0.1:1080/";
}; };
environment.shellAliases = let environment.shellAliases =
let
inherit (config.networking.proxy) httpProxy httpsProxy; inherit (config.networking.proxy) httpProxy httpsProxy;
in { in
{
"setproxy" = "export http_proxy=${httpProxy} https_proxy=${httpsProxy}"; "setproxy" = "export http_proxy=${httpProxy} https_proxy=${httpsProxy}";
"unsetproxy" = "set -e http_proxy https_proxy"; "unsetproxy" = "set -e http_proxy https_proxy";
}; };

View file

@ -1,4 +1,5 @@
{lib, ...}: { { lib, ... }:
{
sops.secrets = lib.mapAttrs (_name: value: value // { sopsFile = ./secrets.yaml; }) { sops.secrets = lib.mapAttrs (_name: value: value // { sopsFile = ./secrets.yaml; }) {
"wireless/wangxiaobo".path = "/var/lib/iwd/wangxiaobo.psk"; "wireless/wangxiaobo".path = "/var/lib/iwd/wangxiaobo.psk";
"wireless/ImmortalWrt".path = "/var/lib/iwd/ImmortalWrt.psk"; "wireless/ImmortalWrt".path = "/var/lib/iwd/ImmortalWrt.psk";

View file

@ -1,9 +1,11 @@
let let
addPatches = pkg: patches: addPatches =
pkg: patches:
pkg.overrideAttrs (old: { pkg.overrideAttrs (old: {
patches = (old.patches or [ ]) ++ patches; patches = (old.patches or [ ]) ++ patches;
}); });
in { in
{
patches = _final: prev: { patches = _final: prev: {
# https://aur.archlinux.org/pkgbase/nautilus-typeahead # https://aur.archlinux.org/pkgbase/nautilus-typeahead
nautilus = prev.nautilus.overrideAttrs { nautilus = prev.nautilus.overrideAttrs {
@ -21,7 +23,8 @@ in {
''; '';
}; };
qt6Packages = prev.qt6Packages.overrideScope (_final': prev': { qt6Packages = prev.qt6Packages.overrideScope (
_final': prev': {
# HACK: no more qt5 # HACK: no more qt5
fcitx5-with-addons = prev'.fcitx5-with-addons.override { fcitx5-with-addons = prev'.fcitx5-with-addons.override {
libsForQt5.fcitx5-qt = prev.emptyDirectory; libsForQt5.fcitx5-qt = prev.emptyDirectory;
@ -33,25 +36,27 @@ in {
curl = prev.emptyDirectory; curl = prev.emptyDirectory;
opencc = prev.emptyDirectory; opencc = prev.emptyDirectory;
qtwebengine = prev.emptyDirectory; qtwebengine = prev.emptyDirectory;
}) }).overrideAttrs
.overrideAttrs (oldAttrs: { (oldAttrs: {
buildInputs = oldAttrs.buildInputs ++ [prev.gettext prev'.qtbase]; buildInputs = oldAttrs.buildInputs ++ [
cmakeFlags = prev.gettext
oldAttrs.cmakeFlags prev'.qtbase
++ [ ];
cmakeFlags = oldAttrs.cmakeFlags ++ [
(prev.lib.cmakeBool "ENABLE_BROWSER" false) (prev.lib.cmakeBool "ENABLE_BROWSER" false)
(prev.lib.cmakeBool "ENABLE_CLOUDPINYIN" false) (prev.lib.cmakeBool "ENABLE_CLOUDPINYIN" false)
(prev.lib.cmakeBool "ENABLE_OPENCC" false) (prev.lib.cmakeBool "ENABLE_OPENCC" false)
]; ];
}); });
}); }
);
# HACK: no more gtk2 # HACK: no more gtk2
gnome-themes-extra = gnome-themes-extra =
(prev.gnome-themes-extra.override { (prev.gnome-themes-extra.override {
gtk2 = prev.emptyDirectory; gtk2 = prev.emptyDirectory;
}) }).overrideAttrs
.overrideAttrs { {
configureFlags = [ "--disable-gtk2-engine" ]; configureFlags = [ "--disable-gtk2-engine" ];
}; };

View file

@ -1,8 +1,10 @@
# NOTE: 301: All packages are migrated to `github:Guanran928/nur-packages`, # NOTE: 301: All packages are migrated to `github:Guanran928/nur-packages`,
# only keeping some packages that only fits for personal use. # only keeping some packages that only fits for personal use.
pkgs: let pkgs:
let
inherit (pkgs) callPackage; inherit (pkgs) callPackage;
in { in
{
# https://github.com/NixOS/nixpkgs/pull/308720 # https://github.com/NixOS/nixpkgs/pull/308720
pixivfe = callPackage ./pixivfe.nix { }; pixivfe = callPackage ./pixivfe.nix { };

View file

@ -2,7 +2,7 @@
projectRootFile = "flake.nix"; projectRootFile = "flake.nix";
### nix ### nix
programs.alejandra.enable = true; programs.nixfmt.enable = true;
programs.deadnix.enable = true; programs.deadnix.enable = true;
programs.statix.enable = true; programs.statix.enable = true;