refactor: hosts/modules: fewer file-level inherits
This commit is contained in:
@@ -1,11 +1,8 @@
|
|||||||
{ config, lib, ... }:
|
{ lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib) attrValues filterAttrs mkMerge mkOption types;
|
host = lib.types.submodule ({ config, name, ... }: {
|
||||||
cfg = config.sane.hosts;
|
options = with lib; {
|
||||||
|
|
||||||
host = types.submodule ({ config, name, ... }: {
|
|
||||||
options = {
|
|
||||||
names = mkOption {
|
names = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
description = ''
|
description = ''
|
||||||
@@ -69,7 +66,7 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
sane.hosts.by-name = mkOption {
|
sane.hosts.by-name = with lib; mkOption {
|
||||||
type = types.attrsOf host;
|
type = types.attrsOf host;
|
||||||
default = {};
|
default = {};
|
||||||
description = ''
|
description = ''
|
||||||
|
@@ -16,13 +16,11 @@
|
|||||||
|
|
||||||
{ lib, config, ... }:
|
{ lib, config, ... }:
|
||||||
|
|
||||||
with lib;
|
|
||||||
let
|
let
|
||||||
cfg = config.sane.nixcache;
|
cfg = config.sane.nixcache;
|
||||||
hostName = config.networking.hostName;
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = with lib; {
|
||||||
sane.nixcache.enable = mkOption {
|
sane.nixcache.enable = mkOption {
|
||||||
default = false;
|
default = false;
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
@@ -55,13 +53,13 @@ in
|
|||||||
# to explicitly build from a specific cache (in case others are down):
|
# to explicitly build from a specific cache (in case others are down):
|
||||||
# - `nixos-rebuild ... --option substituters https://cache.nixos.org`
|
# - `nixos-rebuild ... --option substituters https://cache.nixos.org`
|
||||||
# - `nix build ... --substituters ""`
|
# - `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.nixos "https://cache.nixos.org/")
|
||||||
(lib.optional cfg.substituters.cachix "https://nix-community.cachix.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).
|
# 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.
|
# 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="
|
"nixcache.uninsane.org:r3WILM6+QrkmsLgqVQcEdibFD7Q/4gyzD9dGT33GP70="
|
||||||
"desko:Q7mjjqoBMgNQ5P0e63sLur65A+D4f3Sv4QiycDIKxiI="
|
"desko:Q7mjjqoBMgNQ5P0e63sLur65A+D4f3Sv4QiycDIKxiI="
|
||||||
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
||||||
|
Reference in New Issue
Block a user