Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move systemd-lib.nix and systemd-unit-options.nix into utils #146815

Merged
merged 1 commit into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ config, lib }:
{ lib, systemdUtils }:

with systemdUtils.lib;
with lib;
with import ./systemd-lib.nix { inherit config lib pkgs; };

let
checkService = checkUnitConfig "Service" [
Expand Down
7 changes: 6 additions & 1 deletion nixos/lib/utils.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pkgs: with pkgs.lib;
{ lib, config, pkgs }: with lib;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not great that there's more wiring now, but I think we'll have to wait with systemd refactoring, as mentioned in the earlier comment.
I guess that's just the faith of "utils", to grow all sorts of weird dependencies, because everyone wants to use them for their own distinct purposes. I hope we'll remove it altogether in the future.


rec {

Expand Down Expand Up @@ -165,4 +165,9 @@ rec {
${builtins.toJSON set}
EOF
'';

systemdUtils = {
lib = import ./systemd-lib.nix { inherit lib config pkgs; };
unitOptions = import ./systemd-unit-options.nix { inherit lib systemdUtils; };
};
}
4 changes: 2 additions & 2 deletions nixos/modules/misc/extra-arguments.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ pkgs, ... }:
{ lib, config, pkgs, ... }:

{
_module.args = {
utils = import ../../lib/utils.nix pkgs;
utils = import ../../lib/utils.nix { inherit lib config pkgs; };
};
}
6 changes: 2 additions & 4 deletions nixos/modules/security/systemd-confinement.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{ config, pkgs, lib, ... }:
{ config, pkgs, lib, utils, ... }:

let
toplevelConfig = config;
inherit (lib) types;
inherit (import ../system/boot/systemd-lib.nix {
inherit config pkgs lib;
}) mkPathSafeName;
inherit (utils.systemdUtils.lib) mkPathSafeName;
in {
options.systemd.services = lib.mkOption {
type = types.attrsOf (types.submodule ({ name, config, ... }: {
Expand Down
4 changes: 2 additions & 2 deletions nixos/modules/services/backup/restic.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, utils, ... }:

with lib;

let
# Type for a valid systemd unit option. Needed for correctly passing "timerConfig" to "systemd.timers"
unitOption = (import ../../system/boot/systemd-unit-options.nix { inherit config lib; }).unitOption;
inherit (utils.systemdUtils.unitOptions) unitOption;
in
{
options.services.restic.backups = mkOption {
Expand Down
6 changes: 3 additions & 3 deletions nixos/modules/system/boot/networkd.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, utils, ... }:

with utils.systemdUtils.unitOptions;
with utils.systemdUtils.lib;
with lib;
with import ./systemd-unit-options.nix { inherit config lib; };
with import ./systemd-lib.nix { inherit config lib pkgs; };

let

Expand Down
6 changes: 3 additions & 3 deletions nixos/modules/system/boot/systemd-nspawn.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{ config, lib , pkgs, ...}:
{ config, lib, pkgs, utils, ...}:

with utils.systemdUtils.unitOptions;
with utils.systemdUtils.lib;
with lib;
with import ./systemd-unit-options.nix { inherit config lib; };
with import ./systemd-lib.nix { inherit config lib pkgs; };

let
cfg = config.systemd.nspawn;
Expand Down
4 changes: 2 additions & 2 deletions nixos/modules/system/boot/systemd.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{ config, lib, pkgs, utils, ... }:

with utils;
with systemdUtils.unitOptions;
with systemdUtils.lib;
with lib;
with import ./systemd-unit-options.nix { inherit config lib; };
with import ./systemd-lib.nix { inherit config lib pkgs; };

let

Expand Down