refactor: hosts/modules: fewer file-level inherits
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
{ config, lib, ... }:
|
||||
{ lib, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) attrValues filterAttrs mkMerge mkOption types;
|
||||
cfg = config.sane.hosts;
|
||||
|
||||
host = types.submodule ({ config, name, ... }: {
|
||||
options = {
|
||||
host = lib.types.submodule ({ config, name, ... }: {
|
||||
options = with lib; {
|
||||
names = mkOption {
|
||||
type = types.listOf types.str;
|
||||
description = ''
|
||||
@@ -69,7 +66,7 @@ let
|
||||
in
|
||||
{
|
||||
options = {
|
||||
sane.hosts.by-name = mkOption {
|
||||
sane.hosts.by-name = with lib; mkOption {
|
||||
type = types.attrsOf host;
|
||||
default = {};
|
||||
description = ''
|
||||
|
@@ -16,13 +16,11 @@
|
||||
|
||||
{ lib, config, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.sane.nixcache;
|
||||
hostName = config.networking.hostName;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
options = with lib; {
|
||||
sane.nixcache.enable = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
@@ -55,13 +53,13 @@ in
|
||||
# to explicitly build from a specific cache (in case others are down):
|
||||
# - `nixos-rebuild ... --option substituters https://cache.nixos.org`
|
||||
# - `nix build ... --substituters ""`
|
||||
nix.settings.substituters = mkIf cfg.enable (lib.flatten [
|
||||
nix.settings.substituters = lib.mkIf cfg.enable (lib.flatten [
|
||||
(lib.optional cfg.substituters.nixos "https://cache.nixos.org/")
|
||||
(lib.optional cfg.substituters.cachix "https://nix-community.cachix.org")
|
||||
]);
|
||||
# always trust our keys (so one can explicitly use a substituter even if it's not the default).
|
||||
# note that these are also used to sign paths before deploying over SSH; not just nix-serve.
|
||||
nix.settings.trusted-public-keys = mkIf cfg.enable-trusted-keys [
|
||||
nix.settings.trusted-public-keys = lib.mkIf cfg.enable-trusted-keys [
|
||||
"nixcache.uninsane.org:r3WILM6+QrkmsLgqVQcEdibFD7Q/4gyzD9dGT33GP70="
|
||||
"desko:Q7mjjqoBMgNQ5P0e63sLur65A+D4f3Sv4QiycDIKxiI="
|
||||
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
||||
|
Reference in New Issue
Block a user