From 6a67b7382408253c86049cffa92d3e936c898138 Mon Sep 17 00:00:00 2001 From: Will Leinweber Date: Thu, 30 Oct 2025 10:19:13 +0100 Subject: [PATCH] Housekeeping updates - Drop custom crunchydata/nixpkgs version of crystal and use upstream nipxkgs. It's come a long way in the last few years, so it's nice not not need any custom stuff - Drop flake-utils - Update crystal 1.11 -> 1.16 - Update all shards --- flake.lock | 120 ++------------------------------- flake.nix | 153 +++++++++++++++++++++--------------------- shard.lock | 14 ++-- shards.nix | 48 ++++++------- src/client/cluster.cr | 8 +-- 5 files changed, 120 insertions(+), 223 deletions(-) diff --git a/flake.lock b/flake.lock index baef2ff..5e9dc66 100644 --- a/flake.lock +++ b/flake.lock @@ -1,64 +1,12 @@ { "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, - "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "lastGoodStaticBoehmgc": { - "locked": { - "lastModified": 1710266477, - "narHash": "sha256-oChjOWfSxtY5508wFhQQ/MS092+Xxzfj9vnv53VNHCE=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "14feac318eefa31d936d9b6a2aacb1928899abfe", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "14feac318eefa31d936d9b6a2aacb1928899abfe", - "type": "github" - } - }, "nix-filter": { "locked": { - "lastModified": 1710156097, - "narHash": "sha256-1Wvk8UP7PXdf8bCCaEoMnOT1qe5/Duqgj+rL8sRQsSM=", + "lastModified": 1757882181, + "narHash": "sha256-+cCxYIh2UNalTz364p+QYmWHs0P+6wDhiWR4jDIKQIU=", "owner": "numtide", "repo": "nix-filter", - "rev": "3342559a24e85fc164b295c3444e8a139924675b", + "rev": "59c44d1909c72441144b93cf0f054be7fe764de5", "type": "github" }, "original": { @@ -69,11 +17,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1711593151, - "narHash": "sha256-/9NCoPI7fqJIN8viONsY9X0fAeq8jc3GslFCO0ky6TQ=", + "lastModified": 1761656231, + "narHash": "sha256-EiED5k6gXTWoAIS8yQqi5mAX6ojnzpHwAQTS3ykeYMg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "bb2b73df7bcfbd2dd55ff39b944d70547d53c267", + "rev": "e99366c665bdd53b7b500ccdc5226675cfc51f45", "type": "github" }, "original": { @@ -83,64 +31,10 @@ "type": "github" } }, - "nixpkgs-crunchy": { - "inputs": { - "flake-utils": "flake-utils_2", - "lastGoodStaticBoehmgc": "lastGoodStaticBoehmgc", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1711620066, - "narHash": "sha256-RJZTdHUdznGxnWP+dvcrClGg8ctYggAlIrc4drujtUA=", - "owner": "crunchydata", - "repo": "nixpkgs", - "rev": "cafe229c653d9961f7d0b2123fccb8488d8c9c42", - "type": "github" - }, - "original": { - "owner": "crunchydata", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { - "flake-utils": "flake-utils", "nix-filter": "nix-filter", - "nixpkgs": "nixpkgs", - "nixpkgs-crunchy": "nixpkgs-crunchy" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index 53551bf..193829b 100644 --- a/flake.nix +++ b/flake.nix @@ -3,95 +3,98 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - nixpkgs-crunchy = { url = "github:crunchydata/nixpkgs"; inputs.nixpkgs.follows = "nixpkgs"; }; nix-filter.url = "github:numtide/nix-filter"; }; - outputs = { self, nixpkgs, nixpkgs-crunchy, flake-utils, nix-filter }: + outputs = { nixpkgs, nix-filter, ... }: let - systems = builtins.map (a: a.system) (builtins.catAttrs "crystal" (builtins.attrValues nixpkgs-crunchy.outputs.packages)); + forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed; filterSrc = files: (nix-filter.lib { root = ./.; include = [ "src" "spec" ] ++ files; }); - in - flake-utils.lib.eachSystem systems (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - crunchy = nixpkgs-crunchy.packages.${system}; - - crystal = crunchy.crystal.override { extraBuildInputs = [ pkgs.libssh2 ]; }; - crystalStatic = crunchy.crystalStatic.override { extraBuildInputs = [ pkgs.pkgsStatic.libssh2 ]; }; - check = pkgs.writeScriptBin "check" "nix build .#check --keep-going --print-build-logs"; - shardFiles = [ "shard.lock" "shards.nix" "shard.yml" ]; - src = filterSrc (shardFiles ++ [ "Readme" "Changelog" ]); - specSrc = filterSrc shardFiles; - lintSrc = filterSrc [ ".ameba.yml" ]; + perSystemOutputs = system: + let + pkgs = nixpkgs.legacyPackages.${system}; - darwinBuildInputs = [ - pkgs.darwin.apple_sdk.frameworks.Foundation - pkgs.darwin.apple_sdk.frameworks.Security - ]; + crystal = pkgs.crystal; - mkPkgArgs = { inherit self src; doCheck = false; }; - - # NOTE: currently (2023-11-29) `nix flake check` fails on x86 macs due to - # error: don't yet have a `targetPackages.darwin.LibsystemCross for x86_64-apple-darwin` - # so only have a static package on the other platforms for now. - # some maybe relevant issues: - # https://github.com/NixOS/nixpkgs/pull/256590 - # https://github.com/NixOS/nixpkgs/issues/180771 - # https://github.com/NixOS/nixpkgs/issues/270375 - static = if system == "x86_64-darwin" then null else "static"; - in - rec { - packages = { - default = crystal.mkPkg mkPkgArgs; - ${static} = crystalStatic.mkPkg mkPkgArgs; - check = pkgs.linkFarmFromDrvs "cb-all-checks" (builtins.attrValues checks); - }; + check = pkgs.writeScriptBin "check" "nix build .#check --keep-going --print-build-logs"; + shardFiles = [ "shard.lock" "shards.nix" "shard.yml" ]; + src = filterSrc (shardFiles ++ [ "Readme" "Changelog" ]); + specSrc = filterSrc shardFiles; + lintSrc = filterSrc [ ".ameba.yml" ]; - devShells.default = pkgs.mkShell { - buildInputs = with crunchy; [ crystal2nix ameba ] - ++ [ crystal check ] - ++ [ pkgs.pcre2 pkgs.pcre pkgs.libyaml ] - ++ pkgs.lib.optionals pkgs.stdenv.isDarwin darwinBuildInputs; - }; + # returns a function that can read a value for a key in shard.yml + shardValue = src: key: + let + file = src + "/shard.yml"; + contents = builtins.readFile file; + match = builtins.split (key + ": ([-a-zA-Z0-9\.]+).*\n") contents; + in + if builtins.length match == 3 then + builtins.head (builtins.head (builtins.tail match)) + else + builtins.traceVerbose "file ${file} doesn't have top-level key '${key}'" null; - checks = { - format = pkgs.stdenvNoCC.mkDerivation { - name = "format"; - src = specSrc; - installPhase = "mkdir $out && crystal tool format --check"; - nativeBuildInputs = [ crystal ]; - dontPatch = true; - dontConfigure = true; - dontBuild = true; - dontFixup = true; + version = shardValue src "version"; + in + rec { + packages = { + default = crystal.buildCrystalPackage { + inherit src version; + pname = "cb"; + format = "shards"; + shardsFile = ./shards.nix; + buildInputs = [ pkgs.libssh2 ]; + doCheck = false; + }; + check = pkgs.linkFarmFromDrvs "cb-all-checks" (builtins.attrValues checks); }; - ameba = pkgs.stdenvNoCC.mkDerivation { - name = "ameba"; - src = lintSrc; - installPhase = "mkdir $out && ameba"; - nativeBuildInputs = [ crunchy.ameba ]; - dontPatch = true; - dontConfigure = true; - dontBuild = true; - dontFixup = true; + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ crystal2nix ameba shards libssh2 ] + ++ [ crystal check ]; }; - specs = crystal.buildCrystalPackage { - name = "specs"; - src = specSrc; - HOME = "/tmp"; # needed just for cb, not in general - installPhase = "mkdir $out && crystal spec --progress"; - shardsFile = specSrc + "/shards.nix"; - doCheck = false; - dontPatch = true; - dontBuild = true; - dontFixup = true; + checks = { + format = pkgs.stdenvNoCC.mkDerivation { + name = "format"; + src = specSrc; + installPhase = "mkdir $out && crystal tool format --check"; + nativeBuildInputs = [ crystal ]; + dontPatch = true; + dontConfigure = true; + dontBuild = true; + dontFixup = true; + }; + + ameba = pkgs.stdenvNoCC.mkDerivation { + name = "ameba"; + src = lintSrc; + installPhase = "mkdir $out && ameba"; + nativeBuildInputs = [ pkgs.ameba ]; + dontPatch = true; + dontConfigure = true; + dontBuild = true; + dontFixup = true; + }; + + specs = crystal.buildCrystalPackage { + name = "specs"; + src = specSrc; + buildInputs = [ pkgs.libssh2 ]; + installPhase = "mkdir $out && HOME=$TMP crystal spec --progress"; + shardsFile = specSrc + "/shards.nix"; + doCheck = false; + dontPatch = true; + dontBuild = true; + dontFixup = true; + }; }; }; - } - ); + in + { + packages = forAllSystems (system: (perSystemOutputs system).packages); + devShells = forAllSystems (system: (perSystemOutputs system).devShells); + checks = forAllSystems (system: (perSystemOutputs system).checks); + }; } diff --git a/shard.lock b/shard.lock index 668345d..a89e2cb 100644 --- a/shard.lock +++ b/shard.lock @@ -6,27 +6,27 @@ shards: backtracer: git: https://github.com/sija/backtracer.cr.git - version: 1.2.2 + version: 1.2.4 db: git: https://github.com/crystal-lang/crystal-db.git - version: 0.11.0 + version: 0.13.1 pg: git: https://github.com/will/crystal-pg.git - version: 0.26.0 + version: 0.29.0 promise: git: https://github.com/spider-gazelle/promise.git - version: 3.0.0 + version: 3.2.0 raven: git: https://github.com/sija/raven.cr.git - version: 1.9.2 + version: 1.9.5 retriable: git: https://github.com/sija/retriable.cr.git - version: 0.2.4 + version: 0.2.5 spectator: git: https://gitlab.com/arctic-fox/spectator.git @@ -34,7 +34,7 @@ shards: ssh2: git: https://github.com/spider-gazelle/ssh2.cr.git - version: 1.7.0 + version: 1.7.2 tallboy: git: https://github.com/epoch/tallboy.git diff --git a/shards.nix b/shards.nix index 990cea0..0c76c0f 100644 --- a/shards.nix +++ b/shards.nix @@ -1,50 +1,50 @@ { - any_hash = { + "any_hash" = { url = "https://github.com/sija/any_hash.cr.git"; rev = "v0.2.5"; sha256 = "0qfddwaalcz7f95xbr42cvwh1wzifr5m27lp735fjz2y4xx2c5kj"; }; - backtracer = { + "backtracer" = { url = "https://github.com/sija/backtracer.cr.git"; - rev = "v1.2.2"; - sha256 = "1rknyylsi14m7i77x7c3138wdw27i4f6sd78m3srw851p47bwr20"; + rev = "v1.2.4"; + sha256 = "0v4wcf5lchgv9amsf5w9ajxmnp4gn0qmsxwzajbd8hs3a0dqzxkg"; }; - db = { + "db" = { url = "https://github.com/crystal-lang/crystal-db.git"; - rev = "v0.11.0"; - sha256 = "1ylfhpn64p72ywi39niqb179f61z08q4qd4hhjza05z18mdaghl3"; + rev = "v0.13.1"; + sha256 = "02b79bdv5h460ay0vkpwi5q69b1qrm9z29z02p09xb03hijxskpd"; }; - pg = { + "pg" = { url = "https://github.com/will/crystal-pg.git"; - rev = "v0.26.0"; - sha256 = "04fwbgrlf2nzma0p2c8ki7p8sk113jhziq2al3ivif2lpmhr39fy"; + rev = "v0.29.0"; + sha256 = "0sac3cwx10jc8as9r8xy80gfkcmpk2g8jbw5b6y0fr02ka414mqp"; }; - promise = { + "promise" = { url = "https://github.com/spider-gazelle/promise.git"; - rev = "v3.0.0"; - sha256 = "1pyzxmp7prx3bkzxxdpl7ji0m79y710gnblyl58q4kgxw9srr8fk"; + rev = "v3.2.0"; + sha256 = "1pmgf118j53bwcpznmmj6bv0a08b50qx11zylzzdkg295wdqxkj5"; }; - raven = { + "raven" = { url = "https://github.com/sija/raven.cr.git"; - rev = "v1.9.2"; - sha256 = "1ywh5h98m78cpkjpq9kz0g62flmq2i2lyldha5zc8hdwk6z9q1bi"; + rev = "v1.9.5"; + sha256 = "1jm4hsl8dm1lvlj2wbxi2dznxb5i66ixn0qid7llwxxis0fazrk0"; }; - retriable = { + "retriable" = { url = "https://github.com/sija/retriable.cr.git"; - rev = "v0.2.4"; - sha256 = "1lhdzi6kaabbbx1b2awkmhm6bmj52kxjl6xkn2k7h0sknf78iffk"; + rev = "v0.2.5"; + sha256 = "0wdl7blzd43nb93sn6pgmdq5s76n47q0qylcsz0wy3r9jg9p7wpm"; }; - spectator = { + "spectator" = { url = "https://gitlab.com/arctic-fox/spectator.git"; rev = "v0.11.6"; sha256 = "03lcn6m4ikbi695dcszvl7snmkr0cgxz77if4ggn3w5mx0ldpyda"; }; - ssh2 = { + "ssh2" = { url = "https://github.com/spider-gazelle/ssh2.cr.git"; - rev = "v1.5.3"; - sha256 = "1a9m7df26yp50lxacdp8jjdyx00i33g5dz271zf33bqr9c6kfg8b"; + rev = "v1.7.2"; + sha256 = "134pkfi8m76x5lzphnwf1f312svi7kcmsnd803sv9x37ksl5ph2m"; }; - tallboy = { + "tallboy" = { url = "https://github.com/epoch/tallboy.git"; rev = "v0.9.3"; sha256 = "0s1sc6n8si3krrjb9imv5bazxbd5fl4nkarc3lmjyrvs6c9i56zc"; diff --git a/src/client/cluster.cr b/src/client/cluster.cr index 9dd4f34..d9e0048 100644 --- a/src/client/cluster.cr +++ b/src/client/cluster.cr @@ -81,7 +81,7 @@ module CB @network_id = nil, @plan_id = nil, @provider_id = nil, - @region_id = nil + @region_id = nil, ) end end @@ -101,7 +101,7 @@ module CB @maintenance_window_start = nil, @postgres_version_id = nil, @storage = nil, - @network_id = nil + @network_id = nil, ) end end @@ -138,7 +138,7 @@ module CB @provider_id = nil, @region_id = nil, @storage = nil, - @target_time = nil + @target_time = nil, ) end end @@ -199,7 +199,7 @@ module CB @network_id = nil, @plan_id = nil, @provider_id = nil, - @region_id = nil + @region_id = nil, ) end end