Compare commits

...

5 Commits

Author SHA1 Message Date
chn
788709aac9 services.synapse: fix 2023-12-20 12:33:17 +08:00
chn
f5053ae284 services.postgresql: add initializeFlags 2023-12-20 12:23:05 +08:00
chn
6a6625d585 system.kernel: port some change from xddxdd/nur-packages 2023-12-20 11:31:12 +08:00
chn
69c528a03d switch back to xanmod 2023-12-20 11:04:40 +08:00
chn
6c496b7b8e services.postgresql: fix locale setting 2023-12-19 22:09:35 +08:00
4 changed files with 31 additions and 8 deletions

View File

@@ -116,7 +116,7 @@
}; };
nixpkgs = nixpkgs =
{ march = "alderlake"; cuda = { enable = true; capabilities = [ "8.6" ]; forwardCompat = false; }; }; { march = "alderlake"; cuda = { enable = true; capabilities = [ "8.6" ]; forwardCompat = false; }; };
kernel.patches = [ "cjktty" ]; kernel.patches = [ "cjktty" "lantian" ];
impermanence.enable = true; impermanence.enable = true;
networking.hostname = "pc"; networking.hostname = "pc";
sysctl.laptop-mode = 5; sysctl.laptop-mode = 5;

View File

@@ -10,7 +10,7 @@ inputs:
database = mkOption { type = types.nonEmptyStr; default = submoduleInputs.config._module.args.name; }; database = mkOption { type = types.nonEmptyStr; default = submoduleInputs.config._module.args.name; };
user = mkOption { type = types.nonEmptyStr; default = submoduleInputs.config._module.args.name; }; user = mkOption { type = types.nonEmptyStr; default = submoduleInputs.config._module.args.name; };
passwordFile = mkOption { type = types.nullOr types.nonEmptyStr; default = null; }; passwordFile = mkOption { type = types.nullOr types.nonEmptyStr; default = null; };
locale = mkOption { type = types.nullOr types.nonEmptyStr; default = null; }; initializeFlags = mkOption { type = types.attrsOf types.nonEmptyStr; default = {}; };
};})); };}));
default = {}; default = {};
}; };
@@ -52,7 +52,6 @@ inputs:
# chattr +C /path/to/dir # chattr +C /path/to/dir
# cp -a --reflink=never /path/to/dir_old/. /path/to/dir # cp -a --reflink=never /path/to/dir_old/. /path/to/dir
# rm -rf /path/to/dir_old # rm -rf /path/to/dir_old
ensureDatabases = map (db: db.value.database) (attrsToList postgresql.instances);
ensureUsers = map (db: { name = db.value.user; }) (attrsToList postgresql.instances); ensureUsers = map (db: { name = db.value.user; }) (attrsToList postgresql.instances);
}; };
postgresqlBackup = postgresqlBackup =
@@ -69,11 +68,17 @@ inputs:
passwordFile = passwordFile =
if db.value.passwordFile or null != null then db.value.passwordFile if db.value.passwordFile or null != null then db.value.passwordFile
else inputs.config.sops.secrets."postgresql/${db.value.user}".path; else inputs.config.sops.secrets."postgresql/${db.value.user}".path;
locale = if db.value.locale != null then " LOCALE ${db.value.locale}" else ""; initializeFlag =
if db.value.initializeFlags != {} then
" WITH "
+ (concatStringsSep " " (map
(flag: ''${flag.name} = "${flag.value}"'')
(attrsToList db.value.initializeFlags)))
else "";
in in
# create database if not exist # create database if not exist
"$PSQL -tAc \"SELECT 1 FROM pg_database WHERE datname = '${db.value.database}'\" | grep -q 1" "$PSQL -tAc \"SELECT 1 FROM pg_database WHERE datname = '${db.value.database}'\" | grep -q 1"
+ " || $PSQL -tAc 'CREATE DATABASE \"${db.value.database}\"${locale}'" + " || $PSQL -tAc 'CREATE DATABASE \"${db.value.database}\"${initializeFlag}'"
# set user password # set user password
+ "\n" + "\n"
+ "$PSQL -tAc \"ALTER USER ${db.value.user} with encrypted password '$(cat ${passwordFile})'\"" + "$PSQL -tAc \"ALTER USER ${db.value.user} with encrypted password '$(cat ${passwordFile})'\""

