nix: use new nix.settings syntax

This commit is contained in:
teutat3s 2022-11-22 12:30:54 +01:00
parent 2630acd0bc
commit 0db272c260
Signed by: teutat3s
GPG key ID: 4FA1D3FA524F22C1
5 changed files with 46 additions and 35 deletions

View file

@ -1,10 +1,12 @@
{ config, pkgs, lib, ... }:
with lib;
let cfg = config.pub-solar.core;
in
{
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.pub-solar.core;
in {
options.pub-solar.core = {
enableCaddy = mkOption {
type = types.bool;
@ -17,12 +19,12 @@ in
binaryCaches = mkOption {
type = types.listOf types.str;
default = [ ];
default = [];
description = "Binary caches to use.";
};
publicKeys = mkOption {
type = types.listOf types.str;
default = [ ];
default = [];
description = "Public keys of binary caches.";
};
};
@ -40,15 +42,16 @@ in
networking.firewall.enable = true;
# Customized binary caches list (with fallback to official binary cache)
nix.binaryCaches = cfg.binaryCaches;
nix.binaryCachePublicKeys = cfg.publicKeys;
nix.settings.substituters = cfg.binaryCaches;
nix.settings.trusted-public-keys = cfg.publicKeys;
# These entries get added to /etc/hosts
networking.hosts = {
"127.0.0.1" = [ ]
++ lib.optionals cfg.enableCaddy [ "caddy.local" ]
++ lib.optionals config.pub-solar.printing.enable [ "cups.local" ]
++ lib.optionals cfg.enableHelp [ "help.local" ];
"127.0.0.1" =
[]
++ lib.optionals cfg.enableCaddy ["caddy.local"]
++ lib.optionals config.pub-solar.printing.enable ["cups.local"]
++ lib.optionals cfg.enableHelp ["help.local"];
};
# Caddy reverse proxy for local services like cups

View file

@ -1,19 +1,25 @@
{ config, pkgs, lib, inputs, ... }:
{
config,
pkgs,
lib,
inputs,
...
}: {
nix = {
# Use default version alias for nix package
package = pkgs.nix;
# Improve nix store disk usage
autoOptimiseStore = true;
gc.automatic = true;
optimise.automatic = true;
# Prevents impurities in builds
useSandbox = true;
# give root and @wheel special privileges with nix
trustedUsers = [ "root" "@wheel" ];
# This is just a representation of the nix default
systemFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ];
settings = {
# Improve nix store disk usage
auto-optimise-store = true;
# Prevents impurities in builds
sandbox = true;
# give root and @wheel special privileges with nix
trusted-users = ["root" "@wheel"];
# This is just a representation of the nix default
system-features = ["nixos-test" "benchmark" "big-parallel" "kvm"];
};
# Generally useful nix option defaults
extraOptions = ''
min-free = 536870912

View file

@ -1,11 +1,13 @@
{ pkgs, lib, ... }:
let
{
pkgs,
lib,
...
}: let
folder = ./.;
toImport = name: value: folder + ("/" + name);
filterCaches = key: value: value == "regular" && lib.hasSuffix ".nix" key && key != "default.nix";
imports = lib.mapAttrsToList toImport (lib.filterAttrs filterCaches (builtins.readDir folder));
in
{
in {
inherit imports;
nix.binaryCaches = [ "https://cache.nixos.org/" ];
nix.settings.substituters = ["https://cache.nixos.org/"];
}

View file

@ -1,9 +1,9 @@
{
nix = {
binaryCaches = [
nix.settings = {
substituters = [
"https://nix-community.cachix.org"
];
binaryCachePublicKeys = [
trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};

View file

@ -1,9 +1,9 @@
{
nix = {
binaryCaches = [
nix.settings = {
substituters = [
"https://nrdxp.cachix.org"
];
binaryCachePublicKeys = [
trusted-public-keys = [
"nrdxp.cachix.org-1:Fc5PSqY2Jm1TrWfm88l6cvGWwz3s93c6IOifQWnhNW4="
];
};