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 Dec 8, 2024
2 parents 789afaa + 0bc7caf commit 38a7813
Show file tree
Hide file tree
Showing 92 changed files with 3,112 additions and 888 deletions.
2 changes: 1 addition & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ let
# these are the only ones that are currently not
inherit (builtins) addErrorContext isPath trace typeOf unsafeGetAttrPos;
inherit (self.trivial) id const pipe concat or and xor bitAnd bitOr bitXor
bitNot boolToString mergeAttrs flip mapNullable inNixShell isFloat min max
bitNot boolToString mergeAttrs flip defaultTo mapNullable inNixShell isFloat min max
importJSON importTOML warn warnIf warnIfNot throwIf throwIfNot checkListOfEnum
info showWarnings nixpkgsVersion version isInOldestRelease oldestSupportedReleaseIsAtLeast
mod compare splitByAndCompare seq deepSeq lessThan add sub
Expand Down
34 changes: 34 additions & 0 deletions lib/trivial.nix
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,40 @@ in {
*/
flip = f: a: b: f b a;

/**
Return `maybeValue` if not null, otherwise return `default`.
# Inputs
`default`
: 1\. Function argument
`maybeValue`
: 2\. Function argument
# Examples
:::{.example}
## `lib.trivial.defaultTo` usage example
```nix
defaultTo "default" null
=> "default"
defaultTo "default" "foo"
=> "foo"
defaultTo "default" false
=> false
```
:::
*/
defaultTo = default: maybeValue:
if maybeValue != null then maybeValue
else default;

/**
Apply function if the supplied argument is non-null.
Expand Down
12 changes: 12 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15452,6 +15452,12 @@
githubId = 93013864;
name = "nat-418";
};
nateeag = {
github = "NateEag";
githubId = 837719;
name = "Nate Eagleson";
email = "[email protected]";
};
nathan-gs = {
email = "[email protected]";
github = "nathan-gs";
Expand Down Expand Up @@ -15712,6 +15718,12 @@
githubId = 7845120;
name = "Alex Martens";
};
nezia = {
email = "[email protected]";
github = "nezia1";
githubId = 43719748;
name = "Anthony Rodriguez";
};
ngerstle = {
name = "Nicholas Gerstle";
email = "[email protected]";
Expand Down
18 changes: 13 additions & 5 deletions nixos/modules/services/desktops/gnome/rygel.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# rygel service.
{ config, lib, pkgs, ... }:

let

cfg = config.services.gnome.rygel;

in

{
meta = {
maintainers = lib.teams.gnome.members;
Expand All @@ -18,17 +24,19 @@
'';
type = lib.types.bool;
};

package = lib.options.mkPackageOption pkgs "rygel" { };
};
};

###### implementation
config = lib.mkIf config.services.gnome.rygel.enable {
environment.systemPackages = [ pkgs.rygel ];
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];

services.dbus.packages = [ pkgs.rygel ];
services.dbus.packages = [ cfg.package ];

systemd.packages = [ pkgs.rygel ];
systemd.packages = [ cfg.package ];

environment.etc."rygel.conf".source = "${pkgs.rygel}/etc/rygel.conf";
environment.etc."rygel.conf".source = "${cfg.package}/etc/rygel.conf";
};
}
96 changes: 63 additions & 33 deletions nixos/modules/services/video/wivrn.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,66 @@ let

# For the application option to work with systemd PATH, we find the store binary path of
# the package, concat all of the following strings, and then update the application attribute.
# Application can either be a package or a list that has a package as the first element.
applicationExists = builtins.hasAttr "application" cfg.config.json;

# Since the json config attribute type "configFormat.type" doesn't allow specifying types for
# individual attributes, we have to type check manually.

# The application option must be either a package or a list with package as the first element.

# Checking if an application is provided
applicationAttrExists = builtins.hasAttr "application" cfg.config.json;
applicationListNotEmpty = (
if builtins.isList cfg.config.json.application then
(builtins.length cfg.config.json.application) != 0
else
true
);
applicationCheck = applicationExists && applicationListNotEmpty;
applicationCheck = applicationAttrExists && applicationListNotEmpty;

applicationBinary = (
# Manage packages and their exe paths
applicationAttr = (
if builtins.isList cfg.config.json.application then
builtins.head cfg.config.json.application
else
cfg.config.json.application
);
applicationStrings = builtins.tail cfg.config.json.application;

applicationPath = mkIf applicationCheck applicationBinary;
applicationPackage = mkIf applicationCheck applicationAttr;
applicationPackageExe = getExe applicationAttr;
serverPackageExe = getExe cfg.package;

# Managing strings
applicationStrings = builtins.tail cfg.config.json.application;
applicationConcat = (
if builtins.isList cfg.config.json.application then
builtins.concatStringsSep " " ([ (getExe applicationBinary) ] ++ applicationStrings)
builtins.concatStringsSep " " ([ applicationPackageExe ] ++ applicationStrings)
else
(getExe applicationBinary)
applicationPackageExe
);

# Manage config file
applicationUpdate = recursiveUpdate cfg.config.json (
optionalAttrs applicationCheck { application = applicationConcat; }
);
configFile = configFormat.generate "config.json" applicationUpdate;
enabledConfig = optionalString cfg.config.enable "-f ${configFile}";

# Manage server executables and flags
serverExec = builtins.concatStringsSep " " (
[
serverPackageExe
"--systemd"
enabledConfig
]
++ cfg.extraServerFlags
);
applicationExec = builtins.concatStringsSep " " (
[
serverPackageExe
"--application"
enabledConfig
]
++ cfg.extraApplicationFlags
);
in
{
options = {
Expand Down Expand Up @@ -84,6 +114,19 @@ in
};
};

extraServerFlags = mkOption {
type = types.listOf types.str;
description = "Flags to add to the wivrn service.";
default = [ ];
example = ''[ "--no-publish-service" ]'';
};

extraApplicationFlags = mkOption {
type = types.listOf types.str;
description = "Flags to add to the wivrn-application service. This is NOT the WiVRn startup application.";
default = [ ];
};

extraPackages = mkOption {
type = types.listOf types.package;
description = "Packages to add to the wivrn-application service $PATH.";
Expand All @@ -96,17 +139,17 @@ in
json = mkOption {
type = configFormat.type;
description = ''
Configuration for WiVRn. The attributes are serialized to JSON in config.json.
Configuration for WiVRn. The attributes are serialized to JSON in config.json. If a config or certain attributes are not provided, the server will default to stock values.
Note that the application option must be either a package or a
list with package as the first element.
See https://github.com/Meumeu/WiVRn/blob/master/docs/configuration.md
See https://github.com/WiVRn/WiVRn/blob/master/docs/configuration.md
'';
default = { };
example = literalExpression ''
{
scale = 0.8;
scale = 0.5;
bitrate = 100000000;
encoders = [
{
Expand All @@ -119,7 +162,6 @@ in
}
];
application = [ pkgs.wlx-overlay-s ];
tcp_only = true;
}
'';
};
Expand All @@ -130,14 +172,14 @@ in
config = mkIf cfg.enable {
assertions = [
{
assertion = !applicationCheck || isDerivation applicationBinary;
assertion = !applicationCheck || isDerivation applicationAttr;
message = "The application in WiVRn configuration is not a package. Please ensure that the application is a package or that a package is the first element in the list.";
}
];

systemd.user = {
services = {
# The WiVRn server runs in a hardened service and starts the applications in a different service
# The WiVRn server runs in a hardened service and starts the application in a different service
wivrn = {
description = "WiVRn XR runtime service";
environment = {
Expand All @@ -148,9 +190,7 @@ in
IPC_EXIT_ON_DISCONNECT = "off";
} // cfg.monadoEnvironment;
serviceConfig = {
ExecStart = (
(getExe cfg.package) + " --systemd" + optionalString cfg.config.enable " -f ${configFile}"
);
ExecStart = serverExec;
# Hardening options
CapabilityBoundingSet = [ "CAP_SYS_NICE" ];
AmbientCapabilities = [ "CAP_SYS_NICE" ];
Expand All @@ -169,34 +209,24 @@ in
RestrictSUIDSGID = true;
};
wantedBy = mkIf cfg.autoStart [ "default.target" ];
restartTriggers = [
cfg.package
configFile
];
restartTriggers = [ cfg.package ];
};
wivrn-application = mkIf applicationCheck {
description = "WiVRn application service";
requires = [ "wivrn.service" ];
serviceConfig = {
ExecStart = (
(getExe cfg.package) + " --application" + optionalString cfg.config.enable " -f ${configFile}"
);
ExecStart = applicationExec;
Restart = "on-failure";
RestartSec = 0;
PrivateTmp = true;
};
# We need to add the application to PATH so WiVRn can find it
path = [ applicationPath ] ++ cfg.extraPackages;
path = [ applicationPackage ] ++ cfg.extraPackages;
};
};
};

services = {
# WiVRn can be used with some wired headsets so we include xr-hardware
udev.packages = with pkgs; [
android-udev-rules
xr-hardware
];
udev.packages = with pkgs; [ android-udev-rules ];
avahi = {
enable = true;
publish = {
Expand All @@ -214,7 +244,7 @@ in
environment = {
systemPackages = [
cfg.package
applicationPath
applicationPackage
];
pathsToLink = [ "/share/openxr" ];
etc."xdg/openxr/1/active_runtime.json" = mkIf cfg.defaultRuntime {
Expand Down
2 changes: 1 addition & 1 deletion nixos/tests/web-apps/immich.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import ../make-test-python.nix (
res = machine.succeed("""
curl -f -H 'Cookie: immich_access_token=%s' http://localhost:2283/api/jobs
""" % token)
assert json.loads(res)["backupDatabase"]["jobCounts"]["active"] == 1
assert sum(json.loads(res)["backupDatabase"]["jobCounts"].values()) >= 1
machine.wait_until_succeeds("ls /var/lib/immich/backups/*.sql.gz")
'';
}
Expand Down
Loading

0 comments on commit 38a7813

Please sign in to comment.