2009-09-28 20:26:13 +02:00
|
|
|
{pkgs, options, config, ...}:
|
|
|
|
|
|
|
|
let
|
2009-09-29 17:21:36 +02:00
|
|
|
|
|
|
|
alias = from: to: {
|
|
|
|
name = "Alias";
|
|
|
|
msg.use = x: x;
|
|
|
|
msg.define = x: x;
|
|
|
|
};
|
|
|
|
|
|
|
|
obsolete = from: to: {
|
|
|
|
name = "Obsolete name";
|
|
|
|
msg.use = x:
|
2010-05-07 17:14:50 +02:00
|
|
|
builtins.trace "Obsolete option `${from}' is used instead of `${to}'." x;
|
2009-09-29 17:21:36 +02:00
|
|
|
msg.define = x:
|
2010-05-07 17:14:50 +02:00
|
|
|
builtins.trace "Obsolete option `${from}' is defined instead of `${to}'." x;
|
2009-09-29 17:21:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
deprecated = from: to: {
|
|
|
|
name = "Deprecated name";
|
|
|
|
msg.use = x:
|
2010-05-07 17:14:50 +02:00
|
|
|
abort "Deprecated option `${from}' is used instead of `${to}'.";
|
2009-09-29 17:21:36 +02:00
|
|
|
msg.define = x:
|
2010-05-07 17:14:50 +02:00
|
|
|
abort "Deprecated option `${from}' is defined instead of `${to}'.";
|
2009-09-29 17:21:36 +02:00
|
|
|
};
|
|
|
|
|
2009-09-28 20:26:13 +02:00
|
|
|
|
|
|
|
zipModules = list: with pkgs.lib;
|
|
|
|
zip (n: v:
|
2010-10-14 20:18:38 +02:00
|
|
|
if tail v != [] then
|
|
|
|
if n == "_type" then builtins.trace "Merge _type" (head v)
|
|
|
|
else if n == "extraConfigs" then builtins.trace "Merge extraConfigs" (concatLists v)
|
|
|
|
else if n == "description" || n == "apply" then
|
|
|
|
abort "Cannot rename an option to multiple options."
|
|
|
|
else zipModules v
|
|
|
|
else head v
|
2009-09-28 20:26:13 +02:00
|
|
|
) list;
|
|
|
|
|
2010-10-14 15:57:15 +02:00
|
|
|
rename = statusTemplate: from: to: with pkgs.lib;
|
2009-09-28 20:26:13 +02:00
|
|
|
let
|
2009-09-29 17:21:36 +02:00
|
|
|
status = statusTemplate from to;
|
2009-09-28 20:26:13 +02:00
|
|
|
setTo = setAttrByPath (splitString "." to);
|
|
|
|
setFrom = setAttrByPath (splitString "." from);
|
2009-09-29 15:44:07 +02:00
|
|
|
toOf = attrByPath (splitString "." to)
|
2010-05-07 17:14:50 +02:00
|
|
|
(abort "Renaming error: option `${to}' does not exists.");
|
2009-09-29 15:44:07 +02:00
|
|
|
fromOf = attrByPath (splitString "." from)
|
2010-05-07 17:14:50 +02:00
|
|
|
(abort "Internal error: option `${from}' should be declared.");
|
2009-09-28 20:26:13 +02:00
|
|
|
in
|
|
|
|
[{
|
|
|
|
options = setFrom (mkOption {
|
2009-09-29 17:21:36 +02:00
|
|
|
description = "${status.name} of <option>${to}</option>.";
|
|
|
|
apply = x: status.msg.use (toOf config);
|
2009-09-28 20:26:13 +02:00
|
|
|
});
|
|
|
|
}] ++
|
|
|
|
[{
|
|
|
|
options = setTo (mkOption {
|
2009-09-29 17:21:36 +02:00
|
|
|
extraConfigs =
|
|
|
|
let externalDefs = (fromOf options).definitions; in
|
|
|
|
if externalDefs == [] then []
|
|
|
|
else map (def: def.value) (status.msg.define externalDefs);
|
2009-09-28 20:26:13 +02:00
|
|
|
});
|
|
|
|
}];
|
|
|
|
|
|
|
|
in zipModules ([]
|
|
|
|
|
|
|
|
# usage example:
|
2010-10-14 15:57:15 +02:00
|
|
|
# ++ rename alias "services.xserver.slim.theme" "services.xserver.displayManager.slim.theme"
|
|
|
|
++ rename obsolete "environment.extraPackages" "environment.systemPackages"
|
2009-09-28 20:26:13 +02:00
|
|
|
|
2009-09-29 11:50:38 +02:00
|
|
|
# Old Grub-related options.
|
2010-10-14 15:57:15 +02:00
|
|
|
++ rename obsolete "boot.copyKernels" "boot.loader.grub.copyKernels"
|
|
|
|
++ rename obsolete "boot.extraGrubEntries" "boot.loader.grub.extraEntries"
|
|
|
|
++ rename obsolete "boot.extraGrubEntriesBeforeNixos" "boot.loader.grub.extraEntriesBeforeNixOS"
|
|
|
|
++ rename obsolete "boot.grubDevice" "boot.loader.grub.device"
|
|
|
|
++ rename obsolete "boot.bootMount" "boot.loader.grub.bootDevice"
|
|
|
|
++ rename obsolete "boot.grubSplashImage" "boot.loader.grub.splashImage"
|
2009-09-28 20:26:13 +02:00
|
|
|
|
2010-10-14 15:57:15 +02:00
|
|
|
++ rename obsolete "boot.initrd.extraKernelModules" "boot.initrd.kernelModules"
|
2009-12-15 15:05:01 +01:00
|
|
|
|
2010-03-11 18:02:49 +01:00
|
|
|
# OpenSSH
|
2010-10-14 15:57:15 +02:00
|
|
|
++ rename obsolete "services.sshd.ports" "services.openssh.ports"
|
|
|
|
++ rename obsolete "services.sshd.enable" "services.openssh.enable"
|
|
|
|
++ rename obsolete "services.sshd.allowSFTP" "services.openssh.allowSFTP"
|
|
|
|
++ rename obsolete "services.sshd.forwardX11" "services.openssh.forwardX11"
|
|
|
|
++ rename obsolete "services.sshd.gatewayPorts" "services.openssh.gatewayPorts"
|
|
|
|
++ rename obsolete "services.sshd.permitRootLogin" "services.openssh.permitRootLogin"
|
|
|
|
++ rename obsolete "services.xserver.startSSHAgent" "services.xserver.startOpenSSHAgent"
|
2009-11-22 01:40:53 +01:00
|
|
|
|
2009-10-12 19:09:38 +02:00
|
|
|
# KDE
|
2010-10-14 15:57:15 +02:00
|
|
|
++ rename deprecated "kde.extraPackages" "environment.kdePackages"
|
2010-10-14 16:57:38 +02:00
|
|
|
# ++ rename obsolete "environment.kdePackages" "environment.systemPackages" # !!! doesn't work!
|
2009-10-06 21:25:25 +02:00
|
|
|
|
2009-09-28 20:26:13 +02:00
|
|
|
) # do not add renaming after this.
|