Skip to content

Commit

Permalink
Merge master into staging-next
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Mar 16, 2023
2 parents 80a0ae1 + c3e12e5 commit 455127a
Show file tree
Hide file tree
Showing 85 changed files with 586 additions and 514 deletions.
2 changes: 1 addition & 1 deletion lib/generators.nix
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ ${expr "" v}
(if v then "True" else "False")
else if isFunction v then
abort "generators.toDhall: cannot convert a function to Dhall"
else if isNull v then
else if v == null then
abort "generators.toDhall: cannot convert a null to Dhall"
else
builtins.toJSON v;
Expand Down
2 changes: 1 addition & 1 deletion maintainers/scripts/haskell/dependencies.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let
pkgs = import ../../.. {};
inherit (pkgs) lib;
getDeps = _: pkg: {
deps = builtins.filter (x: !isNull x) (map (x: x.pname or null) (pkg.propagatedBuildInputs or []));
deps = builtins.filter (x: x != null) (map (x: x.pname or null) (pkg.propagatedBuildInputs or []));
broken = (pkg.meta.hydraPlatforms or [null]) == [];
};
in
Expand Down
1 change: 0 additions & 1 deletion nixos/lib/test-driver/test_driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ def create_machine(self, args: Dict[str, Any]) -> Machine:
start_command=cmd,
name=name,
keep_vm_state=args.get("keep_vm_state", False),
allow_reboot=args.get("allow_reboot", False),
)

def serial_stdout_on(self) -> None:
Expand Down
28 changes: 17 additions & 11 deletions nixos/lib/test-driver/test_driver/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,24 +144,22 @@ def cmd(
self,
monitor_socket_path: Path,
shell_socket_path: Path,
allow_reboot: bool = False, # TODO: unused, legacy?
allow_reboot: bool = False,
) -> str:
display_opts = ""
display_available = any(x in os.environ for x in ["DISPLAY", "WAYLAND_DISPLAY"])
if not display_available:
display_opts += " -nographic"

