Skip to content

Instantly share code, notes, and snippets.

@dasJ
Created April 18, 2021 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dasJ/f55d106229d0a78196d664fca12837dd to your computer and use it in GitHub Desktop.
Save dasJ/f55d106229d0a78196d664fca12837dd to your computer and use it in GitHub Desktop.
{ config, lib, pkgs, modulesPath, ... }: let
systemdLib = import "${modulesPath}/system/boot/systemd-lib.nix" { inherit config lib pkgs; };
# Apply a list of overrideAttrs functions to a drv
applyOverrides = drv: overrides: lib.foldl' (drv': override: lib.extendDerivation true (override drv') drv') drv overrides;
in {
options.systemd.units = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule ({ name, config, ... }: {
options = {
overrides = lib.mkOption {
description = "Overrides to apply to the unit file derivation";
# TOREM 21.05
#type = lib.types.listOf (lib.types.functionTo lib.types.attrs);
type = lib.types.listOf lib.types.unspecified;
default = [];
example = [ (oA: {
patches = (oA.patches or []) ++ [ "$somepatch" ];
}) ];
};
};
config = {
unit = applyOverrides (systemdLib.makeUnit name config) config.overrides;
};
}));
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment