mirror of
https://github.com/nix-community/home-manager
synced 2024-11-27 05:29:46 +01:00
go: add telemetry options
This commit is contained in:
parent
93435d27d2
commit
89ae191311
4 changed files with 64 additions and 0 deletions
|
@ -6,6 +6,8 @@ let
|
||||||
|
|
||||||
cfg = config.programs.go;
|
cfg = config.programs.go;
|
||||||
|
|
||||||
|
modeFileContent = "${cfg.telemetry.mode} ${cfg.telemetry.date}";
|
||||||
|
|
||||||
in {
|
in {
|
||||||
meta.maintainers = [ maintainers.rvolosatovs ];
|
meta.maintainers = [ maintainers.rvolosatovs ];
|
||||||
|
|
||||||
|
@ -71,6 +73,31 @@ in {
|
||||||
or checksum database.
|
or checksum database.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
telemetry = mkOption {
|
||||||
|
type = types.submodule {
|
||||||
|
options = {
|
||||||
|
mode = mkOption {
|
||||||
|
type = with types; nullOr (enum [ "off" "local" "on" ]);
|
||||||
|
default = null;
|
||||||
|
description = "Go telemetry mode to be set.";
|
||||||
|
};
|
||||||
|
|
||||||
|
date = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "1970-01-01";
|
||||||
|
description = ''
|
||||||
|
The date indicating the date at which the modefile
|
||||||
|
was updated, in YYYY-MM-DD format. It's used to
|
||||||
|
reset the timeout before the next telemetry report
|
||||||
|
is uploaded when telemetry mode is set to "on".
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = { };
|
||||||
|
description = "Options to configure Go telemetry mode.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -98,5 +125,17 @@ in {
|
||||||
(mkIf (cfg.goPrivate != [ ]) {
|
(mkIf (cfg.goPrivate != [ ]) {
|
||||||
home.sessionVariables.GOPRIVATE = concatStringsSep "," cfg.goPrivate;
|
home.sessionVariables.GOPRIVATE = concatStringsSep "," cfg.goPrivate;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
(mkIf (cfg.telemetry.mode != null) {
|
||||||
|
home.file."Library/Application Support/go/telemetry/mode" = {
|
||||||
|
enable = pkgs.stdenv.hostPlatform.isDarwin;
|
||||||
|
text = modeFileContent;
|
||||||
|
};
|
||||||
|
|
||||||
|
xdg.configFile."go/telemetry/mode" = {
|
||||||
|
enable = !pkgs.stdenv.hostPlatform.isDarwin;
|
||||||
|
text = modeFileContent;
|
||||||
|
};
|
||||||
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,7 @@ in import nmtSrc {
|
||||||
./modules/programs/gh-dash
|
./modules/programs/gh-dash
|
||||||
./modules/programs/git
|
./modules/programs/git
|
||||||
./modules/programs/git-cliff
|
./modules/programs/git-cliff
|
||||||
|
./modules/programs/go
|
||||||
./modules/programs/gpg
|
./modules/programs/gpg
|
||||||
./modules/programs/gradle
|
./modules/programs/gradle
|
||||||
./modules/programs/granted
|
./modules/programs/granted
|
||||||
|
|
1
tests/modules/programs/go/default.nix
Normal file
1
tests/modules/programs/go/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ go-telemetry = ./go-telemetry.nix; }
|
23
tests/modules/programs/go/go-telemetry.nix
Normal file
23
tests/modules/programs/go/go-telemetry.nix
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.go = {
|
||||||
|
enable = true;
|
||||||
|
telemetry = {
|
||||||
|
mode = "on";
|
||||||
|
date = "2006-01-02";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nm.script = let
|
||||||
|
modeFileDir = if !pkgs.stdenv.isDarwin then
|
||||||
|
".config/go/telemetry"
|
||||||
|
else
|
||||||
|
"Library/Application Support/go/telemetry";
|
||||||
|
in ''
|
||||||
|
assertFileExists "home-files/${modeFileDir}/mode"
|
||||||
|
assertFileContent \
|
||||||
|
"home-files/${modeFileDir}/mode" \
|
||||||
|
"on 2006-01-02"
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue