mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 13:57:10 +03:00
Add a renaming module. This module introduce the rename function to
fetch definitions of oldest options and to add them inside the new option. Properties are still valid and will not be affected by the renaming. e.g: with: rename alias "foo.bar" to "baz.quz" and with the following module: { foo.bar = (mkOverride 10 {}) 42; baz.quz = 21; } the result of baz.quz would be 42 because the priority is still working after the renaming. svn path=/nixos/trunk/; revision=17484
This commit is contained in:
parent
bd41c01bfe
commit
7568587e88
@ -27,6 +27,7 @@
|
|||||||
./programs/pwdutils/pwdutils.nix
|
./programs/pwdutils/pwdutils.nix
|
||||||
./programs/ssh.nix
|
./programs/ssh.nix
|
||||||
./programs/ssmtp.nix
|
./programs/ssmtp.nix
|
||||||
|
./rename.nix
|
||||||
./security/consolekit.nix
|
./security/consolekit.nix
|
||||||
./security/pam.nix
|
./security/pam.nix
|
||||||
./security/policykit.nix
|
./security/policykit.nix
|
||||||
|
41
modules/rename.nix
Normal file
41
modules/rename.nix
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{pkgs, options, config, ...}:
|
||||||
|
|
||||||
|
|
||||||
|
let
|
||||||
|
to = throw "This is just a dummy keyword";
|
||||||
|
alias = { name = "Alias"; };
|
||||||
|
obsolete = { name = "Obsolete name"; };
|
||||||
|
|
||||||
|
zipModules = list: with pkgs.lib;
|
||||||
|
zip (n: v:
|
||||||
|
if tail v != [] then zipModules v else head v
|
||||||
|
) list;
|
||||||
|
|
||||||
|
rename = fromStatus: from: keyword: to: with pkgs.lib;
|
||||||
|
let
|
||||||
|
setTo = setAttrByPath (splitString "." to);
|
||||||
|
setFrom = setAttrByPath (splitString "." from);
|
||||||
|
toOf = attrByPath (splitString "." to) (abort "bad renaming");
|
||||||
|
fromOf = attrByPath (splitString "." from) (abort "IE: renaming error");
|
||||||
|
in
|
||||||
|
[{
|
||||||
|
options = setFrom (mkOption {
|
||||||
|
description = "${fromStatus.name} of <option>${to}</option>.";
|
||||||
|
apply = x: toOf config;
|
||||||
|
});
|
||||||
|
}] ++
|
||||||
|
[{
|
||||||
|
options = setTo (mkOption {
|
||||||
|
extraConfigs = map (def: def.value) (fromOf options).definitions;
|
||||||
|
});
|
||||||
|
}];
|
||||||
|
|
||||||
|
in zipModules ([]
|
||||||
|
|
||||||
|
# usage example:
|
||||||
|
# ++ rename alias "services.xserver.slim.theme" to "services.xserver.displayManager.slim.theme"
|
||||||
|
# ++ rename obsolete "environment.extraPackages" to "environment.systemPackages"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
) # do not add renaming after this.
|
Loading…
Reference in New Issue
Block a user