nixos: Make config.nix.enable pass test

main
Robert Hensing 2 years ago
parent 8f57dc38d9
commit eb8b70c020
  1. 2
      nixos/modules/installer/tools/tools.nix
  2. 10
      nixos/modules/services/misc/nix-gc.nix
  3. 10
      nixos/modules/services/misc/nix-optimise.nix
  4. 2
      nixos/modules/virtualisation/qemu-vm.nix
  5. 15
      nixos/tests/without-nix.nix

@ -117,7 +117,7 @@ in
'';
};
config = lib.mkIf (!config.system.disableInstallerTools) {
config = lib.mkIf (config.nix.enable && !config.system.disableInstallerTools) {
system.nixos-generate-config.configuration = mkDefault ''
# Edit this configuration file to define what should be installed on

@ -81,8 +81,14 @@ in
###### implementation
config = {
systemd.services.nix-gc = {
assertions = [
{
assertion = cfg.automatic -> config.nix.enable;
message = ''nix.gc.automatic requires nix.enable'';
}
];
systemd.services.nix-gc = lib.mkIf config.nix.enable {
description = "Nix Garbage Collector";
script = "exec ${config.nix.package.out}/bin/nix-collect-garbage ${cfg.options}";
startAt = optional cfg.automatic cfg.dates;

@ -37,8 +37,14 @@ in
###### implementation
config = {
systemd.services.nix-optimise =
assertions = [
{
assertion = cfg.automatic -> config.nix.enable;
message = ''nix.optimise.automatic requires nix.enable'';
}
];
systemd.services.nix-optimise = lib.mkIf config.nix.enable
{ description = "Nix Store Optimiser";
# No point this if the nix daemon (and thus the nix store) is outside
unitConfig.ConditionPathIsReadWrite = "/nix/var/nix/daemon-socket";

@ -796,7 +796,7 @@ in
# allow `system.build.toplevel' to be included. (If we had a direct
# reference to ${regInfo} here, then we would get a cyclic
# dependency.)
boot.postBootCommands =
boot.postBootCommands = lib.mkIf config.nix.enable
''
if [[ "$(cat /proc/cmdline)" =~ regInfo=([^ ]*) ]]; then
${config.nix.package.out}/bin/nix-store --load-db < ''${BASH_REMATCH[1]}

@ -6,6 +6,21 @@ import ./make-test-python.nix ({ lib, ... }: {
nodes.machine = { ... }: {
nix.enable = false;
nixpkgs.overlays = [
(self: super: {
nix = throw "don't want to use pkgs.nix";
nixVersions = lib.mapAttrs (k: throw "don't want to use pkgs.nixVersions.${k}") super.nixVersions;
# aliases, some deprecated
nix_2_3 = throw "don't want to use pkgs.nix_2_3";
nix_2_4 = throw "don't want to use pkgs.nix_2_4";
nix_2_5 = throw "don't want to use pkgs.nix_2_5";
nix_2_6 = throw "don't want to use pkgs.nix_2_6";
nixFlakes = throw "don't want to use pkgs.nixFlakes";
nixStable = throw "don't want to use pkgs.nixStable";
nixUnstable = throw "don't want to use pkgs.nixUnstable";
nixStatic = throw "don't want to use pkgs.nixStatic";
})
];
};
testScript = ''

Loading…
Cancel
Save