From 9cdc7590c4a1e7bc8abd2248acfdf7ad5dc0ca85 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 6 Aug 2024 23:25:40 -0400 Subject: [PATCH 01/16] chore(nix): drop flake-checks --- flake.lock | 16 ---------------- flake.nix | 16 ---------------- 2 files changed, 32 deletions(-) diff --git a/flake.lock b/flake.lock index 083a8213..54bf5da6 100644 --- a/flake.lock +++ b/flake.lock @@ -1,20 +1,5 @@ { "nodes": { - "flake-checks": { - "locked": { - "lastModified": 1726652014, - "narHash": "sha256-TdbcCjW6z3VsFg1uvrvCdp0pzFXUyP8qegp8dSmQuaE=", - "owner": "getchoo", - "repo": "flake-checks", - "rev": "108aa8f5a8a610ae14c1edb61017dd750b666ed6", - "type": "github" - }, - "original": { - "owner": "getchoo", - "repo": "flake-checks", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1727335715, @@ -33,7 +18,6 @@ }, "root": { "inputs": { - "flake-checks": "flake-checks", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay" } diff --git a/flake.nix b/flake.nix index e8c3db88..cc88cc86 100644 --- a/flake.nix +++ b/flake.nix @@ -4,8 +4,6 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - flake-checks.url = "github:getchoo/flake-checks"; - rust-overlay = { url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; @@ -15,7 +13,6 @@ outputs = { self, nixpkgs, - flake-checks, rust-overlay, }: let systems = [ @@ -27,19 +24,6 @@ forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system}); in { - checks = forAllSystems (pkgs: let - flake-checks' = flake-checks.lib.mkChecks { - inherit pkgs; - root = ./.; - }; - in { - check-actionlint = flake-checks'.actionlint; - check-alejandra = flake-checks'.alejandra; - check-deadnix = flake-checks'.deadnix; - check-rustfmt = flake-checks'.rustfmt; - check-statix = flake-checks'.statix; - }); - devShells = forAllSystems (pkgs: { default = pkgs.mkShell { packages = with pkgs; [ From 3b5abf3af89505e85c59b1d714c3d6705471cdf4 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 6 Aug 2024 23:26:02 -0400 Subject: [PATCH 02/16] style(nix): alejandra -> nixfmt-rfc-style --- flake.nix | 162 ++++++++++++++++++++++++--------------------- nix/derivation.nix | 34 ++++++---- nix/module.nix | 31 +++++---- nix/static.nix | 22 +++--- 4 files changed, 135 insertions(+), 114 deletions(-) diff --git a/flake.nix b/flake.nix index cc88cc86..ef3b8347 100644 --- a/flake.nix +++ b/flake.nix @@ -10,83 +10,91 @@ }; }; - outputs = { - self, - nixpkgs, - rust-overlay, - }: let - systems = [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; - - forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system}); - in { - devShells = forAllSystems (pkgs: { - default = pkgs.mkShell { - packages = with pkgs; [ - redis - - # linters & formatters - actionlint - nodePackages.prettier - - # rust tools - clippy - rustfmt - rust-analyzer - - # nix tools - self.formatter.${system} - deadnix - nil - statix - ]; - - inputsFrom = [self.packages.${pkgs.system}.refraction]; - RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}"; - }; - }); - - formatter = forAllSystems (pkgs: pkgs.alejandra); - - nixosModules.default = import ./nix/module.nix self; - - packages = forAllSystems ({ - lib, - pkgs, - system, - ... - }: let - packages' = self.packages.${system}; - - mkStatic = pkgs.callPackage ./nix/static.nix { - inherit (self.packages.${pkgs.system}) refraction; - rust-overlay = rust-overlay.packages.${system}; - }; - - mkContainerFor = refraction: - pkgs.dockerTools.buildLayeredImage { - name = "refraction"; - tag = "latest-${refraction.stdenv.hostPlatform.qemuArch}"; - config.Cmd = [(lib.getExe refraction)]; - inherit (refraction) architecture; + outputs = + { + self, + nixpkgs, + rust-overlay, + }: + let + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + + forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system}); + in + { + devShells = forAllSystems (pkgs: { + default = pkgs.mkShell { + packages = with pkgs; [ + redis + + # linters & formatters + actionlint + nodePackages.prettier + + # rust tools + clippy + rustfmt + rust-analyzer + + # nix tools + self.formatter.${system} + deadnix + nil + statix + ]; + + inputsFrom = [ self.packages.${pkgs.system}.refraction ]; + RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}"; }; - in { - refraction = pkgs.callPackage ./nix/derivation.nix {inherit self;}; - - static-x86_64 = mkStatic {arch = "x86_64";}; - static-aarch64 = mkStatic {arch = "aarch64";}; - container-x86_64 = mkContainerFor packages'.static-x86_64; - container-aarch64 = mkContainerFor packages'.static-aarch64; - - default = packages'.refraction; - }); - - overlays.default = _: prev: { - refraction = prev.callPackage ./nix/derivation.nix {inherit self;}; + }); + + formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style); + + nixosModules.default = import ./nix/module.nix self; + + packages = forAllSystems ( + { + lib, + pkgs, + system, + ... + }: + let + packages' = self.packages.${system}; + + mkStatic = pkgs.callPackage ./nix/static.nix { + inherit (self.packages.${pkgs.system}) refraction; + rust-overlay = rust-overlay.packages.${system}; + }; + + mkContainerFor = + refraction: + pkgs.dockerTools.buildLayeredImage { + name = "refraction"; + tag = "latest-${refraction.stdenv.hostPlatform.qemuArch}"; + config.Cmd = [ (lib.getExe refraction) ]; + inherit (refraction) architecture; + }; + in + { + refraction = pkgs.callPackage ./nix/derivation.nix { inherit self; }; + + static-x86_64 = mkStatic { arch = "x86_64"; }; + static-aarch64 = mkStatic { arch = "aarch64"; }; + container-x86_64 = mkContainerFor packages'.static-x86_64; + container-aarch64 = mkContainerFor packages'.static-aarch64; + + default = packages'.refraction; + } + ); + + overlays.default = _: prev: { + refraction = prev.callPackage ./nix/derivation.nix { inherit self; }; + }; }; - }; } diff --git a/nix/derivation.nix b/nix/derivation.nix index 0e86a181..94b81a03 100644 --- a/nix/derivation.nix +++ b/nix/derivation.nix @@ -31,19 +31,24 @@ rustPlatform.buildRustPackage { lockFile = ../Cargo.lock; }; - buildInputs = lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [ - CoreFoundation - Security - SystemConfiguration - ]); + buildInputs = lib.optionals stdenv.hostPlatform.isDarwin ( + with darwin.apple_sdk.frameworks; + [ + CoreFoundation + Security + SystemConfiguration + ] + ); - env = let - toRustFlags = lib.mapAttrs' ( - name: - lib.nameValuePair - "CARGO_PROFILE_RELEASE_${lib.toUpper (builtins.replaceStrings ["-"] ["_"] name)}" - ); - in + env = + let + toRustFlags = lib.mapAttrs' ( + name: + lib.nameValuePair "CARGO_PROFILE_RELEASE_${ + lib.toUpper (builtins.replaceStrings [ "-" ] [ "_" ] name) + }" + ); + in lib.optionalAttrs lto (toRustFlags { lto = "thin"; }) @@ -62,6 +67,9 @@ rustPlatform.buildRustPackage { description = "Discord bot for Prism Launcher"; homepage = "https://github.com/PrismLauncher/refraction"; license = licenses.gpl3Plus; - maintainers = with maintainers; [getchoo Scrumplex]; + maintainers = with maintainers; [ + getchoo + Scrumplex + ]; }; } diff --git a/nix/module.nix b/nix/module.nix index 5572e4be..7203e842 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -1,14 +1,15 @@ -self: { +self: +{ config, lib, pkgs, ... -}: let +}: +let cfg = config.services.refraction; defaultUser = "refraction"; - inherit - (lib) + inherit (lib) getExe literalExpression mdDoc @@ -19,10 +20,11 @@ self: { optionals types ; -in { +in +{ options.services.refraction = { enable = mkEnableOption "refraction"; - package = mkPackageOption self.packages.${pkgs.stdenv.hostPlatform.system} "refraction" {}; + package = mkPackageOption self.packages.${pkgs.stdenv.hostPlatform.system} "refraction" { }; user = mkOption { description = mdDoc '' @@ -84,10 +86,8 @@ in { systemd.services."refraction" = { enable = true; - wantedBy = ["multi-user.target"]; - after = - ["network.target"] - ++ optionals (cfg.redisUrl == "local") ["redis-refraction.service"]; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ] ++ optionals (cfg.redisUrl == "local") [ "redis-refraction.service" ]; script = '' ${getExe cfg.package} @@ -95,9 +95,10 @@ in { environment = { BOT_REDIS_URL = - if cfg.redisUrl == "local" - then "unix:${config.services.redis.servers.refraction.unixSocket}" - else cfg.redisUrl; + if cfg.redisUrl == "local" then + "unix:${config.services.redis.servers.refraction.unixSocket}" + else + cfg.redisUrl; }; serviceConfig = { @@ -141,9 +142,7 @@ in { }; }; - groups = mkIf (cfg.group == defaultUser) { - ${defaultUser} = {}; - }; + groups = mkIf (cfg.group == defaultUser) { ${defaultUser} = { }; }; }; }; } diff --git a/nix/static.nix b/nix/static.nix index 5d2c2bed..c147999b 100644 --- a/nix/static.nix +++ b/nix/static.nix @@ -3,7 +3,9 @@ refraction, rust-overlay, pkgsCross, -}: {arch}: let +}: +{ arch }: +let targets = with pkgsCross; { x86_64 = musl64.pkgsStatic; aarch64 = aarch64-multiplatform.pkgsStatic; @@ -11,17 +13,21 @@ getRustcTarget = pkgs: pkgs.stdenv.hostPlatform.rust.rustcTarget; toolchain = rust-overlay.rust.minimal.override { - extensions = ["rust-std"]; + extensions = [ "rust-std" ]; targets = lib.mapAttrsToList (lib.const getRustcTarget) targets; }; - mkRustPlatformWith = pkgs: + mkRustPlatformWith = + pkgs: pkgs.makeRustPlatform ( - lib.genAttrs ["cargo" "rustc"] (lib.const toolchain) + lib.genAttrs [ + "cargo" + "rustc" + ] (lib.const toolchain) ); rustPlatforms = lib.mapAttrs (lib.const mkRustPlatformWith) targets; in - refraction.override { - rustPlatform = rustPlatforms.${arch}; - optimizeSize = true; - } +refraction.override { + rustPlatform = rustPlatforms.${arch}; + optimizeSize = true; +} From 1f19bd515be3e82c35c42cc525e6b5d81d254db0 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 6 Aug 2024 23:27:40 -0400 Subject: [PATCH 03/16] refactor(nix): simplify forAllSystems --- flake.nix | 71 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/flake.nix b/flake.nix index ef3b8347..55a32aac 100644 --- a/flake.nix +++ b/flake.nix @@ -17,6 +17,7 @@ rust-overlay, }: let + inherit (nixpkgs) lib; systems = [ "x86_64-linux" "aarch64-linux" @@ -24,47 +25,49 @@ "aarch64-darwin" ]; - forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system}); + forAllSystems = lib.genAttrs systems; + nixpkgsFor = nixpkgs.legacyPackages; in { - devShells = forAllSystems (pkgs: { - default = pkgs.mkShell { - packages = with pkgs; [ - redis - - # linters & formatters - actionlint - nodePackages.prettier - - # rust tools - clippy - rustfmt - rust-analyzer - - # nix tools - self.formatter.${system} - deadnix - nil - statix - ]; - - inputsFrom = [ self.packages.${pkgs.system}.refraction ]; - RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}"; - }; - }); - - formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style); + devShells = forAllSystems ( + system: + let + pkgs = nixpkgsFor.${system}; + in + { + default = pkgs.mkShell { + packages = with pkgs; [ + redis + + # linters & formatters + actionlint + nodePackages.prettier + + # rust tools + clippy + rustfmt + rust-analyzer + + # nix tools + self.formatter.${system} + nil + statix + ]; + + inputsFrom = [ self.packages.${pkgs.system}.refraction ]; + RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}"; + }; + } + ); + + formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style); nixosModules.default = import ./nix/module.nix self; packages = forAllSystems ( - { - lib, - pkgs, - system, - ... - }: + system: let + pkgs = nixpkgsFor.${system}; packages' = self.packages.${system}; mkStatic = pkgs.callPackage ./nix/static.nix { From 3d87cf4b8fc026b1a8aa548e30401878c5c23e25 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 6 Aug 2024 23:29:44 -0400 Subject: [PATCH 04/16] ci: remove unused env var --- .github/workflows/update-flake.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/update-flake.yml b/.github/workflows/update-flake.yml index 23356023..6e04cad7 100644 --- a/.github/workflows/update-flake.yml +++ b/.github/workflows/update-flake.yml @@ -15,9 +15,6 @@ jobs: contents: write pull-requests: write - env: - PR_BRANCH: 'update-lockfiles' - steps: - name: Checkout repository uses: actions/checkout@v4 From 4b57942c5bb1d84c405046147f015202a883cc7f Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 6 Aug 2024 23:39:45 -0400 Subject: [PATCH 05/16] perf(nix): refactor mkStatic this should speed up evaluation a bit by caching all the things --- flake.nix | 12 ++++++------ nix/static.nix | 28 ++++++++++++++++------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/flake.nix b/flake.nix index 55a32aac..2d716232 100644 --- a/flake.nix +++ b/flake.nix @@ -71,17 +71,17 @@ packages' = self.packages.${system}; mkStatic = pkgs.callPackage ./nix/static.nix { - inherit (self.packages.${pkgs.system}) refraction; + inherit (packages') refraction; rust-overlay = rust-overlay.packages.${system}; }; - mkContainerFor = + containerize = refraction: pkgs.dockerTools.buildLayeredImage { name = "refraction"; - tag = "latest-${refraction.stdenv.hostPlatform.qemuArch}"; + tag = "latest-${refraction.passthru.architecture}"; config.Cmd = [ (lib.getExe refraction) ]; - inherit (refraction) architecture; + inherit (refraction.passthru) architecture; }; in { @@ -89,8 +89,8 @@ static-x86_64 = mkStatic { arch = "x86_64"; }; static-aarch64 = mkStatic { arch = "aarch64"; }; - container-x86_64 = mkContainerFor packages'.static-x86_64; - container-aarch64 = mkContainerFor packages'.static-aarch64; + container-x86_64 = containerize packages'.static-x86_64; + container-aarch64 = containerize packages'.static-aarch64; default = packages'.refraction; } diff --git a/nix/static.nix b/nix/static.nix index c147999b..94b30eab 100644 --- a/nix/static.nix +++ b/nix/static.nix @@ -4,30 +4,34 @@ rust-overlay, pkgsCross, }: -{ arch }: let - targets = with pkgsCross; { + crossPlatformFor = with pkgsCross; { x86_64 = musl64.pkgsStatic; aarch64 = aarch64-multiplatform.pkgsStatic; }; - getRustcTarget = pkgs: pkgs.stdenv.hostPlatform.rust.rustcTarget; toolchain = rust-overlay.rust.minimal.override { extensions = [ "rust-std" ]; - targets = lib.mapAttrsToList (lib.const getRustcTarget) targets; + targets = lib.mapAttrsToList (_: pkgs: pkgs.stdenv.hostPlatform.rust.rustcTarget) crossPlatformFor; }; - mkRustPlatformWith = - pkgs: + rustPlatformFor = lib.mapAttrs ( + _: pkgs: pkgs.makeRustPlatform ( lib.genAttrs [ "cargo" "rustc" - ] (lib.const toolchain) - ); - rustPlatforms = lib.mapAttrs (lib.const mkRustPlatformWith) targets; + ] (_: toolchain) + ) + ) crossPlatformFor; in -refraction.override { - rustPlatform = rustPlatforms.${arch}; +{ arch }: +(refraction.override { + rustPlatform = rustPlatformFor.${arch}; optimizeSize = true; -} +}).overrideAttrs + (old: { + passthru = old.passthru or { } // { + inherit toolchain; + }; + }) From fc012b86afb65d956268d9de04c99e000eba8407 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 6 Aug 2024 23:43:22 -0400 Subject: [PATCH 06/16] refactor(nix): cleanup package --- flake.nix | 4 +-- nix/derivation.nix | 75 ---------------------------------------------- nix/package.nix | 68 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 77 deletions(-) delete mode 100644 nix/derivation.nix create mode 100644 nix/package.nix diff --git a/flake.nix b/flake.nix index 2d716232..d55c0784 100644 --- a/flake.nix +++ b/flake.nix @@ -85,7 +85,7 @@ }; in { - refraction = pkgs.callPackage ./nix/derivation.nix { inherit self; }; + refraction = pkgs.callPackage ./nix/package.nix { }; static-x86_64 = mkStatic { arch = "x86_64"; }; static-aarch64 = mkStatic { arch = "aarch64"; }; @@ -97,7 +97,7 @@ ); overlays.default = _: prev: { - refraction = prev.callPackage ./nix/derivation.nix { inherit self; }; + refraction = prev.callPackage ./nix/package.nix { }; }; }; } diff --git a/nix/derivation.nix b/nix/derivation.nix deleted file mode 100644 index 94b81a03..00000000 --- a/nix/derivation.nix +++ /dev/null @@ -1,75 +0,0 @@ -{ - lib, - stdenv, - go, - rustPlatform, - darwin, - self, - lto ? true, - optimizeSize ? false, -}: -rustPlatform.buildRustPackage { - pname = "refraction"; - version = - (lib.importTOML ../Cargo.toml).package.version - + "-${self.shortRev or self.dirtyShortRev or "unknown-dirty"}"; - - __structuredAttrs = true; - - src = lib.fileset.toSource { - root = ../.; - fileset = lib.fileset.unions [ - ../src - ../build.rs - ../Cargo.lock - ../Cargo.toml - ../tags - ]; - }; - - cargoLock = { - lockFile = ../Cargo.lock; - }; - - buildInputs = lib.optionals stdenv.hostPlatform.isDarwin ( - with darwin.apple_sdk.frameworks; - [ - CoreFoundation - Security - SystemConfiguration - ] - ); - - env = - let - toRustFlags = lib.mapAttrs' ( - name: - lib.nameValuePair "CARGO_PROFILE_RELEASE_${ - lib.toUpper (builtins.replaceStrings [ "-" ] [ "_" ] name) - }" - ); - in - lib.optionalAttrs lto (toRustFlags { - lto = "thin"; - }) - // lib.optionalAttrs optimizeSize (toRustFlags { - codegen-units = "1"; - opt-level = "s"; - panic = "abort"; - strip = "symbols"; - }); - - # useful for container images - passthru.architecture = go.GOARCH; - - meta = with lib; { - mainProgram = "refraction"; - description = "Discord bot for Prism Launcher"; - homepage = "https://github.com/PrismLauncher/refraction"; - license = licenses.gpl3Plus; - maintainers = with maintainers; [ - getchoo - Scrumplex - ]; - }; -} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 00000000..4bc93e6a --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,68 @@ +{ + lib, + stdenv, + go, + rustPlatform, + lto ? !optimizeSize, + optimizeSize ? false, +}: + +let + fs = lib.fileset; + toRustFlags = flags: toString (lib.mapAttrsToList (name: value: "-C ${name}=${value}") flags); +in +assert lib.assertMsg (lto -> !optimizeSize) "`lto` and `optimizeSize` are mutually exclusive"; +rustPlatform.buildRustPackage rec { + pname = "refraction"; + inherit (passthru.cargoToml.package) version; + + src = fs.toSource { + root = ../.; + fileset = fs.intersection (fs.gitTracked ../.) ( + fs.unions [ + ../src + ../build.rs + ../Cargo.lock + ../Cargo.toml + ../tags + ] + ); + }; + + cargoLock.lockFile = ../Cargo.lock; + + # `panic=abort` breaks tests womp womp + doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform && !optimizeSize; + + env = { + RUSTFLAGS = toRustFlags ( + lib.optionalAttrs lto { + lto = "thin"; + embed-bicode = "yes"; + } + // lib.optionalAttrs optimizeSize { + codegen-units = "1"; + opt-level = "s"; + panic = "abort"; + strip = "symbols"; + } + ); + }; + + passthru = { + cargoToml = lib.importTOML ../Cargo.toml; + # For container images + dockerArchitecture = go.GOARCH; + }; + + meta = { + description = "Discord bot for Prism Launcher"; + homepage = "https://github.com/PrismLauncher/refraction"; + license = lib.licenses.gpl3Plus; + maintainers = with lib.maintainers; [ + getchoo + Scrumplex + ]; + mainProgram = "refraction"; + }; +} From c7086265ed5d06f90374351a536aad6f8474c036 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 6 Aug 2024 23:47:09 -0400 Subject: [PATCH 07/16] chore(nix): remove mdDoc from module --- nix/module.nix | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nix/module.nix b/nix/module.nix index 7203e842..4e6d8a69 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -12,7 +12,6 @@ let inherit (lib) getExe literalExpression - mdDoc mkEnableOption mkIf mkOption @@ -27,7 +26,7 @@ in package = mkPackageOption self.packages.${pkgs.stdenv.hostPlatform.system} "refraction" { }; user = mkOption { - description = mdDoc '' + description = '' User under which the service should run. If this is the default value, the user will be created, with the specified group as the primary group. @@ -40,7 +39,7 @@ in }; group = mkOption { - description = mdDoc '' + description = '' Group under which the service should run. If this is the default value, the group will be created. ''; @@ -52,7 +51,7 @@ in }; redisUrl = mkOption { - description = mdDoc '' + description = '' Connection to a redis server. If this needs to include credentials that shouldn't be world-readable in the Nix store, set environmentFile and override the `REDIS_URL` entry. @@ -66,7 +65,7 @@ in }; environmentFile = mkOption { - description = mdDoc '' + description = '' Environment file as defined in {manpage}`systemd.exec(5)` ''; type = types.nullOr types.path; From 098a3283dfedd7e313b925d7af22c469f1671fab Mon Sep 17 00:00:00 2001 From: seth Date: Wed, 7 Aug 2024 00:03:51 -0400 Subject: [PATCH 08/16] build(nix): use docker arch names for container --- .github/workflows/docker.yml | 30 +++++++++++++++++------------- flake.nix | 4 ++-- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c150bf69..a3ce7208 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,21 +2,24 @@ name: Docker on: push: - branches: ['main'] + branches: [ main ] pull_request: workflow_dispatch: jobs: build: name: Build image - runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - arch: [x86_64, aarch64] + arch: [ amd64, arm64 ] + + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - name: Install Nix uses: DeterminateSystems/nix-installer-action@v15 @@ -43,8 +46,10 @@ jobs: push: name: Push image - needs: build + + if: github.event_name == 'push' + runs-on: ubuntu-latest permissions: @@ -54,16 +59,15 @@ jobs: REGISTRY: ghcr.io USERNAME: ${{ github.actor }} - if: github.event_name == 'push' - steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - name: Determine image name run: | echo "IMAGE_NAME=${REPOSITORY,,}" >> "$GITHUB_ENV" env: - REPOSITORY: '${{ github.repository }}' + REPOSITORY: ${{ github.repository }} - name: Download images uses: actions/download-artifact@v4 @@ -83,15 +87,15 @@ jobs: run: | set -eu - architectures=("x86_64" "aarch64") + architectures=("amd64" "arm64") for arch in "${architectures[@]}"; do docker load < images/container-"$arch"/*.tar.gz docker tag refraction:latest-"$arch" "$TAG"-"$arch" - docker push ${{ env.TAG }}-"$arch" + docker push "$TAG"-"$arch" done docker manifest create "$TAG" \ - --amend "$TAG"-x86_64 \ - --amend "$TAG"-aarch64 + --amend "$TAG"-amd64 \ + --amend "$TAG"-arm64 docker manifest push "$TAG" diff --git a/flake.nix b/flake.nix index d55c0784..b0092186 100644 --- a/flake.nix +++ b/flake.nix @@ -89,8 +89,8 @@ static-x86_64 = mkStatic { arch = "x86_64"; }; static-aarch64 = mkStatic { arch = "aarch64"; }; - container-x86_64 = containerize packages'.static-x86_64; - container-aarch64 = containerize packages'.static-aarch64; + container-amd64 = containerize packages'.static-x86_64; + container-arm64 = containerize packages'.static-aarch64; default = packages'.refraction; } From 62947a9ff16514269f540e25bbf66c728b94129f Mon Sep 17 00:00:00 2001 From: seth Date: Wed, 7 Aug 2024 04:09:28 -0400 Subject: [PATCH 09/16] build(nix): drop rust-overlay nixpkgs works well enough and gives us a good buffer in dealing with compiler regressions --- flake.lock | 23 +---------------------- flake.nix | 21 ++------------------- nix/containerize.nix | 9 +++++++++ nix/static.nix | 32 ++------------------------------ 4 files changed, 14 insertions(+), 71 deletions(-) create mode 100644 nix/containerize.nix diff --git a/flake.lock b/flake.lock index 54bf5da6..08f3592e 100644 --- a/flake.lock +++ b/flake.lock @@ -18,28 +18,7 @@ }, "root": { "inputs": { - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" - } - }, - "rust-overlay": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1727404165, - "narHash": "sha256-kZCiYpQJBZ3kL9QymS88mCxpQwqo8KqvZeHk6LATuY8=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "76f0a61e733259e1034dd6523e039d04932ffefc", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index b0092186..c605a60c 100644 --- a/flake.nix +++ b/flake.nix @@ -3,18 +3,12 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - - rust-overlay = { - url = "github:oxalica/rust-overlay"; - inputs.nixpkgs.follows = "nixpkgs"; - }; }; outputs = { self, nixpkgs, - rust-overlay, }: let inherit (nixpkgs) lib; @@ -70,19 +64,8 @@ pkgs = nixpkgsFor.${system}; packages' = self.packages.${system}; - mkStatic = pkgs.callPackage ./nix/static.nix { - inherit (packages') refraction; - rust-overlay = rust-overlay.packages.${system}; - }; - - containerize = - refraction: - pkgs.dockerTools.buildLayeredImage { - name = "refraction"; - tag = "latest-${refraction.passthru.architecture}"; - config.Cmd = [ (lib.getExe refraction) ]; - inherit (refraction.passthru) architecture; - }; + mkStatic = pkgs.callPackage ./nix/static.nix { }; + containerize = pkgs.callPackage ./nix/containerize.nix { }; in { refraction = pkgs.callPackage ./nix/package.nix { }; diff --git a/nix/containerize.nix b/nix/containerize.nix new file mode 100644 index 00000000..558a7c89 --- /dev/null +++ b/nix/containerize.nix @@ -0,0 +1,9 @@ +{ lib, dockerTools }: +refraction: + +dockerTools.buildLayeredImage { + name = "refraction"; + tag = "latest-${refraction.passthru.dockerArchitecture}"; + config.Cmd = [ (lib.getExe refraction) ]; + architecture = refraction.passthru.dockerArchitecture; +} diff --git a/nix/static.nix b/nix/static.nix index 94b30eab..8df03c80 100644 --- a/nix/static.nix +++ b/nix/static.nix @@ -1,37 +1,9 @@ -{ - lib, - refraction, - rust-overlay, - pkgsCross, -}: +{ pkgsCross }: let crossPlatformFor = with pkgsCross; { x86_64 = musl64.pkgsStatic; aarch64 = aarch64-multiplatform.pkgsStatic; }; - - toolchain = rust-overlay.rust.minimal.override { - extensions = [ "rust-std" ]; - targets = lib.mapAttrsToList (_: pkgs: pkgs.stdenv.hostPlatform.rust.rustcTarget) crossPlatformFor; - }; - - rustPlatformFor = lib.mapAttrs ( - _: pkgs: - pkgs.makeRustPlatform ( - lib.genAttrs [ - "cargo" - "rustc" - ] (_: toolchain) - ) - ) crossPlatformFor; in { arch }: -(refraction.override { - rustPlatform = rustPlatformFor.${arch}; - optimizeSize = true; -}).overrideAttrs - (old: { - passthru = old.passthru or { } // { - inherit toolchain; - }; - }) +crossPlatformFor.${arch}.callPackage ./package.nix { optimizeSize = true; } From 02cf98ee4bd365da631ceaa8a51f0eccfc0ec5c2 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 6 Aug 2024 23:59:03 -0400 Subject: [PATCH 10/16] ci: simplify --- .github/workflows/check.yml | 66 ------------------------- .github/workflows/ci.yml | 79 ++++++++++++++++++++++++++++++ .github/workflows/clippy.yml | 47 ++++++++++++++++++ .github/workflows/docker.yml | 20 ++++++-- .github/workflows/nix.yml | 52 -------------------- .github/workflows/update-flake.yml | 4 +- flake.nix | 18 +++++++ nix/clippy.nix | 39 +++++++++++++++ 8 files changed, 202 insertions(+), 123 deletions(-) delete mode 100644 .github/workflows/check.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/clippy.yml delete mode 100644 .github/workflows/nix.yml create mode 100644 nix/clippy.nix diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index ced6425f..00000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Check - -on: - push: - branches: ['main'] - pull_request: - -jobs: - rustfmt: - name: Run rustfmt - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - components: rustfmt - - - name: Setup Rust cache - uses: Swatinem/rust-cache@v2 - - - name: Run rustfmt - run: cargo fmt --all -- --check - - clippy: - name: Run Clippy scan - runs-on: ubuntu-latest - - permissions: - security-events: write - - steps: - - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - components: clippy - - - name: Setup Rust cache - uses: Swatinem/rust-cache@v2 - - - name: Install SARIF tools - run: cargo install clippy-sarif sarif-fmt - - - name: Fetch Cargo deps - run: cargo fetch --locked - - - name: Run Clippy - continue-on-error: true - run: | - cargo clippy \ - --all-features \ - --all-targets \ - --message-format=json \ - | clippy-sarif | tee /tmp/clippy.sarif | sarif-fmt - - - name: Upload results - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: /tmp/clippy.sarif - wait-for-processing: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..f54bdf23 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,79 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +jobs: + build: + name: Build (${{ matrix.os }}) + + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + use-nix: true + - os: windows-latest + use-nix: false + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust + if: ${{ !matrix.use-nix }} + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Install Nix + if: ${{ matrix.use-nix }} + uses: DeterminateSystems/nix-installer-action@v15 + + - name: Setup Nix cache + if: ${{ matrix.use-nix }} + uses: DeterminateSystems/magic-nix-cache-action@v8 + + - name: Build + if: ${{ !matrix.use-nix }} + run: cargo build --locked + + - name: Build + if: ${{ matrix.use-nix }} + run: nix build --print-build-logs .#refraction-debug + + flake: + name: Flake checks + + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v15 + + - name: Setup Nix cache + uses: DeterminateSystems/magic-nix-cache-action@v8 + + - name: Run checks + run: | + nix flake check --print-build-logs --show-trace + + # Make sure all above jobs finished successfully + release-gate: + name: CI Release gate + needs: [build, flake] + + if: ${{ always() }} + + runs-on: ubuntu-latest + + steps: + - name: Exit with error + if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} + run: exit 1 diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml new file mode 100644 index 00000000..8834daa5 --- /dev/null +++ b/.github/workflows/clippy.yml @@ -0,0 +1,47 @@ +name: Clippy + +on: + push: + branches: [main] + paths: + - 'Cargo.toml' + - 'Cargo.lock' + - '**.rs' + pull_request: + paths: + - 'Cargo.toml' + - 'Cargo.lock' + - '**.rs' + workflow_dispatch: + +jobs: + clippy: + name: Run scan + + runs-on: ubuntu-latest + + permissions: + security-events: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v13 + + - name: Setup Nix cache + uses: DeterminateSystems/magic-nix-cache-action@v7 + + - name: Generate sarif report + id: clippy-run + run: | + nix build --print-build-logs .#clippy-report + [ -L result ] || exit 1 + echo "sarif-file=$(readlink -f result)" >> "$GITHUB_OUTPUT" + + - name: Upload results + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: ${{ steps.clippy-run.outputs.sarif-file }} + wait-for-processing: true diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a3ce7208..413b3063 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,7 +2,7 @@ name: Docker on: push: - branches: [ main ] + branches: [main] pull_request: workflow_dispatch: @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - arch: [ amd64, arm64 ] + arch: [amd64, arm64] runs-on: ubuntu-latest @@ -44,11 +44,25 @@ jobs: if-no-files-found: error retention-days: 3 + # Make sure all above jobs finished successfully + release-gate: + name: Docker Release gate + needs: [build] + + if: ${{ always() }} + + runs-on: ubuntu-latest + + steps: + - name: Exit with error + if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} + run: exit 1 + push: name: Push image needs: build - if: github.event_name == 'push' + if: ${{ github.event_name == 'push' }} runs-on: ubuntu-latest diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml deleted file mode 100644 index ec472fa0..00000000 --- a/.github/workflows/nix.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Nix - -on: - push: - branches: ['main'] - pull_request: - workflow_dispatch: - -jobs: - build: - name: Build - strategy: - matrix: - os: [ubuntu-latest, macos-latest] - - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@v15 - - - name: Setup Nix cache - uses: DeterminateSystems/magic-nix-cache-action@v8 - - - name: Build refraction - run: nix build --fallback --print-build-logs - - check: - name: Check flake - - strategy: - matrix: - os: [ubuntu-latest, macos-latest] - - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@v15 - - - name: Setup Nix cache - uses: DeterminateSystems/magic-nix-cache-action@v8 - - - name: Run checks - run: | - nix flake check --print-build-logs --show-trace diff --git a/.github/workflows/update-flake.yml b/.github/workflows/update-flake.yml index 6e04cad7..6d17418c 100644 --- a/.github/workflows/update-flake.yml +++ b/.github/workflows/update-flake.yml @@ -24,9 +24,9 @@ jobs: - name: Update flake.lock id: update - uses: DeterminateSystems/update-flake-lock@main + uses: DeterminateSystems/update-flake-lock@v23 with: - pr-title: "nix: update flake.lock" + pr-title: 'nix: update flake.lock' - name: Enable Pull Request Automerge uses: peter-evans/enable-pull-request-automerge@v3 diff --git a/flake.nix b/flake.nix index c605a60c..f42f4eb8 100644 --- a/flake.nix +++ b/flake.nix @@ -58,6 +58,24 @@ nixosModules.default = import ./nix/module.nix self; + # For CI + legacyPackages = forAllSystems ( + system: + let + pkgs = nixpkgsFor.${system}; + in + { + clippy-report = pkgs.callPackage ./nix/clippy.nix { inherit (self.packages.${system}) refraction; }; + + refraction-debug = (self.packages.${system}.refraction.override { lto = false; }).overrideAttrs ( + finalAttrs: _: { + cargoBuildType = "debug"; + cargoCheckType = finalAttrs.cargoBuildType; + } + ); + } + ); + packages = forAllSystems ( system: let diff --git a/nix/clippy.nix b/nix/clippy.nix new file mode 100644 index 00000000..9c360a9e --- /dev/null +++ b/nix/clippy.nix @@ -0,0 +1,39 @@ +{ + cargo, + clippy, + clippy-sarif, + refraction, + rustPlatform, + sarif-fmt, + stdenv, +}: + +stdenv.mkDerivation { + pname = "${refraction.pname}-sarif-report"; + inherit (refraction) + version + src + cargoDeps + buildInputs + ; + + nativeBuildInputs = [ + cargo + clippy + clippy-sarif + rustPlatform.cargoSetupHook + sarif-fmt + ]; + + buildPhase = '' + cargo clippy \ + --all-features \ + --all-targets \ + --tests \ + --message-format=json \ + | clippy-sarif | tee $out | sarif-fmt + ''; + + dontInstall = true; + dontFixup = true; +} From d6d5b25b9c6180e4caec5c51d26bd768d388fe88 Mon Sep 17 00:00:00 2001 From: seth Date: Wed, 21 Aug 2024 04:29:37 -0400 Subject: [PATCH 11/16] chore(nix): fix nixpkgs flake ref they are *technically* case sensitive --- flake.lock | 4 ++-- flake.nix | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 08f3592e..57965550 100644 --- a/flake.lock +++ b/flake.lock @@ -4,13 +4,13 @@ "locked": { "lastModified": 1727335715, "narHash": "sha256-1uw3y94dA4l22LkqHRIsb7qr3rV5XdxQFqctINfx8Cc=", - "owner": "nixos", + "owner": "NixOS", "repo": "nixpkgs", "rev": "28b5b8af91ffd2623e995e20aee56510db49001a", "type": "github" }, "original": { - "owner": "nixos", + "owner": "NixOS", "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" diff --git a/flake.nix b/flake.nix index f42f4eb8..d255c307 100644 --- a/flake.nix +++ b/flake.nix @@ -1,9 +1,7 @@ { description = "Discord bot for Prism Launcher"; - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - }; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; outputs = { From d42eb94ce5f8058a3944e8af8b526c400115418d Mon Sep 17 00:00:00 2001 From: seth Date: Sun, 8 Sep 2024 22:40:08 -0400 Subject: [PATCH 12/16] chore: don't use Message::is_own() --- src/handlers/event/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handlers/event/mod.rs b/src/handlers/event/mod.rs index 528317dd..efaca475 100644 --- a/src/handlers/event/mod.rs +++ b/src/handlers/event/mod.rs @@ -42,7 +42,7 @@ pub async fn handle( // ignore new messages from bots // note: the webhook_id check allows us to still respond to PK users if (new_message.author.bot && new_message.webhook_id.is_none()) - || new_message.is_own(ctx) + || (new_message.author == **ctx.cache.current_user()) { trace!("Ignoring message {} from bot", new_message.id); return Ok(()); From e6b26af253076052f2d055454467c68e2fd5f033 Mon Sep 17 00:00:00 2001 From: seth Date: Sun, 8 Sep 2024 22:53:50 -0400 Subject: [PATCH 13/16] fix: ensure http client user agent is set --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 848fad89..0a4ec235 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,7 +58,7 @@ async fn setup( trace!("Redis connection looks good!"); } - let http_client = api::HttpClient::default(); + let http_client = ::default(); let octocrab = octocrab::instance(); let data = Data { From 127b1783255c83f0591d197cbf8ec0aa3c601186 Mon Sep 17 00:00:00 2001 From: seth Date: Mon, 11 Nov 2024 17:05:57 -0500 Subject: [PATCH 14/16] refactor(nix): re-use overlay for pure packages --- flake.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index d255c307..3a866c3b 100644 --- a/flake.nix +++ b/flake.nix @@ -80,11 +80,13 @@ pkgs = nixpkgsFor.${system}; packages' = self.packages.${system}; + refractionPackages = lib.makeScope pkgs.newScope (lib.flip self.overlays.default pkgs); + mkStatic = pkgs.callPackage ./nix/static.nix { }; containerize = pkgs.callPackage ./nix/containerize.nix { }; in { - refraction = pkgs.callPackage ./nix/package.nix { }; + inherit (refractionPackages) refraction; static-x86_64 = mkStatic { arch = "x86_64"; }; static-aarch64 = mkStatic { arch = "aarch64"; }; @@ -95,8 +97,8 @@ } ); - overlays.default = _: prev: { - refraction = prev.callPackage ./nix/package.nix { }; + overlays.default = final: _: { + refraction = final.callPackage ./nix/package.nix { }; }; }; } From b42c6780df963af1a66125c8bd57120f9d379e37 Mon Sep 17 00:00:00 2001 From: seth Date: Mon, 11 Nov 2024 17:24:10 -0500 Subject: [PATCH 15/16] ci: add flake checks --- flake.nix | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/flake.nix b/flake.nix index 3a866c3b..52f0c33c 100644 --- a/flake.nix +++ b/flake.nix @@ -21,6 +21,29 @@ nixpkgsFor = nixpkgs.legacyPackages; in { + checks = forAllSystems ( + system: + let + pkgs = nixpkgsFor.${system}; + mkCheck = + name: deps: script: + pkgs.runCommand name { nativeBuildInputs = deps; } '' + ${script} + touch $out + ''; + in + { + actionlint = mkCheck "check-actionlint" [ pkgs.actionlint ] "actionlint ${./.github/workflows}/*"; + deadnix = mkCheck "check-deadnix" [ pkgs.deadnix ] "deadnix --fail ${self}"; + statix = mkCheck "check-statix" [ pkgs.statix ] "statix check ${self}"; + nixfmt = mkCheck "check-nixfmt" [ pkgs.nixfmt-rfc-style ] "nixfmt --check ${self}"; + rustfmt = mkCheck "check-rustfmt" [ + pkgs.cargo + pkgs.rustfmt + ] "cd ${self} && cargo fmt -- --check"; + } + ); + devShells = forAllSystems ( system: let From 4f7edb26340f44f1414ec8704dedeaa29f4bd37d Mon Sep 17 00:00:00 2001 From: seth Date: Mon, 11 Nov 2024 17:49:57 -0500 Subject: [PATCH 16/16] chore: fix warnings for rust 2024 --- src/storage/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/storage/mod.rs b/src/storage/mod.rs index e482b4ff..1aad0bee 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -35,7 +35,7 @@ impl Storage { let mut con = self.client.get_multiplexed_async_connection().await?; // Just store some value. We only care about the presence of this key - con.set_ex(key, 0, 7 * 24 * 60 * 60).await?; // 1 week + () = con.set_ex(key, 0, 7 * 24 * 60 * 60).await?; // 1 week Ok(()) } @@ -54,7 +54,8 @@ impl Storage { debug!("Caching launcher version as {version}"); let mut con = self.client.get_multiplexed_async_connection().await?; - con.set_ex(LAUNCHER_VERSION_KEY, version, 24 * 60 * 60) + () = con + .set_ex(LAUNCHER_VERSION_KEY, version, 24 * 60 * 60) .await?; // 1 day Ok(()) @@ -73,7 +74,8 @@ impl Storage { debug!("Caching stargazer count as {stargazers}"); let mut con = self.client.get_multiplexed_async_connection().await?; - con.set_ex(LAUNCHER_STARGAZER_KEY, stargazers, 60 * 60) + () = con + .set_ex(LAUNCHER_STARGAZER_KEY, stargazers, 60 * 60) .await?; Ok(())