Many fixes and tweaks
* Fix tags (again?) * Make tag names more consistent * Remove prefix commands (not implemented well and not worth fixing) * Allow '-'s in tags * Fix /joke * Fix /members * Fix intel_hd issue match * Fix log analysis reply * Clearer log analysis messages It's weird to say the process failed when no issues were found. * Clippy * Final doc cleanup * Fix link expanding * Fix duplicate event filtering The other code simply does not work. ChannelId does have a method to grab members but I'm not sure whether it would work either. * Remove message resolution It's surprisingly hard to create an bug-free implementation. * Fix pluralkit detection * simplify tag codegen * commands: improve error handling in members unwrap() bad!!!11!! * events: use debug logs for pk checks * Revert "Remove message resolution" This reverts commit 0d9f224a81917212adafdeb2213f3cc11b44cf88. * Bring back prefix commands with "." (it's easier to type) * Add help * Fix messsage resolution * utils: factor out message resolution * Improve tag message * Disable VC support for message resolution for now * Improve prefix command usage Update on edit, display additional tip with wrong usage. * Check invoke_on_edit to display tip * Add defer in commands which make http requests * Apply tag sorting to slash commands too * handlers::error: `+=` -> `writeln!` * handlers::event: ignore own new messages * help: remove unneeded format! * optimize for size in release builds * nix: cleanup deployment expressions * nix: use treefmt * nix: update flake.lock Flake lock file updates: • Updated input 'fenix': 'github:nix-community/fenix/eb683549b7d76b12d1a009f888b91b70ed34485f' (2024-01-27) → 'github:nix-community/fenix/c53bb4a32f2fce7acf4e8e160a54779c4460ffdb' (2024-03-17) • Updated input 'fenix/rust-analyzer-src': 'github:rust-lang/rust-analyzer/596e5c77cf5b2b660b3ac2ce732fa0596c246d9b' (2024-01-26) → 'github:rust-lang/rust-analyzer/5ecace48f693afaa6adf8cb23086b651db3aec96' (2024-03-16) • Updated input 'nixpkgs': 'github:nixos/nixpkgs/4fddc9be4eaf195d631333908f2a454b03628ee5' (2024-01-25) → 'github:nixos/nixpkgs/34ad8c9f29a18b4dd97a9ad40ceb16954f24afe7' (2024-03-17) • Updated input 'pre-commit-hooks': 'github:cachix/pre-commit-hooks.nix/f56597d53fd174f796b5a7d3ee0b494f9e2285cc' (2024-01-20) → 'github:cachix/pre-commit-hooks.nix/5df5a70ad7575f6601d91f0efec95dd9bc619431' (2024-02-15) • Updated input 'procfile-nix': 'github:getchoo/procfile-nix/31a33e4264e5c6214844993c5b508fb3500ef5cd' (2024-01-27) → 'github:getchoo/procfile-nix/7a0ab379a4ab71c9deccaca9fb463e9aaea363d8' (2024-03-14) --------- Co-authored-by: seth <getchoo@tuta.io>
This commit is contained in:
parent
1ea08671fb
commit
9d0c022c68
38 changed files with 492 additions and 296 deletions
|
@ -1,9 +1,12 @@
|
|||
{
|
||||
inputs,
|
||||
self,
|
||||
flake-parts-lib,
|
||||
withSystem,
|
||||
...
|
||||
}: {
|
||||
flake.nixosModules.default = import ./module.nix self;
|
||||
flake.nixosModules.default = flake-parts-lib.importApply ./module.nix {
|
||||
inherit withSystem;
|
||||
};
|
||||
|
||||
perSystem = {
|
||||
lib,
|
||||
|
@ -13,8 +16,8 @@
|
|||
inputs',
|
||||
...
|
||||
}: let
|
||||
crossPkgsFor =
|
||||
{
|
||||
crossPkgs =
|
||||
rec {
|
||||
x86_64-linux = {
|
||||
x86_64 = pkgs.pkgsStatic;
|
||||
aarch64 = pkgs.pkgsCross.aarch64-multiplatform.pkgsStatic;
|
||||
|
@ -30,11 +33,13 @@
|
|||
aarch64 = pkgs.pkgsCross.aarch64-multiplatform.pkgsStatic;
|
||||
};
|
||||
|
||||
aarch64-darwin = crossPkgsFor.x86_64-darwin;
|
||||
aarch64-darwin = x86_64-darwin;
|
||||
}
|
||||
.${system};
|
||||
|
||||
exeFor = arch: let
|
||||
refractionFor = arch: let
|
||||
inherit (crossPkgs.${arch}.stdenv) cc;
|
||||
|
||||
target = "${arch}-unknown-linux-musl";
|
||||
target' = builtins.replaceStrings ["-"] ["_"] target;
|
||||
targetUpper = lib.toUpper target';
|
||||
|
@ -52,8 +57,8 @@
|
|||
};
|
||||
|
||||
refraction = self'.packages.refraction.override {
|
||||
lto = true;
|
||||
naersk = naersk';
|
||||
optimizeSize = true;
|
||||
};
|
||||
|
||||
newAttrs = {
|
||||
|
@ -62,26 +67,26 @@
|
|||
"CARGO_TARGET_${targetUpper}_RUSTFLAGS" = "-C target-feature=+crt-static";
|
||||
"CARGO_TARGET_${targetUpper}_LINKER" = newAttrs."CC_${target'}";
|
||||
};
|
||||
|
||||
inherit (crossPkgsFor.${arch}.stdenv) cc;
|
||||
in
|
||||
lib.getExe (
|
||||
refraction.overrideAttrs (lib.const newAttrs)
|
||||
);
|
||||
refraction.overrideAttrs newAttrs;
|
||||
|
||||
containerFor = arch:
|
||||
pkgs.dockerTools.buildLayeredImage {
|
||||
name = "refraction";
|
||||
tag = "latest-${arch}";
|
||||
contents = [pkgs.dockerTools.caCertificates];
|
||||
config.Cmd = [(exeFor arch)];
|
||||
config.Cmd = [
|
||||
(lib.getExe (refractionFor arch))
|
||||
];
|
||||
|
||||
architecture = crossPkgsFor.${arch}.go.GOARCH;
|
||||
architecture = crossPkgs.${arch}.go.GOARCH;
|
||||
};
|
||||
in {
|
||||
legacyPackages = {
|
||||
container-x86_64 = containerFor "x86_64";
|
||||
container-aarch64 = containerFor "aarch64";
|
||||
|
||||
mkPackagesFor = arch: {
|
||||
"refraction-static-${arch}" = refractionFor arch;
|
||||
"container-${arch}" = containerFor arch;
|
||||
};
|
||||
in {
|
||||
legacyPackages = lib.attrsets.mergeAttrsList (map mkPackagesFor ["x86_64" "aarch64"]);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
lib,
|
||||
stdenv,
|
||||
naersk,
|
||||
CoreFoundation,
|
||||
Security,
|
||||
SystemConfiguration,
|
||||
darwin,
|
||||
version,
|
||||
optimizeSize ? false,
|
||||
lto ? false,
|
||||
}:
|
||||
naersk.buildPackage {
|
||||
pname = "refraction";
|
||||
|
@ -23,13 +21,13 @@ naersk.buildPackage {
|
|||
];
|
||||
};
|
||||
|
||||
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [
|
||||
CoreFoundation
|
||||
Security
|
||||
SystemConfiguration
|
||||
];
|
||||
]);
|
||||
|
||||
cargoBuildFlags = lib.optionals optimizeSize ["-C" "codegen-units=1" "-C" "strip=symbols" "-C" "opt-level=z"];
|
||||
cargoBuildFlags = lib.optionals lto ["-C" "lto=thin" "-C" "embed-bitcode=yes" "-Zdylib-lto"];
|
||||
|
||||
meta = with lib; {
|
||||
mainProgram = "refraction";
|
||||
|
|
56
nix/dev.nix
56
nix/dev.nix
|
@ -5,24 +5,9 @@
|
|||
config,
|
||||
self',
|
||||
...
|
||||
}: {
|
||||
pre-commit.settings.hooks = {
|
||||
actionlint.enable = true;
|
||||
alejandra.enable = true;
|
||||
deadnix.enable = true;
|
||||
rustfmt.enable = true;
|
||||
statix.enable = true;
|
||||
nil.enable = true;
|
||||
prettier = {
|
||||
enable = true;
|
||||
excludes = ["flake.lock"];
|
||||
};
|
||||
};
|
||||
|
||||
procfiles.daemons.processes = {
|
||||
redis = lib.getExe' pkgs.redis "redis-server";
|
||||
};
|
||||
|
||||
}: let
|
||||
enableAll = lib.flip lib.genAttrs (lib.const {enable = true;});
|
||||
in {
|
||||
devShells.default = pkgs.mkShell {
|
||||
shellHook = ''
|
||||
${config.pre-commit.installationScript}
|
||||
|
@ -31,6 +16,7 @@
|
|||
packages = with pkgs; [
|
||||
# general
|
||||
actionlint
|
||||
nodePackages.prettier
|
||||
config.procfiles.daemons.package
|
||||
|
||||
# rust
|
||||
|
@ -50,6 +36,38 @@
|
|||
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||
};
|
||||
|
||||
formatter = pkgs.alejandra;
|
||||
treefmt = {
|
||||
projectRootFile = "flake.nix";
|
||||
|
||||
programs = enableAll [
|
||||
"alejandra"
|
||||
"deadnix"
|
||||
"prettier"
|
||||
"rustfmt"
|
||||
];
|
||||
|
||||
settings.global = {
|
||||
excludes = [
|
||||
"./target"
|
||||
"./flake.lock"
|
||||
"./Cargo.lock"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
pre-commit.settings = {
|
||||
settings.treefmt.package = config.treefmt.build.wrapper;
|
||||
|
||||
hooks = enableAll [
|
||||
"actionlint"
|
||||
"nil"
|
||||
"statix"
|
||||
"treefmt"
|
||||
];
|
||||
};
|
||||
|
||||
procfiles.daemons.processes = {
|
||||
redis = lib.getExe' pkgs.redis "redis-server";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
self: {
|
||||
{withSystem, ...}: {
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
|
@ -22,7 +22,9 @@ self: {
|
|||
in {
|
||||
options.services.refraction = {
|
||||
enable = mkEnableOption "refraction";
|
||||
package = mkPackageOption self.packages.${pkgs.stdenv.hostPlatform.system} "refraction" {};
|
||||
package = mkPackageOption (
|
||||
withSystem pkgs.stdenv.hostPlatform.system ({pkgs, ...}: pkgs)
|
||||
) "refraction" {};
|
||||
|
||||
user = mkOption {
|
||||
description = mdDoc ''
|
||||
|
@ -102,7 +104,7 @@ in {
|
|||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
Restart = "always";
|
||||
Restart = "on-failure";
|
||||
|
||||
EnvironmentFile = mkIf (cfg.environmentFile != null) cfg.environmentFile;
|
||||
|
||||
|
@ -122,8 +124,14 @@ in {
|
|||
ProtectKernelModules = true;
|
||||
ProtectKernelTunables = true;
|
||||
ProtectSystem = "strict";
|
||||
RestrictNamespaces = "uts ipc pid user cgroup";
|
||||
RestrictNamespaces = true;
|
||||
RestrictSUIDSGID = true;
|
||||
SystemCallArchitectures = "native";
|
||||
SystemCallFilter = [
|
||||
"@system-service"
|
||||
"~@resources"
|
||||
"~@privileged"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -12,14 +12,6 @@
|
|||
packages = {
|
||||
refraction = pkgs.callPackage ./derivation.nix {
|
||||
version = builtins.substring 0 7 self.rev or "dirty";
|
||||
|
||||
inherit
|
||||
(pkgs.darwin.apple_sdk.frameworks)
|
||||
CoreFoundation
|
||||
Security
|
||||
SystemConfiguration
|
||||
;
|
||||
|
||||
naersk = inputs.naersk.lib.${system};
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue