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] authored Oct 31, 2021
2 parents f66386e + 1b209f6 commit 7ca1d48
Show file tree
Hide file tree
Showing 52 changed files with 635 additions and 381 deletions.
13 changes: 12 additions & 1 deletion nixos/lib/testing-python.nix
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ rec {
build-vms = import ./build-vms.nix {
inherit system lib pkgs minimal specialArgs;
extraConfigurations = extraConfigurations ++ [(
{ config, ... }:
{
virtualisation.qemu.package = qemu_pkg;

Expand All @@ -230,7 +231,17 @@ rec {
# copied to the image.
virtualisation.additionalPaths =
lib.optional
(builtins.hasContext testScript')
# A testScript may evaluate nodes, which has caused
# infinite recursions. The demand cycle involves:
# testScript -->
# nodes -->
# toplevel -->
# additionalPaths -->
# hasContext testScript' -->
# testScript (ad infinitum)
# If we don't need to build an image, we can break this
# cycle by short-circuiting when useNixStoreImage is false.
(config.virtualisation.useNixStoreImage && builtins.hasContext testScript')
(pkgs.writeStringReferencesToFile testScript');

# Ensure we do not use aliases. Ideally this is only set
Expand Down
20 changes: 10 additions & 10 deletions nixos/modules/services/desktops/pipewire/pipewire-media-session.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ let
# Use upstream config files passed through spa-json-dump as the base
# Patched here as necessary for them to work with this module
defaults = {
alsa-monitor = (builtins.fromJSON (builtins.readFile ./alsa-monitor.conf.json));
bluez-monitor = (builtins.fromJSON (builtins.readFile ./bluez-monitor.conf.json));
media-session = (builtins.fromJSON (builtins.readFile ./media-session.conf.json));
v4l2-monitor = (builtins.fromJSON (builtins.readFile ./v4l2-monitor.conf.json));
alsa-monitor = (builtins.fromJSON (builtins.readFile ./media-session/alsa-monitor.conf.json));
bluez-monitor = (builtins.fromJSON (builtins.readFile ./media-session/bluez-monitor.conf.json));
media-session = (builtins.fromJSON (builtins.readFile ./media-session/media-session.conf.json));
v4l2-monitor = (builtins.fromJSON (builtins.readFile ./media-session/v4l2-monitor.conf.json));
};

configs = {
Expand All @@ -43,8 +43,8 @@ in {

package = mkOption {
type = types.package;
default = pkgs.pipewire.mediaSession;
defaultText = literalExpression "pkgs.pipewire.mediaSession";
default = pkgs.pipewire-media-session;
defaultText = literalExpression "pkgs.pipewire-media-session";
description = ''
The pipewire-media-session derivation to use.
'';
Expand All @@ -55,7 +55,7 @@ in {
type = json.type;
description = ''
Configuration for the media session core. For details see
https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/${cfg.package.version}/src/daemon/media-session.d/media-session.conf
https://gitlab.freedesktop.org/pipewire/media-session/-/blob/${cfg.package.version}/src/daemon/media-session.d/media-session.conf
'';
default = {};
};
Expand All @@ -64,7 +64,7 @@ in {
type = json.type;
description = ''
Configuration for the alsa monitor. For details see
https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/${cfg.package.version}/src/daemon/media-session.d/alsa-monitor.conf
https://gitlab.freedesktop.org/pipewire/media-session/-/blob/${cfg.package.version}/src/daemon/media-session.d/alsa-monitor.conf
'';
default = {};
};
Expand All @@ -73,7 +73,7 @@ in {
type = json.type;
description = ''
Configuration for the bluez5 monitor. For details see
https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/${cfg.package.version}/src/daemon/media-session.d/bluez-monitor.conf
https://gitlab.freedesktop.org/pipewire/media-session/-/blob/${cfg.package.version}/src/daemon/media-session.d/bluez-monitor.conf
'';
default = {};
};
Expand All @@ -82,7 +82,7 @@ in {
type = json.type;
description = ''
Configuration for the V4L2 monitor. For details see
https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/${cfg.package.version}/src/daemon/media-session.d/v4l2-monitor.conf
https://gitlab.freedesktop.org/pipewire/media-session/-/blob/${cfg.package.version}/src/daemon/media-session.d/v4l2-monitor.conf
'';
default = {};
};
Expand Down
11 changes: 5 additions & 6 deletions nixos/modules/services/desktops/pipewire/pipewire.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ let
# Use upstream config files passed through spa-json-dump as the base
# Patched here as necessary for them to work with this module
defaults = {
client = builtins.fromJSON (builtins.readFile ./client.conf.json);
client-rt = builtins.fromJSON (builtins.readFile ./client-rt.conf.json);
jack = builtins.fromJSON (builtins.readFile ./jack.conf.json);
# Remove session manager invocation from the upstream generated file, it points to the wrong path
pipewire = builtins.fromJSON (builtins.readFile ./pipewire.conf.json);
pipewire-pulse = builtins.fromJSON (builtins.readFile ./pipewire-pulse.conf.json);
client = builtins.fromJSON (builtins.readFile ./daemon/client.conf.json);
client-rt = builtins.fromJSON (builtins.readFile ./daemon/client-rt.conf.json);
jack = builtins.fromJSON (builtins.readFile ./daemon/jack.conf.json);
pipewire = builtins.fromJSON (builtins.readFile ./daemon/pipewire.conf.json);
pipewire-pulse = builtins.fromJSON (builtins.readFile ./daemon/pipewire-pulse.conf.json);
};

configs = {
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/web-apps/nextcloud.nix
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ in {
{ systemd.timers.nextcloud-cron = {
wantedBy = [ "timers.target" ];
timerConfig.OnBootSec = "5m";
timerConfig.OnUnitActiveSec = "15m";
timerConfig.OnUnitActiveSec = "5m";
timerConfig.Unit = "nextcloud-cron.service";
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,28 @@
import os.path
from typing import Tuple, List, Optional

SystemIdentifier = Tuple[Optional[str], int, Optional[str]]


def copy_if_not_exists(source: str, dest: str) -> None:
if not os.path.exists(dest):
shutil.copyfile(source, dest)


def system_dir(profile: Optional[str], generation: int) -> str:
def generation_dir(profile: Optional[str], generation: int) -> str:
if profile:
return "/nix/var/nix/profiles/system-profiles/%s-%d-link" % (profile, generation)
else:
return "/nix/var/nix/profiles/system-%d-link" % (generation)

BOOT_ENTRY = """title NixOS{profile}
def system_dir(profile: Optional[str], generation: int, specialisation: Optional[str]) -> str:
d = generation_dir(profile, generation)
if specialisation:
return os.path.join(d, "specialisation", specialisation)
else:
return d

BOOT_ENTRY = """title NixOS{profile}{specialisation}
version Generation {generation} {description}
linux {kernel}
initrd {initrd}
Expand All @@ -46,26 +55,34 @@ def system_dir(profile: Optional[str], generation: int) -> str:
"""


def write_loader_conf(profile: Optional[str], generation: int) -> None:
def generation_conf_filename(profile: Optional[str], generation: int, specialisation: Optional[str]) -> str:
pieces = [
"nixos",
profile or None,
"generation",
str(generation),
f"specialisation-{specialisation}" if specialisation else None,
]
return "-".join(p for p in pieces if p) + ".conf"


def write_loader_conf(profile: Optional[str], generation: int, specialisation: Optional[str]) -> None:
with open("@efiSysMountPoint@/loader/loader.conf.tmp", 'w') as f:
if "@timeout@" != "":
f.write("timeout @timeout@\n")
if profile:
f.write("default nixos-%s-generation-%d.conf\n" % (profile, generation))
else:
f.write("default nixos-generation-%d.conf\n" % (generation))
f.write("default %s\n" % generation_conf_filename(profile, generation, specialisation))
if not @editor@:
f.write("editor 0\n");
f.write("console-mode @consoleMode@\n");
os.rename("@efiSysMountPoint@/loader/loader.conf.tmp", "@efiSysMountPoint@/loader/loader.conf")


def profile_path(profile: Optional[str], generation: int, name: str) -> str:
return os.path.realpath("%s/%s" % (system_dir(profile, generation), name))
def profile_path(profile: Optional[str], generation: int, specialisation: Optional[str], name: str) -> str:
return os.path.realpath("%s/%s" % (system_dir(profile, generation, specialisation), name))


def copy_from_profile(profile: Optional[str], generation: int, name: str, dry_run: bool = False) -> str:
store_file_path = profile_path(profile, generation, name)
def copy_from_profile(profile: Optional[str], generation: int, specialisation: Optional[str], name: str, dry_run: bool = False) -> str:
store_file_path = profile_path(profile, generation, specialisation, name)
suffix = os.path.basename(store_file_path)
store_dir = os.path.basename(os.path.dirname(store_file_path))
efi_file_path = "/efi/nixos/%s-%s.efi" % (store_dir, suffix)
Expand Down Expand Up @@ -95,26 +112,25 @@ def describe_generation(generation_dir: str) -> str:
return description


def write_entry(profile: Optional[str], generation: int, machine_id: str) -> None:
kernel = copy_from_profile(profile, generation, "kernel")
initrd = copy_from_profile(profile, generation, "initrd")
def write_entry(profile: Optional[str], generation: int, specialisation: Optional[str], machine_id: str) -> None:
kernel = copy_from_profile(profile, generation, specialisation, "kernel")
initrd = copy_from_profile(profile, generation, specialisation, "initrd")
try:
append_initrd_secrets = profile_path(profile, generation, "append-initrd-secrets")
append_initrd_secrets = profile_path(profile, generation, specialisation, "append-initrd-secrets")
subprocess.check_call([append_initrd_secrets, "@efiSysMountPoint@%s" % (initrd)])
except FileNotFoundError:
pass
if profile:
entry_file = "@efiSysMountPoint@/loader/entries/nixos-%s-generation-%d.conf" % (profile, generation)
else:
entry_file = "@efiSysMountPoint@/loader/entries/nixos-generation-%d.conf" % (generation)
generation_dir = os.readlink(system_dir(profile, generation))
entry_file = "@efiSysMountPoint@/loader/entries/%s" % (
generation_conf_filename(profile, generation, specialisation))
generation_dir = os.readlink(system_dir(profile, generation, specialisation))
tmp_path = "%s.tmp" % (entry_file)
kernel_params = "init=%s/init " % generation_dir

with open("%s/kernel-params" % (generation_dir)) as params_file:
kernel_params = kernel_params + params_file.read()
with open(tmp_path, 'w') as f:
f.write(BOOT_ENTRY.format(profile=" [" + profile + "]" if profile else "",
specialisation=" (%s)" % specialisation if specialisation else "",
generation=generation,
kernel=kernel,
initrd=initrd,
Expand All @@ -133,7 +149,7 @@ def mkdir_p(path: str) -> None:
raise


def get_generations(profile: Optional[str] = None) -> List[Tuple[Optional[str], int]]:
def get_generations(profile: Optional[str] = None) -> List[SystemIdentifier]:
gen_list = subprocess.check_output([
"@nix@/bin/nix-env",
"--list-generations",
Expand All @@ -145,10 +161,19 @@ def get_generations(profile: Optional[str] = None) -> List[Tuple[Optional[str],
gen_lines.pop()

configurationLimit = @configurationLimit@
return [ (profile, int(line.split()[0])) for line in gen_lines ][-configurationLimit:]
configurations: List[SystemIdentifier] = [ (profile, int(line.split()[0]), None) for line in gen_lines ]
return configurations[-configurationLimit:]


def get_specialisations(profile: Optional[str], generation: int, _: Optional[str]) -> List[SystemIdentifier]:
specialisations_dir = os.path.join(
system_dir(profile, generation, None), "specialisation")
if not os.path.exists(specialisations_dir):
return []
return [(profile, generation, spec) for spec in os.listdir(specialisations_dir)]


def remove_old_entries(gens: List[Tuple[Optional[str], int]]) -> None:
def remove_old_entries(gens: List[SystemIdentifier]) -> None:
rex_profile = re.compile("^@efiSysMountPoint@/loader/entries/nixos-(.*)-generation-.*\.conf$")
rex_generation = re.compile("^@efiSysMountPoint@/loader/entries/nixos.*-generation-(.*)\.conf$")
known_paths = []
Expand Down Expand Up @@ -243,6 +268,8 @@ def main() -> None:
for gen in gens:
try:
write_entry(*gen, machine_id)
for specialisation in get_specialisations(*gen):
write_entry(*specialisation, machine_id)
if os.readlink(system_dir(*gen)) == args.default_config:
write_loader_conf(*gen)
except OSError as e:
Expand Down
5 changes: 2 additions & 3 deletions nixos/tests/ghostunnel.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{ pkgs, ... }: import ./make-test-python.nix {

import ./make-test-python.nix ({ pkgs, ... }: {
nodes = {
backend = { pkgs, ... }: {
services.nginx.enable = true;
Expand Down Expand Up @@ -101,4 +100,4 @@
meta.maintainers = with pkgs.lib.maintainers; [
roberth
];
}
})
2 changes: 1 addition & 1 deletion nixos/tests/nixops/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let
users.users.person.isNormalUser = true;
virtualisation.writableStore = true;
virtualisation.memorySize = 1024 /*MiB*/;
virtualisation.pathsInNixDB = [
virtualisation.additionalPaths = [
pkgs.hello
pkgs.figlet

Expand Down
23 changes: 23 additions & 0 deletions nixos/tests/systemd-boot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,29 @@ in
'';
};

# Check that specialisations create corresponding boot entries.
specialisation = makeTest {
name = "systemd-boot-specialisation";
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ lukegb ];

machine = { pkgs, lib, ... }: {
imports = [ common ];
specialisation.something.configuration = {};
};

testScript = ''
machine.start()
machine.wait_for_unit("multi-user.target")
machine.succeed(
"test -e /boot/loader/entries/nixos-generation-1-specialisation-something.conf"
)
machine.succeed(
"grep -q 'title NixOS (something)' /boot/loader/entries/nixos-generation-1-specialisation-something.conf"
)
'';
};

# Boot without having created an EFI entry--instead using default "/EFI/BOOT/BOOTX64.EFI"
fallback = makeTest {
name = "systemd-boot-fallback";
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/blockchains/btcpayserver/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

buildDotnetModule rec {
pname = "btcpayserver";
version = "1.2.4";
version = "1.3.1";

src = fetchFromGitHub {
owner = pname;
repo = pname;
rev = "v${version}";
sha256 = "sha256-vjNJ08twsJ036TTFF6srOGshDpP7ZwWCGN0XjrtFT/g=";
sha256 = "sha256-gJvUW/U+O83Q0VDo6a5VkWx2RuofMNs/mPn/hnM2XiE=";
};

projectFile = "BTCPayServer/BTCPayServer.csproj";
Expand Down
Loading

0 comments on commit 7ca1d48

Please sign in to comment.