Skip to content

Commit

Permalink
nix.nix: inherit from upstream nix.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
ShamrockLee committed Feb 18, 2024
1 parent 5828992 commit 8fd0eaf
Showing 1 changed file with 13 additions and 42 deletions.
55 changes: 13 additions & 42 deletions modules/environment/nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,27 @@
# (Copyright (c) 2003-2022 Eelco Dolstra and the Nixpkgs/NixOS contributors,
# licensed under MIT License as well)

{ config, lib, pkgs, ... }:
{ config, lib, pkgs, nixpkgs, ... }:

with lib;

let
cfg = config.nix;
renameNixOpt = old: new:
(mkRenamedOptionModule [ "nix" old ] [ "nix" new ]);
mkRenamedOptionModuleWith {
sinceRelease = 2205;
from = [ "nix" old ];
to = [ "nix" "settings" new ];
};
in

{
# Backward-compatibility with the NixOS options.
imports = [
(renameNixOpt "binaryCaches" "substituters")
(renameNixOpt "binaryCachePublicKeys" "trustedPublicKeys")
# Use options and config from upstream nix.nix
"${nixpkgs}/nixos/modules/config/nix.nix"
# Backward-compatibility with pre-`settings` options.
(renameNixOpt "substituters" "substituters")
(renameNixOpt "trustedPublicKeys" "trustedPublicKeys")
];

###### interface
Expand Down Expand Up @@ -51,32 +57,6 @@ in
'';
};

## From nix.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.
'';
};

extraOptions = mkOption {
type = types.lines;
default = "";
description = "Extra config to be appended to <filename>/etc/nix/nix.conf</filename>.";
};
};

};
Expand All @@ -85,22 +65,13 @@ in
###### implementation

config = {
environment.etc = {
"nix/nix.conf".text = ''
sandbox = false
substituters = ${concatStringsSep " " cfg.substituters}
trusted-public-keys = ${concatStringsSep " " cfg.trustedPublicKeys}
${cfg.extraOptions}
'';
};

nix = {
enable = true;
substituters = [
settings.substituters = [
"https://cache.nixos.org"
"https://nix-on-droid.cachix.org"
];
trustedPublicKeys = [
settings.trustedPublicKeys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-on-droid.cachix.org-1:56snoMJTXmDRC1Ei24CmKoUqvHJ9XCp+nidK7qkMQrU="
];
Expand Down

0 comments on commit 8fd0eaf

Please sign in to comment.