-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathflake.nix
76 lines (73 loc) · 2.52 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
{
description = "Comin - GitOps for NixOS Machines";
outputs = { self, nixpkgs }:
let
systems = [ "aarch64-linux" "x86_64-linux" ];
forAllSystems = nixpkgs.lib.genAttrs systems;
nixpkgsFor = forAllSystems (system: import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
});
optionsDocFor = forAllSystems (system:
import ./nix/module-options-doc.nix (nixpkgsFor."${system}")
);
in {
overlays.default = final: prev: let
# - safe.directory: this is to allow comin to fetch local repositories belonging
# to other users. Otherwise, comin fails with:
# Pull from remote 'local' failed: unknown error: fatal: detected dubious ownership in repository
# - core.hooksPath: to avoid Git executing hooks from a repository belonging to another user
gitConfigFile = final.writeTextFile {
name = "git.config";
text = ''
[safe]
directory = *
[core]
hooksPath = /dev/null
'';
};
in {
comin = final.buildGoModule rec {
pname = "comin";
version = "0.2.0";
nativeCheckInputs = [ final.git ];
src = final.lib.fileset.toSource {
root = ./.;
fileset = final.lib.fileset.unions [
./cmd
./internal
./go.mod
./go.sum
./main.go
];
};
vendorHash = "sha256-9qObgfXvMkwE+1BVZNQXVhKhL6LqMqyIUhGnXf8q9SI=";
ldflags = [
"-X github.com/nlewo/comin/cmd.version=${version}"
];
buildInputs = [ final.makeWrapper ];
postInstall = ''
# This is because Nix needs Git at runtime by the go-git library
wrapProgram $out/bin/comin --set GIT_CONFIG_SYSTEM ${gitConfigFile} --prefix PATH : ${final.git}/bin
'';
};
};
packages = forAllSystems (system: {
default = nixpkgsFor."${system}".comin;
generate-module-options = optionsDocFor."${system}".optionsDocCommonMarkGenerator;
});
checks = forAllSystems (system: {
module-options-doc = optionsDocFor."${system}".checkOptionsDocCommonMark;
# I don't understand why nix flake check does't build packages.default
package = nixpkgsFor."${system}".comin;
});
nixosModules.comin = import ./nix/module.nix self.overlays.default;
devShells.x86_64-linux.default = let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
in pkgs.mkShell {
buildInputs = [
pkgs.go pkgs.godef pkgs.gopls
];
};
};
}