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 15, 2024
1 parent 0c904d6 commit 0392a6e
Showing 1 changed file with 16 additions and 55 deletions.
71 changes: 16 additions & 55 deletions modules/environment/nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# (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;

Expand All @@ -20,8 +20,8 @@ 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"
];

###### interface
Expand Down Expand Up @@ -50,64 +50,25 @@ 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>.";
};
};

};


###### implementation

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

{
nix = {
enable = true;
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="
];
};
}
];
config = {
nix = {
enable = true;
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="
];
};
};

}

0 comments on commit 0392a6e

Please sign in to comment.