nix: allow configuration of nix.conf

This commit is contained in:
Tobias Happ 2021-05-27 18:45:56 +02:00 committed by Alexander Sosedkin
parent 92b2897b7c
commit ee772f1e1d
3 changed files with 74 additions and 31 deletions

View file

@ -1,30 +0,0 @@
# Copyright (c) 2019-2020, see AUTHORS. Licensed under MIT License, see LICENSE.
{ config, lib, pkgs, ... }:
with lib;
{
###### interface
options = {
};
###### implementation
config = {
environment.etc = {
"nix/nix.conf".text = ''
sandbox = false
substituters = https://cache.nixos.org https://nix-on-droid.cachix.org
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-on-droid.cachix.org-1:56snoMJTXmDRC1Ei24CmKoUqvHJ9XCp+nidK7qkMQrU=
'';
};
};
}

View file

@ -0,0 +1,73 @@
# Copyright (c) 2019-2020, see AUTHORS. Licensed under MIT License, see LICENSE.
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.nix;
in
{
###### interface
options = {
nix = {
substituters = mkOption {
type = types.listOf types.str;
default = [];
description = ''
A list of URLs of substituters. The official NixOS and nix-on-droid
substituters are added by default.
'';
};
trustedPublicKeys = mkOption {
type = types.listOf types.str;
default = [];
description = ''
A list of public keys. When paths are copied from another Nix store (such as a
binary cache), they must be signed with one of these keys. The official NixOS
and nix-on-droid public keys are added by default.
'';
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = "Extra config to be appended to /etc/nix/nix.conf.";
};
};
};
###### implementation
config = {
environment.etc = {
"nix/nix.conf".text = ''
sandbox = false
substituters = ${concatStringsSep " " cfg.substituters}
trusted-public-keys = ${concatStringsSep " " cfg.trustedPublicKeys}
${cfg.extraConfig}
'';
};
nix = {
substituters = [
"https://cache.nixos.org"
"https://nix-on-droid.cachix.org"
];
trustedPublicKeys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-on-droid.cachix.org-1:56snoMJTXmDRC1Ei24CmKoUqvHJ9XCp+nidK7qkMQrU="
];
};
};
}

View file

@ -6,10 +6,10 @@
./build/activation.nix
./build/config.nix
./environment/etc
./environment/files.nix
./environment/links.nix
./environment/login
./environment/networking.nix
./environment/nix.nix
./environment/path.nix
./environment/session-init.nix
./home-manager.nix