Skip to content

Commit

Permalink
Merge branch 'rand-tmp' of https://github.com/vatebur/ZeroBot-Plugin
Browse files Browse the repository at this point in the history
…into rand-tmp
  • Loading branch information
vatebur committed Mar 5, 2024
2 parents bb7798e + fad3cb4 commit 24d9e99
Show file tree
Hide file tree
Showing 7 changed files with 455 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ nohup.out
zerobot
ZeroBot-Plugin*
*.syso
/.direnv
25 changes: 25 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
pkgs ? (
let
inherit (builtins) fetchTree fromJSON readFile;
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
in
import (fetchTree nixpkgs.locked) {
overlays = [
(import "${fetchTree gomod2nix.locked}/overlay.nix")
];
}
),
buildGoApplication ? pkgs.buildGoApplication,
}:
buildGoApplication {
pname = "ZeroBot-Plugin";
version = "1.7.6";
pwd = ./.;
src = ./.;
# spec go version manually bcs
# https://github.com/nix-community/gomod2nix/blob/30e3c3a9ec4ac8453282ca7f67fca9e1da12c3e6/builder/default.nix#L130
# do no work
go = pkgs.go_1_20;
modules = ./gomod2nix.toml;
}
85 changes: 85 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
description = "基于 ZeroBot 的 OneBot 插件";

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";
inputs.gomod2nix.inputs.flake-utils.follows = "flake-utils";

outputs = {
self,
nixpkgs,
flake-utils,
gomod2nix,
}: (
flake-utils.lib.eachDefaultSystem
(system: let
pkgs = nixpkgs.legacyPackages.${system};

# 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.
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
in {
# doCheck will fail at write files
packages.default =
(callPackage ./. {
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
})
.overrideAttrs (_: {doCheck = false;});
devShells.default = callPackage ./shell.nix {
inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix;
};
formatter = pkgs.alejandra;
})
);
}
Loading

0 comments on commit 24d9e99

Please sign in to comment.