# qemu options
qemu_opts = ""
qemu_opts += (
""
if allow_reboot
else " -no-reboot"
qemu_opts = (
" -device virtio-serial"
" -device virtconsole,chardev=shell"
" -device virtio-rng-pci"
" -serial stdio"
)
if not allow_reboot:
qemu_opts += " -no-reboot"
# TODO: qemu script already catpures this env variable, legacy?
qemu_opts += " " + os.environ.get("QEMU_OPTS", "")

Expand Down Expand Up @@ -195,9 +193,10 @@ def run(
shared_dir: Path,
monitor_socket_path: Path,
shell_socket_path: Path,
allow_reboot: bool,
) -> subprocess.Popen:
return subprocess.Popen(
self.cmd(monitor_socket_path, shell_socket_path),
self.cmd(monitor_socket_path, shell_socket_path, allow_reboot),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
Expand Down Expand Up @@ -312,7 +311,6 @@ class Machine:

start_command: StartCommand
keep_vm_state: bool
allow_reboot: bool

process: Optional[subprocess.Popen]
pid: Optional[int]
Expand All @@ -337,13 +335,11 @@ def __init__(
start_command: StartCommand,
name: str = "machine",
keep_vm_state: bool = False,
allow_reboot: bool = False,
callbacks: Optional[List[Callable]] = None,
) -> None:
self.out_dir = out_dir
self.tmp_dir = tmp_dir
self.keep_vm_state = keep_vm_state
self.allow_reboot = allow_reboot
self.name = name
self.start_command = start_command
self.callbacks = callbacks if callbacks is not None else []
Expand Down Expand Up @@ -874,7 +870,7 @@ def send_console(self, chars: str) -> None:
self.process.stdin.write(chars.encode())
self.process.stdin.flush()

def start(self) -> None:
def start(self, allow_reboot: bool = False) -> None:
if self.booted:
return

Expand All @@ -898,6 +894,7 @@ def create_socket(path: Path) -> socket.socket:
self.shared_dir,
self.monitor_path,
self.shell_path,
allow_reboot,
)
self.monitor, _ = monitor_socket.accept()
self.shell, _ = shell_socket.accept()
Expand Down Expand Up @@ -946,6 +943,15 @@ def crash(self) -> None:
self.send_monitor_command("quit")
self.wait_for_shutdown()

def reboot(self) -> None:
"""Press Ctrl+Alt+Delete in the guest.
Prepares the machine to be reconnected which is useful if the
machine was started with `allow_reboot = True`
"""
self.send_key(f"ctrl-alt-delete")
self.connected = False

def wait_for_x(self) -> None:
"""Wait until it is possible to connect to the X server. Note that
testing the existence of /tmp/.X11-unix/X0 is insufficient.
Expand Down
8 changes: 4 additions & 4 deletions nixos/modules/hardware/device-tree.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ let
};
};

filterDTBs = src: if isNull cfg.filter
filterDTBs = src: if cfg.filter == null
then "${src}/dtbs"
else
pkgs.runCommand "dtbs-filtered" {} ''
Expand Down Expand Up @@ -93,8 +93,8 @@ let
# Fill in `dtboFile` for each overlay if not set already.
# Existence of one of these is guarded by assertion below
withDTBOs = xs: flip map xs (o: o // { dtboFile =
if isNull o.dtboFile then
if !isNull o.dtsFile then compileDTS o.name o.dtsFile
if o.dtboFile == null then
if o.dtsFile != null then compileDTS o.name o.dtsFile
else compileDTS o.name (pkgs.writeText "dts" o.dtsText)
else o.dtboFile; } );

Expand Down Expand Up @@ -181,7 +181,7 @@ in
config = mkIf (cfg.enable) {

assertions = let
invalidOverlay = o: isNull o.dtsFile && isNull o.dtsText && isNull o.dtboFile;
invalidOverlay = o: (o.dtsFile == null) && (o.dtsText == null) && (o.dtboFile == null);
in lib.singleton {
assertion = lib.all (o: !invalidOverlay o) cfg.overlays;
message = ''
Expand Down
6 changes: 3 additions & 3 deletions nixos/modules/security/doas.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ let
];

mkArgs = rule:
if (isNull rule.args) then ""
if (rule.args == null) then ""
else if (length rule.args == 0) then "args"
else "args ${concatStringsSep " " rule.args}";

mkRule = rule:
let
opts = mkOpts rule;

as = optionalString (!isNull rule.runAs) "as ${rule.runAs}";
as = optionalString (rule.runAs != null) "as ${rule.runAs}";

cmd = optionalString (!isNull rule.cmd) "cmd ${rule.cmd}";
cmd = optionalString (rule.cmd != null) "cmd ${rule.cmd}";

args = mkArgs rule;
in
Expand Down
4 changes: 2 additions & 2 deletions nixos/modules/security/pam.nix
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ let
};
}));

motd = if isNull config.users.motdFile
motd = if config.users.motdFile == null
then pkgs.writeText "motd" config.users.motd
else config.users.motdFile;

Expand Down Expand Up @@ -1233,7 +1233,7 @@ in
config = {
assertions = [
{
assertion = isNull config.users.motd || isNull config.users.motdFile;
assertion = config.users.motd == null || config.users.motdFile == null;
message = ''
Only one of users.motd and users.motdFile can be set.
'';
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/cluster/kubernetes/pki.nix
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ in
'';
})]);

environment.etc.${cfg.etcClusterAdminKubeconfig}.source = mkIf (!isNull cfg.etcClusterAdminKubeconfig)
environment.etc.${cfg.etcClusterAdminKubeconfig}.source = mkIf (cfg.etcClusterAdminKubeconfig != null)
clusterAdminKubeconfig;

environment.systemPackages = mkIf (top.kubelet.enable || top.proxy.enable) [
Expand Down
4 changes: 2 additions & 2 deletions nixos/modules/services/hardware/undervolt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ let
cfg = config.services.undervolt;

mkPLimit = limit: window:
if (isNull limit && isNull window) then null
else assert asserts.assertMsg (!isNull limit && !isNull window) "Both power limit and window must be set";
if (limit == null && window == null) then null
else assert asserts.assertMsg (limit != null && window != null) "Both power limit and window must be set";
"${toString limit} ${toString window}";
cliArgs = lib.cli.toGNUCommandLine {} {
inherit (cfg)
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/home-automation/home-assistant.nix
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ in {
config = mkIf cfg.enable {
assertions = [
{
assertion = cfg.openFirewall -> !isNull cfg.config;
assertion = cfg.openFirewall -> cfg.config != null;
message = "openFirewall can only be used with a declarative config";
}
];
Expand Down
8 changes: 4 additions & 4 deletions nixos/modules/services/networking/multipath.nix
Original file line number Diff line number Diff line change
Expand Up @@ -513,22 +513,22 @@ in {
${indentLines 2 devices}
}
${optionalString (!isNull defaults) ''
${optionalString (defaults != null) ''
defaults {
${indentLines 2 defaults}
}
''}
${optionalString (!isNull blacklist) ''
${optionalString (blacklist != null) ''
blacklist {
${indentLines 2 blacklist}
}
''}
${optionalString (!isNull blacklist_exceptions) ''
${optionalString (blacklist_exceptions != null) ''
blacklist_exceptions {
${indentLines 2 blacklist_exceptions}
}
''}
${optionalString (!isNull overrides) ''
${optionalString (overrides != null) ''
overrides {
${indentLines 2 overrides}
}
Expand Down
6 changes: 3 additions & 3 deletions nixos/modules/services/networking/radicale.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let
listToValue = concatMapStringsSep ", " (generators.mkValueStringDefault { });
};

pkg = if isNull cfg.package then
pkg = if cfg.package == null then
pkgs.radicale
else
cfg.package;
Expand Down Expand Up @@ -117,13 +117,13 @@ in {
}
];

warnings = optional (isNull cfg.package && versionOlder config.system.stateVersion "17.09") ''
warnings = optional (cfg.package == null && versionOlder config.system.stateVersion "17.09") ''
The configuration and storage formats of your existing Radicale
installation might be incompatible with the newest version.
For upgrade instructions see
https://radicale.org/2.1.html#documentation/migration-from-1xx-to-2xx.
Set services.radicale.package to suppress this warning.
'' ++ optional (isNull cfg.package && versionOlder config.system.stateVersion "20.09") ''
'' ++ optional (cfg.package == null && versionOlder config.system.stateVersion "20.09") ''
The configuration format of your existing Radicale installation might be
incompatible with the newest version. For upgrade instructions see
https://github.com/Kozea/Radicale/blob/3.0.6/NEWS.md#upgrade-checklist.
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/system/self-deploy.nix
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ in

requires = lib.mkIf (!(isPathType cfg.repository)) [ "network-online.target" ];

environment.GIT_SSH_COMMAND = lib.mkIf (!(isNull cfg.sshKeyFile))
environment.GIT_SSH_COMMAND = lib.mkIf (cfg.sshKeyFile != null)
"${pkgs.openssh}/bin/ssh -i ${lib.escapeShellArg cfg.sshKeyFile}";

restartIfChanged = false;
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/web-apps/dolibarr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let
if (any (str: k == str) secretKeys) then v
else if isString v then "'${v}'"
else if isBool v then boolToString v
else if isNull v then "null"
else if v == null then "null"
else toString v
;
in
Expand Down
11 changes: 5 additions & 6 deletions nixos/modules/services/web-apps/writefreely.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ let
format = pkgs.formats.ini {
mkKeyValue = key: value:
let
value' = if builtins.isNull value then
""
else if builtins.isBool value then
if value == true then "true" else "false"
else
toString value;
value' = lib.optionalString (value != null)
(if builtins.isBool value then
if value == true then "true" else "false"
else
toString value);
in "${key} = ${value'}";
};

Expand Down
13 changes: 11 additions & 2 deletions nixos/tests/login.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import ./make-test-python.nix ({ pkgs, latestKernel ? false, ... }:
};

testScript = ''
machine.start(allow_reboot = True)
machine.wait_for_unit("multi-user.target")
machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
machine.screenshot("postboot")
Expand Down Expand Up @@ -53,7 +55,14 @@ import ./make-test-python.nix ({ pkgs, latestKernel ? false, ... }:
machine.screenshot("getty")
with subtest("Check whether ctrl-alt-delete works"):
machine.send_key("ctrl-alt-delete")
machine.wait_for_shutdown()
boot_id1 = machine.succeed("cat /proc/sys/kernel/random/boot_id").strip()
assert boot_id1 != ""
machine.reboot()
boot_id2 = machine.succeed("cat /proc/sys/kernel/random/boot_id").strip()
assert boot_id2 != ""
assert boot_id1 != boot_id2
'';
})
4 changes: 2 additions & 2 deletions pkgs/applications/audio/ardour/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@
}:
stdenv.mkDerivation rec {
pname = "ardour";
version = "7.1";
version = "7.3";

# We can't use `fetchFromGitea` here, as attempting to fetch release archives from git.ardour.org
# result in an empty archive. See https://tracker.ardour.org/view.php?id=7328 for more info.
src = fetchgit {
url = "git://git.ardour.org/ardour/ardour.git";
rev = version;
hash = "sha256-eLF9n71tjdPA+ks0B8UonmPZqRgcZEA7ok79+m9PioU=";
hash = "sha256-fDZGmKQ6qgENkq8NY/J67Jym+IXoOYs8DT4xyPXLcC4=";
};

bundledContent = fetchzip {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/audio/cmus/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
, cddbSupport ? true, libcddb ? null
, cdioSupport ? true, libcdio ? null, libcdio-paranoia ? null
, cueSupport ? true, libcue ? null
, discidSupport ? (!stdenv.isDarwin), libdiscid ? null
, discidSupport ? false, libdiscid ? null
, ffmpegSupport ? true, ffmpeg ? null
, flacSupport ? true, flac ? null
, madSupport ? true, libmad ? null
Expand Down
14 changes: 7 additions & 7 deletions pkgs/applications/editors/emacs/elisp-packages/libgenerated.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,28 @@ in {
error = sourceArgs.error or args.error or null;
hasSource = lib.hasAttr variant args;
pname = builtins.replaceStrings [ "@" ] [ "at" ] ename;
broken = ! isNull error;
broken = error != null;
in
if hasSource then
lib.nameValuePair ename (
self.callPackage ({ melpaBuild, fetchurl, ... }@pkgargs:
melpaBuild {
inherit pname ename commit;
version = if isNull version then "" else
lib.concatStringsSep "." (map toString
version = lib.optionalString (version != null)
(lib.concatStringsSep "." (map toString
# Hack: Melpa archives contains versions with parse errors such as [ 4 4 -4 413 ] which should be 4.4-413
# This filter method is still technically wrong, but it's computationally cheap enough and tapers over the issue
(builtins.filter (n: n >= 0) version));
(builtins.filter (n: n >= 0) version)));
# TODO: Broken should not result in src being null (hack to avoid eval errors)
src = if (isNull sha256 || broken) then null else
src = if (sha256 == null || broken) then null else
lib.getAttr fetcher (fetcherGenerators args sourceArgs);
recipe = if isNull commit then null else
recipe = if commit == null then null else
fetchurl {
name = pname + "-recipe";
url = "https://raw.githubusercontent.com/melpa/melpa/${commit}/recipes/${ename}";
inherit sha256;
};
packageRequires = lib.optionals (! isNull deps)
packageRequires = lib.optionals (deps != null)
(map (dep: pkgargs.${dep} or self.${dep} or null)
deps);
meta = (sourceArgs.meta or {}) // {
Expand Down
Loading

0 comments on commit 455127a

Please sign in to comment.