-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
88 lines (78 loc) · 2.17 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
rec {
description = "OpenGFW is a flexible, easy-to-use, open source implementation of GFW on Linux.";
nixConfig = {
extra-substituters = [ "https://opengfw.cachix.org" ];
extra-trusted-public-keys = [ "opengfw.cachix.org-1:vuygVQLuz+GEsqd6RrPOU8ckphW1MVe8MFm22cOo2is=" ];
};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
uspkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
options-nix.url = "github:eum3l/options.nix";
src = {
type = "github";
owner = "apernet";
repo = "OpenGFW";
ref = "v0.4.0";
flake = false;
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
options-nix,
src,
uspkgs,
}:
let
platforms = [
"aarch64-linux"
"x86_64-linux"
];
in
flake-utils.lib.eachSystem platforms (
system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnsupportedSystem = true;
};
unstable = import uspkgs { inherit system; };
in
rec {
formatter = unstable.nixfmt-rfc-style;
packages = rec {
default = opengfw;
opengfw = pkgs.callPackage ./package.nix {
inherit platforms src;
version = pkgs.lib.removePrefix "v" inputs.src.ref;
};
options = options-nix.lib.mkOptionScript {
inherit system;
module = self.nixosModules.default;
modulePrefix = "services.opengfw";
};
};
checks.default = pkgs.callPackage ./check { opengfw = self.nixosModules.default; };
devShells.default = pkgs.mkShellNoCC {
OPENGFW_LOG_LEVEL = "debug";
CGO_ENABLED = 0;
OPENGFW_TMP = "/tmp/opengfw";
inputsFrom = [ packages.opengfw ];
shellHook = ''
rm -r $OPENGFW_TMP
cp -r --no-preserve=mode,ownership ${src} $OPENGFW_TMP
cd $OPENGFW_TMP
'';
};
}
)
// {
nixosModules.default = import ./module.nix self.packages;
hydraJobs = {
inherit (self) packages;
};
};
}