From 579a7eb2c51501cd3bfecde50a516655de1cd256 Mon Sep 17 00:00:00 2001 From: Nobooooody <117302867+Nobooooody@users.noreply.github.com> Date: Sat, 26 Apr 2025 02:12:17 +0800 Subject: [PATCH] chore: use new nixpkgs with overlay which bring back go_1_20 instead of using old nixpkgs --- default.nix | 1 + flake.lock | 25 +++++++++++++++++++++---- flake.nix | 27 ++++++++++++++++++--------- shell.nix | 2 +- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/default.nix b/default.nix index ecde3a4a81..5d8ebfad95 100644 --- a/default.nix +++ b/default.nix @@ -11,6 +11,7 @@ } ), buildGoApplication ? pkgs.buildGoApplication, + ... }: buildGoApplication { pname = "ZeroBot-Plugin"; diff --git a/flake.lock b/flake.lock index ed9ab6dccd..36b302f6df 100644 --- a/flake.lock +++ b/flake.lock @@ -28,11 +28,11 @@ ] }, "locked": { - "lastModified": 1741396135, - "narHash": "sha256-wqmdLr7h4Bk8gyKutgaApJKOM8JVvywI5P48NuqJ9Jg=", + "lastModified": 1742209644, + "narHash": "sha256-jMy1XqXqD0/tJprEbUmKilTkvbDY/C0ZGSsJJH4TNCE=", "owner": "nix-community", "repo": "gomod2nix", - "rev": "0983848bf2a7ccbfe24d874065adb8fd0f23729b", + "rev": "8f3534eb8f6c5c3fce799376dc3b91bae6b11884", "type": "github" }, "original": { @@ -42,6 +42,22 @@ } }, "nixpkgs": { + "locked": { + "lastModified": 1745391562, + "narHash": "sha256-sPwcCYuiEopaafePqlG826tBhctuJsLx/mhKKM5Fmjo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8a2f738d9d1f1d986b5a4cd2fd2061a7127237d7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-with-go_1_20": { "locked": { "lastModified": 1710843028, "narHash": "sha256-CMbK45c4nSkGvayiEHFkGFH+doGPbgo3AWfecd2t1Fk=", @@ -61,7 +77,8 @@ "inputs": { "flake-utils": "flake-utils", "gomod2nix": "gomod2nix", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "nixpkgs-with-go_1_20": "nixpkgs-with-go_1_20" } }, "systems": { diff --git a/flake.nix b/flake.nix index d069177aae..21b6eec41c 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,8 @@ { description = "基于 ZeroBot 的 OneBot 插件"; - # pin nixpkgs to preserve dropped go_1_20 - inputs.nixpkgs.url = "github:NixOS/nixpkgs/33c51330782cb486764eb598d5907b43dc87b4c2"; + inputs.nixpkgs-with-go_1_20.url = "github:NixOS/nixpkgs/33c51330782cb486764eb598d5907b43dc87b4c2"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.gomod2nix.url = "github:nix-community/gomod2nix"; inputs.gomod2nix.inputs.nixpkgs.follows = "nixpkgs"; @@ -11,14 +11,25 @@ outputs = { self, nixpkgs, + nixpkgs-with-go_1_20, flake-utils, gomod2nix, - }: let + ... + } @ inputs: let allSystems = flake-utils.lib.allSystems; in ( flake-utils.lib.eachSystem allSystems (system: let - pkgs = nixpkgs.legacyPackages.${system}; + old-nixpkgs = nixpkgs-with-go_1_20.legacyPackages.${system}; + pkgs = import nixpkgs { + inherit system; + + overlays = [ + (_: _: { + go_1_20 = old-nixpkgs.go_1_20; + }) + ]; + }; # The current default sdk for macOS fails to compile go projects, so we use a newer one for now. # This has no effect on other platforms. @@ -26,11 +37,10 @@ in { # doCheck will fail at write files packages = rec { - - ZeroBot-Plugin = - (callPackage ./. { + ZeroBot-Plugin = (callPackage ./. (inputs + // { inherit (gomod2nix.legacyPackages.${system}) buildGoApplication; - }) + })) .overrideAttrs (_: {doCheck = false;}); default = ZeroBot-Plugin; @@ -43,7 +53,6 @@ pkgs.cacert ]; }; - }; devShells.default = callPackage ./shell.nix { inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix; diff --git a/shell.nix b/shell.nix index b7b1aabc2e..303d0b78d3 100644 --- a/shell.nix +++ b/shell.nix @@ -13,7 +13,7 @@ mkGoEnv ? pkgs.mkGoEnv, gomod2nix ? pkgs.gomod2nix, }: let - goEnv = mkGoEnv {pwd = ./.;}; + goEnv = mkGoEnv { pwd = ./.; go = pkgs.go_1_20; }; in pkgs.mkShell { packages = [