1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2025-02-17 05:35:06 +01:00

nixpkgs: add the readOnly option

The option prevents the Home Manager configuration from reconfiguring or
extending the Nixpkgs it uses to avoid reimporting it.
This commit is contained in:
rcerc 2023-07-13 19:35:17 -04:00
parent d39fce90fb
commit abeec67028
No known key found for this signature in database
GPG key ID: 3F98EC7EC2B87ED1

View file

@ -70,6 +70,18 @@ in {
'';
};
readOnly = mkOption {
default = false;
example = true;
type = types.bool;
description = ''
Whether to prohibit specifying <option>nixpkgs.config</option>,
<option>nixpkgs.overlays</option> or, in the case
<option>nixpkgs.inheritGlobalPkgs</option> is
<literal>true</literal>, <option>nixpkgs.system</option>.
'';
};
config = mkOption {
default = { };
example = { allowBroken = true; };
@ -156,5 +168,14 @@ in {
optionalAttrs (_pkgs.stdenv.isLinux && _pkgs.stdenv.hostPlatform.isx86)
_pkgs.pkgsi686Linux;
};
assertions = [{
assertion = !cfg.readOnly || cfg.config == { } && cfg.overlays == [ ]
&& (!cfg.inheritGlobalPkgs || cfg.system == null);
message = ''
Nixpkgs cannot be reconfigured or extended because
<option>nixpkgs.readOnly</option> is <literal>true</literal>.
'';
}];
};
}