-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathflake.nix
More file actions
107 lines (104 loc) · 2.98 KB
/
flake.nix
File metadata and controls
107 lines (104 loc) · 2.98 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{
inputs = {
flake-utils = {
url = "github:numtide/flake-utils";
};
nixpkgs = {
url = "github:NixOS/nixpkgs/nixos-25.11";
};
};
outputs =
{
self,
flake-utils,
nixpkgs,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
version = pkgs.lib.fileContents ./internal/index/version.txt;
in
{
packages = {
scip-go = pkgs.buildGoModule {
pname = "scip-go";
inherit version;
src = ./.;
vendorHash = "sha256-1I+7iPDSU2RbJzxAmxNVF9NSvdG9Ne6PGG89D4Gx00s=";
subPackages = [ "cmd/scip-go" ];
env.CGO_ENABLED = 0;
checkPhase = "go test ./...";
# Use proxyVendor so deps go into the module cache instead
# of a vendor/ directory that conflicts with test sub-modules
# having their own go.mod.
proxyVendor = true;
nativeCheckInputs = [ pkgs.git ];
};
default = self.packages.${system}.scip-go;
}
// pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
docker = pkgs.dockerTools.buildLayeredImage {
name = "scip-go";
tag = version;
contents = [
self.packages.${system}.scip-go
pkgs.go
pkgs.git
pkgs.cacert
pkgs.busybox
];
fakeRootCommands = ''
mkdir -p /work /tmp
'';
enableFakechroot = true;
config = {
Cmd = [ "scip-go" ];
WorkingDir = "/work";
Env = [
"GOTOOLCHAIN=auto"
"HOME=/tmp"
"TMPDIR=/tmp"
"GOCACHE=/tmp/go-build"
"GOMODCACHE=/tmp/go-mod"
];
Labels = {
"org.opencontainers.image.source" = "https://github.com/scip-code/scip-go";
};
};
};
};
checks = {
nixfmt = pkgs.runCommand "check-nixfmt" { } ''
${pkgs.nixfmt}/bin/nixfmt --check ${./flake.nix}
touch $out
'';
goimports = pkgs.runCommand "check-goimports" { } ''
cd ${./.}
bad=$(
# Snapshot outputs are generated with modified
# indentation for alignment with annotations.
find . -name '*.go' \
-not -path '*/testdata/snapshots/output/*' \
-exec ${pkgs.gotools}/bin/goimports -l {} +
)
if [ -n "$bad" ]; then
echo "goimports check failed on:"
echo "$bad"
exit 1
fi
touch $out
'';
};
devShells = {
default = pkgs.mkShellNoCC {
buildInputs = [
pkgs.go
pkgs.gotools
pkgs.nixfmt
];
};
};
}
);
}