Skip to content

Commit 6f2c9f7

Browse files
Nobooooodyanonymous
andauthored
Initial Commit for nix (#856)
* Initial Commit for nix * Update description * nix fmt * update version --------- Co-authored-by: anonymous <anonymous@anonymous.anonymous44>
1 parent b8858f0 commit 6f2c9f7

File tree

7 files changed

+455
-0
lines changed

7 files changed

+455
-0
lines changed

‎.envrc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ nohup.out
88
zerobot
99
ZeroBot-Plugin*
1010
*.syso
11+
/.direnv

‎default.nix‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
pkgs ? (
3+
let
4+
inherit (builtins) fetchTree fromJSON readFile;
5+
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
6+
in
7+
import (fetchTree nixpkgs.locked) {
8+
overlays = [
9+
(import "${fetchTree gomod2nix.locked}/overlay.nix")
10+
];
11+
}
12+
),
13+
buildGoApplication ? pkgs.buildGoApplication,
14+
}:
15+
buildGoApplication {
16+
pname = "ZeroBot-Plugin";
17+
version = "1.7.6";
18+
pwd = ./.;
19+
src = ./.;
20+
# spec go version manually bcs
21+
# https://github.com/nix-community/gomod2nix/blob/30e3c3a9ec4ac8453282ca7f67fca9e1da12c3e6/builder/default.nix#L130
22+
# do no work
23+
go = pkgs.go_1_20;
24+
modules = ./gomod2nix.toml;
25+
}

‎flake.lock‎

Lines changed: 85 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎flake.nix‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
description = "基于 ZeroBot 的 OneBot 插件";
3+
4+
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
5+
inputs.flake-utils.url = "github:numtide/flake-utils";
6+
inputs.gomod2nix.url = "github:nix-community/gomod2nix";
7+
inputs.gomod2nix.inputs.nixpkgs.follows = "nixpkgs";
8+
inputs.gomod2nix.inputs.flake-utils.follows = "flake-utils";
9+
10+
outputs = {
11+
self,
12+
nixpkgs,
13+
flake-utils,
14+
gomod2nix,
15+
}: (
16+
flake-utils.lib.eachDefaultSystem
17+
(system: let
18+
pkgs = nixpkgs.legacyPackages.${system};
19+
20+
# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
21+
# This has no effect on other platforms.
22+
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
23+
in {
24+
# doCheck will fail at write files
25+
packages.default =
26+
(callPackage ./. {
27+
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
28+
})
29+
.overrideAttrs (_: {doCheck = false;});
30+
devShells.default = callPackage ./shell.nix {
31+
inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix;
32+
};
33+
formatter = pkgs.alejandra;
34+
})
35+
);
36+
}

0 commit comments

Comments
 (0)