-
Notifications
You must be signed in to change notification settings - Fork 12
/
flake.nix
89 lines (83 loc) · 2.54 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
89
{
outputs = inputs @ {
self,
flake-parts,
...
}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
inputs.flake-parts.flakeModules.easyOverlay
inputs.flake-parts.flakeModules.partitions
./nixos/tests/flake-part.nix
];
systems = [
"x86_64-darwin"
"x86_64-linux"
"aarch64-darwin"
"aarch64-linux"
];
perSystem = {
config,
lib,
pkgs,
system,
...
}: let
tsnsrvPkg = p: subPackage:
p.buildGo123Module {
pname = builtins.baseNameOf subPackage;
version = "0.0.0";
vendorHash = builtins.readFile ./tsnsrv.sri;
src = lib.sourceFilesBySuffices (lib.sources.cleanSource ./.) [".go" ".mod" ".sum"];
subPackages = [subPackage];
ldflags = ["-s" "-w"];
meta.mainProgram = builtins.baseNameOf subPackage;
};
imageArgs = p: {
name = "tsnsrv";
tag = "latest";
contents = [
(p.buildEnv {
name = "image-root";
paths = [(tsnsrvPkg p "cmd/tsnsrv")];
pathsToLink = ["/bin" "/tmp"];
})
p.dockerTools.caCertificates
];
config.EntryPoint = ["/bin/tsnsrv"];
};
in {
overlayAttrs = {
inherit (config.packages) tsnsrv tsnsrvOciImage;
};
packages = {
default = config.packages.tsnsrv;
tsnsrv = tsnsrvPkg pkgs "cmd/tsnsrv";
tsnsrvCmdLineValidator = tsnsrvPkg pkgs "cmd/tsnsrvCmdLineValidator";
# This platform's "natively" built docker image:
tsnsrvOciImage = pkgs.dockerTools.buildLayeredImage (imageArgs pkgs);
# "cross-platform" build, mainly to support building on github actions (but also on macOS with apple silicon):
tsnsrvOciImage-cross-aarch64-linux = pkgs.pkgsCross.aarch64-multiplatform.dockerTools.buildLayeredImage (imageArgs pkgs.pkgsCross.aarch64-multiplatform);
};
formatter = pkgs.alejandra;
};
partitionedAttrs = {
checks = "dev";
devShells = "dev";
apps = "dev";
};
partitions.dev = {
extraInputsFlake = ./dev;
module = ./dev/flake-part.nix;
};
flake = {
nixosModules = {
default = import ./nixos {flake = self;};
};
};
};
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
}