1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-01 16:59:43 +01:00
home-manager/tests/modules/misc/nix/example-settings.nix

39 lines
832 B
Nix
Raw Normal View History

nix: add structural settings (#2718) Nix permits user level configurations through ~/.config/nix/nix.conf that allow customization of system-wide settings and behavior. This is beneficial in chroot environments and for per-user configurations. System level Nix configurations in the form of /etc/nix/nix.conf can be specified declaratively via the NixOS nix module but as of currently no counter part exists in home-manager. This PR is a port of the RFC42 implementation for the NixOS nix module[1] to home-manager. Non-applicable options have been excluded and the config generation backends have been tweaked to the backends offered by home-manager. A notable change from the NixOS module is a mandatory option to specify the Nix binary corresponding to the version "nix.conf" should be generated against. This is necessary because the validation phase is dependent on the `nix show-config` subcommand on the host platform. While it is possible to avoid validation entirely, the lack of type checking was deemed too significant. In NixOs, the version information can be retrieved from the `package` option itself which declares the Nix binary system-wide. However in home-manager, there is no pure way to detect the system Nix version and what state version the "nix.conf" should be generated against. Thus an option is used to overcome this limitation by forcing the user to specify the Nix package. Note this interaction can still be automated by forwarding the system-wide Nix package to the home-manager module if needed. Three unit tests were added to test the module behavior for the empty settings, the example settings and the example registry configurations respectively. [1] - NixOS/nixpkgs#139075
2022-03-18 03:47:32 +01:00
{ config, lib, pkgs, ... }:
with lib;
{
config = {
nix = {
package = config.lib.test.mkStubPackage {
2022-03-24 00:11:06 +01:00
version = lib.getVersion pkgs.nixVersions.stable;
nix: add structural settings (#2718) Nix permits user level configurations through ~/.config/nix/nix.conf that allow customization of system-wide settings and behavior. This is beneficial in chroot environments and for per-user configurations. System level Nix configurations in the form of /etc/nix/nix.conf can be specified declaratively via the NixOS nix module but as of currently no counter part exists in home-manager. This PR is a port of the RFC42 implementation for the NixOS nix module[1] to home-manager. Non-applicable options have been excluded and the config generation backends have been tweaked to the backends offered by home-manager. A notable change from the NixOS module is a mandatory option to specify the Nix binary corresponding to the version "nix.conf" should be generated against. This is necessary because the validation phase is dependent on the `nix show-config` subcommand on the host platform. While it is possible to avoid validation entirely, the lack of type checking was deemed too significant. In NixOs, the version information can be retrieved from the `package` option itself which declares the Nix binary system-wide. However in home-manager, there is no pure way to detect the system Nix version and what state version the "nix.conf" should be generated against. Thus an option is used to overcome this limitation by forcing the user to specify the Nix package. Note this interaction can still be automated by forwarding the system-wide Nix package to the home-manager module if needed. Three unit tests were added to test the module behavior for the empty settings, the example settings and the example registry configurations respectively. [1] - NixOS/nixpkgs#139075
2022-03-18 03:47:32 +01:00
buildScript = ''
target=$out/bin/nix
mkdir -p "$(dirname "$target")"
echo -n "true" > "$target"
chmod +x "$target"
'';
};
nixPath = [ "/a" "/b/c" ];
nix: add structural settings (#2718) Nix permits user level configurations through ~/.config/nix/nix.conf that allow customization of system-wide settings and behavior. This is beneficial in chroot environments and for per-user configurations. System level Nix configurations in the form of /etc/nix/nix.conf can be specified declaratively via the NixOS nix module but as of currently no counter part exists in home-manager. This PR is a port of the RFC42 implementation for the NixOS nix module[1] to home-manager. Non-applicable options have been excluded and the config generation backends have been tweaked to the backends offered by home-manager. A notable change from the NixOS module is a mandatory option to specify the Nix binary corresponding to the version "nix.conf" should be generated against. This is necessary because the validation phase is dependent on the `nix show-config` subcommand on the host platform. While it is possible to avoid validation entirely, the lack of type checking was deemed too significant. In NixOs, the version information can be retrieved from the `package` option itself which declares the Nix binary system-wide. However in home-manager, there is no pure way to detect the system Nix version and what state version the "nix.conf" should be generated against. Thus an option is used to overcome this limitation by forcing the user to specify the Nix package. Note this interaction can still be automated by forwarding the system-wide Nix package to the home-manager module if needed. Three unit tests were added to test the module behavior for the empty settings, the example settings and the example registry configurations respectively. [1] - NixOS/nixpkgs#139075
2022-03-18 03:47:32 +01:00
settings = {
use-sandbox = true;
show-trace = true;
system-features = [ "big-parallel" "kvm" "recursive-nix" ];
};
};
nmt.script = ''
assertFileContent \
home-files/.config/nix/nix.conf \
${./example-settings-expected.conf}
assertFileContains home-path/etc/profile.d/hm-session-vars.sh \
'export NIX_PATH="/a:/b/c''${NIX_PATH:+:$NIX_PATH}"'
nix: add structural settings (#2718) Nix permits user level configurations through ~/.config/nix/nix.conf that allow customization of system-wide settings and behavior. This is beneficial in chroot environments and for per-user configurations. System level Nix configurations in the form of /etc/nix/nix.conf can be specified declaratively via the NixOS nix module but as of currently no counter part exists in home-manager. This PR is a port of the RFC42 implementation for the NixOS nix module[1] to home-manager. Non-applicable options have been excluded and the config generation backends have been tweaked to the backends offered by home-manager. A notable change from the NixOS module is a mandatory option to specify the Nix binary corresponding to the version "nix.conf" should be generated against. This is necessary because the validation phase is dependent on the `nix show-config` subcommand on the host platform. While it is possible to avoid validation entirely, the lack of type checking was deemed too significant. In NixOs, the version information can be retrieved from the `package` option itself which declares the Nix binary system-wide. However in home-manager, there is no pure way to detect the system Nix version and what state version the "nix.conf" should be generated against. Thus an option is used to overcome this limitation by forcing the user to specify the Nix package. Note this interaction can still be automated by forwarding the system-wide Nix package to the home-manager module if needed. Three unit tests were added to test the module behavior for the empty settings, the example settings and the example registry configurations respectively. [1] - NixOS/nixpkgs#139075
2022-03-18 03:47:32 +01:00
'';
};
}