View File

@@ -112,6 +112,7 @@ inputs:
in builtins.readFile ((inputs.pkgs.formats.yaml {}).generate "${instance.name}.yaml" in builtins.readFile ((inputs.pkgs.formats.yaml {}).generate "${instance.name}.yaml"
{ {
server_name = instance.value.matrixHostname; server_name = instance.value.matrixHostname;
public_baseurl = "https://${instance.value.hostname}";
listeners = listeners =
[{ [{
bind_addresses = [ "127.0.0.1" ]; bind_addresses = [ "127.0.0.1" ];
@@ -205,7 +206,11 @@ inputs:
{ {
enable = mkIf (synapse.instances != {}) true; enable = mkIf (synapse.instances != {}) true;
instances = listToAttrs (map instances = listToAttrs (map
(instance: { name = "synapse_${replaceStrings [ "-" ] [ "_" ] instance.name}"; value.locale = "C"; }) (instance:
{
name = "synapse_${replaceStrings [ "-" ] [ "_" ] instance.name}";
value.initializeFlags = { TEMPLATE = "template0"; LC_CTYPE = "C"; LC_COLLATE = "C"; };
})
(attrsToList synapse.instances)); (attrsToList synapse.instances));
}; };
redis.instances = listToAttrs (map redis.instances = listToAttrs (map

View File

@@ -2,7 +2,7 @@ inputs:
{ {
options.nixos.system.kernel = let inherit (inputs.lib) mkOption types; in options.nixos.system.kernel = let inherit (inputs.lib) mkOption types; in
{ {
patches = mkOption { type = types.listOf (types.enum [ "cjktty" ]); default = []; }; patches = mkOption { type = types.listOf types.nonEmptyStr; default = []; };
modules = modules =
{ {
install = mkOption { type = types.listOf types.str; default = []; }; install = mkOption { type = types.listOf types.str; default = []; };
@@ -33,7 +33,7 @@ inputs:
extraModulePackages = (with inputs.config.boot.kernelPackages; [ v4l2loopback ]) ++ kernel.modules.install; extraModulePackages = (with inputs.config.boot.kernelPackages; [ v4l2loopback ]) ++ kernel.modules.install;
extraModprobeConfig = builtins.concatStringsSep "\n" kernel.modules.modprobeConfig; extraModprobeConfig = builtins.concatStringsSep "\n" kernel.modules.modprobeConfig;
kernelParams = [ "delayacct" "acpi_osi=Linux" ]; kernelParams = [ "delayacct" "acpi_osi=Linux" ];
kernelPackages = inputs.pkgs.linuxPackages_zen; kernelPackages = inputs.pkgs.linuxPackages_xanmod_latest;
kernelPatches = kernelPatches =
let let
patches = patches =
@@ -61,6 +61,19 @@ inputs:
extraStructuredConfig = extraStructuredConfig =
{ FONT_CJK_16x16 = inputs.lib.kernel.yes; FONT_CJK_32x32 = inputs.lib.kernel.yes; }; { FONT_CJK_16x16 = inputs.lib.kernel.yes; FONT_CJK_32x32 = inputs.lib.kernel.yes; };
}; };
lantian =
{
patch = null;
# pick from xddxdd/nur-packages dce93a
extraStructuredConfig = with inputs.lib.kernel;
{
ACPI_PCI_SLOT = yes;
ENERGY_MODEL = yes;
PARAVIRT_TIME_ACCOUNTING = yes;
PM_AUTOSLEEP = yes;
WQ_POWER_EFFICIENT_DEFAULT = yes;
};
};
}; };
in in
builtins.map (name: { inherit name; } // patches.${name}) kernel.patches; builtins.map (name: { inherit name; } // patches.${name}) kernel.patches;