mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-13 20:30:02 +00:00
Merge branch 'LnL7:master' into add-toplevel-option-lib
This commit is contained in:
commit
3bb62d40a2
7 changed files with 162 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
{ lib }:
|
||||
|
||||
{ system ? builtins.currentSystem or "x86_64-darwin"
|
||||
, pkgs ? null
|
||||
, modules
|
||||
, inputs
|
||||
, baseModules ? import ./modules/module-list.nix
|
||||
|
@ -21,7 +22,15 @@ let
|
|||
pkgsModule = { config, inputs, ... }: {
|
||||
_file = ./eval-config.nix;
|
||||
config = {
|
||||
_module.args.pkgs = import inputs.nixpkgs config.nixpkgs;
|
||||
assertions = [ {
|
||||
# Ensure that nixpkgs.* options are not set when pkgs is set
|
||||
assertion = pkgs == null || (config.nixpkgs.config == { } && config.nixpkgs.overlays == [ ]);
|
||||
message = ''
|
||||
`nixpkgs` options are disabled when `pkgs` is supplied through `darwinSystem`.
|
||||
'';
|
||||
} ];
|
||||
|
||||
_module.args.pkgs = if pkgs != null then pkgs else import inputs.nixpkgs config.nixpkgs;
|
||||
|
||||
# This permits the configuration to override the passed-in
|
||||
# system.
|
||||
|
@ -35,7 +44,7 @@ let
|
|||
literalDocBook = super.literalDocBook or super.literalExample;
|
||||
});
|
||||
|
||||
eval = libExtended.evalModules (builtins.removeAttrs args [ "inputs" "system" ] // {
|
||||
eval = libExtended.evalModules (builtins.removeAttrs args [ "inputs" "pkgs" "system" ] // {
|
||||
modules = modules ++ [ argsModule pkgsModule ] ++ baseModules;
|
||||
specialArgs = { modulesPath = builtins.toString ./modules; } // specialArgs;
|
||||
});
|
||||
|
|
|
@ -29,6 +29,5 @@
|
|||
system = "x86_64-darwin";
|
||||
modules = [ self.darwinModules.simple ];
|
||||
}).system;
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
./services/autossh.nix
|
||||
./services/buildkite-agent.nix
|
||||
./services/chunkwm.nix
|
||||
./services/cachix-agent.nix
|
||||
./services/dnsmasq.nix
|
||||
./services/emacs.nix
|
||||
./services/khd
|
||||
|
@ -49,6 +50,7 @@
|
|||
./services/lorri.nix
|
||||
./services/mail/offlineimap.nix
|
||||
./services/mopidy.nix
|
||||
./services/monitoring/telegraf.nix
|
||||
./services/nix-daemon.nix
|
||||
./services/nix-gc
|
||||
./services/ofborg
|
||||
|
|
|
@ -109,7 +109,7 @@ in
|
|||
|
||||
config = {
|
||||
|
||||
# _module.args.pkgs is defined in ../../default.nix
|
||||
# _module.args.pkgs is defined in ../../eval-config.nix
|
||||
|
||||
};
|
||||
}
|
||||
|
|
76
modules/services/cachix-agent.nix
Normal file
76
modules/services/cachix-agent.nix
Normal file
|
@ -0,0 +1,76 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.cachix-agent;
|
||||
in {
|
||||
options.services.cachix-agent = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Enable to run Cachix Agent as a system service.
|
||||
|
||||
Read <link xlink:href="https://docs.cachix.org/deploy/">Cachix Deploy</link> documentation for more information.
|
||||
'';
|
||||
};
|
||||
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
default = config.networking.hostName;
|
||||
description = ''
|
||||
Agent name, usually the same as the hostname.
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = ''
|
||||
Package containing cachix executable.
|
||||
'';
|
||||
type = types.package;
|
||||
default = pkgs.cachix;
|
||||
defaultText = literalExample "pkgs.cachix";
|
||||
};
|
||||
|
||||
credentialsFile = mkOption {
|
||||
type = types.path;
|
||||
default = "/etc/cachix-agent.token";
|
||||
description = ''
|
||||
Required file that needs to contain CACHIX_AGENT_TOKEN=...
|
||||
'';
|
||||
};
|
||||
|
||||
logFile = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = "/var/log/cachix-agent.log";
|
||||
description = "Absolute path to log all stderr and stdout";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
launchd.daemons.cachix-agent = {
|
||||
script = ''
|
||||
. ${cfg.credentialsFile}
|
||||
|
||||
exec ${cfg.package}/bin/cachix deploy agent ${cfg.name}
|
||||
'';
|
||||
|
||||
path = [ config.nix.package pkgs.coreutils ];
|
||||
|
||||
environment = {
|
||||
NIX_SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
|
||||
USER = "root";
|
||||
};
|
||||
|
||||
serviceConfig.KeepAlive = true;
|
||||
serviceConfig.RunAtLoad = true;
|
||||
serviceConfig.ProcessType = "Interactive";
|
||||
serviceConfig.StandardErrorPath = cfg.logFile;
|
||||
serviceConfig.StandardOutPath = cfg.logFile;
|
||||
serviceConfig.WatchPaths = [
|
||||
cfg.credentialsFile
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
71
modules/services/monitoring/telegraf.nix
Normal file
71
modules/services/monitoring/telegraf.nix
Normal file
|
@ -0,0 +1,71 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption types mkIf;
|
||||
|
||||
cfg = config.services.telegraf;
|
||||
|
||||
settingsFormat = pkgs.formats.toml { };
|
||||
configFile = settingsFormat.generate "config.toml" cfg.extraConfig;
|
||||
in {
|
||||
options = {
|
||||
services.telegraf = {
|
||||
enable = mkEnableOption "telegraf agent";
|
||||
|
||||
package = mkOption {
|
||||
default = pkgs.telegraf;
|
||||
defaultText = lib.literalExpression "pkgs.telegraf";
|
||||
description = "Which telegraf derivation to use";
|
||||
type = types.package;
|
||||
};
|
||||
|
||||
environmentFiles = mkOption {
|
||||
type = types.listOf types.path;
|
||||
default = [ ];
|
||||
example = [ "/run/keys/telegraf.env" ];
|
||||
description = ''
|
||||
File to load as environment file.
|
||||
This is useful to avoid putting secrets into the nix store.
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
default = { };
|
||||
description = "Extra configuration options for telegraf";
|
||||
type = settingsFormat.type;
|
||||
example = {
|
||||
outputs.influxdb = {
|
||||
urls = [ "http://localhost:8086" ];
|
||||
database = "telegraf";
|
||||
};
|
||||
inputs.statsd = {
|
||||
service_address = ":8125";
|
||||
delete_timings = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
configUrl = mkOption {
|
||||
default = null;
|
||||
description = "Url to fetch config from";
|
||||
type = types.nullOr types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
launchd.daemons.telegraf = {
|
||||
script = ''
|
||||
${lib.concatStringsSep "\n"
|
||||
(map (file: "source ${file}") cfg.environmentFiles)}
|
||||
${cfg.package}/bin/telegraf --config ${
|
||||
if cfg.configUrl == null then configFile else cfg.configUrl
|
||||
}
|
||||
'';
|
||||
serviceConfig = {
|
||||
KeepAlive = true;
|
||||
RunAtLoad = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -112,7 +112,7 @@ done
|
|||
|
||||
if [ -z "$action" ]; then showSyntax; fi
|
||||
|
||||
flakeFlags=(--experimental-features 'nix-command flakes')
|
||||
flakeFlags=(--extra-experimental-features 'nix-command flakes')
|
||||
|
||||
if [ -n "$flake" ]; then
|
||||
if [[ $flake =~ ^(.*)\#([^\#\"]*)$ ]]; then
|
||||
|
|
Loading…
Add table
Reference in a new issue