mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-13 20:30:02 +00:00
Refactor nix.nixPath
to make diff easier to compare with NixOS module
This commit is contained in:
parent
c3bdd6d95f
commit
7648c9befc
1 changed files with 28 additions and 27 deletions
|
@ -88,6 +88,29 @@ let
|
|||
in
|
||||
attrsOf (either confAtom (listOf confAtom));
|
||||
|
||||
# Not in NixOS module
|
||||
nixPathType = mkOptionType {
|
||||
name = "nix path";
|
||||
merge = loc: defs:
|
||||
let
|
||||
values = flatten (map (def:
|
||||
(map (x:
|
||||
if isAttrs x then (mapAttrsToList nameValuePair x)
|
||||
else if isString x then x
|
||||
else throw "The option value `${showOption loc}` in `${def.file}` is not a attset or string.")
|
||||
(if isList def.value then def.value else [def.value]))) defs);
|
||||
|
||||
namedPaths = mapAttrsToList (n: v: "${n}=${(head v).value}")
|
||||
(zipAttrs
|
||||
(map (x: { "${x.name}" = { inherit (x) value; }; })
|
||||
(filter isAttrs values)));
|
||||
|
||||
searchPaths = unique
|
||||
(filter isString values);
|
||||
in
|
||||
namedPaths ++ searchPaths;
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
@ -291,37 +314,15 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
# Definition differs substantially from NixOS module
|
||||
nixPath = mkOption {
|
||||
type = mkOptionType {
|
||||
name = "nix path";
|
||||
merge = loc: defs:
|
||||
let
|
||||
values = flatten (map (def:
|
||||
(map (x:
|
||||
if isAttrs x then (mapAttrsToList nameValuePair x)
|
||||
else if isString x then x
|
||||
else throw "The option value `${showOption loc}` in `${def.file}` is not a attset or string.")
|
||||
(if isList def.value then def.value else [def.value]))) defs);
|
||||
|
||||
namedPaths = mapAttrsToList (n: v: "${n}=${(head v).value}")
|
||||
(zipAttrs
|
||||
(map (x: { "${x.name}" = { inherit (x) value; }; })
|
||||
(filter isAttrs values)));
|
||||
|
||||
searchPaths = unique
|
||||
(filter isString values);
|
||||
in
|
||||
namedPaths ++ searchPaths;
|
||||
};
|
||||
default =
|
||||
[ # Include default path <darwin-config>.
|
||||
type = nixPathType;
|
||||
default = [
|
||||
# Include default path <darwin-config>.
|
||||
{ darwin-config = "${config.environment.darwinConfig}"; }
|
||||
"/nix/var/nix/profiles/per-user/root/channels"
|
||||
"$HOME/.nix-defexpr/channels"
|
||||
];
|
||||
example =
|
||||
[ { trunk = "/src/nixpkgs"; }
|
||||
];
|
||||
description = ''
|
||||
The default Nix expression search path, used by the Nix
|
||||
evaluator to look up paths enclosed in angle brackets
|
||||
|
@ -664,7 +665,7 @@ in
|
|||
];
|
||||
|
||||
# Set up the environment variables for running Nix.
|
||||
environment.variables = cfg.envVars // { NIX_PATH = concatStringsSep ":" cfg.nixPath; };
|
||||
environment.variables = cfg.envVars // { NIX_PATH = cfg.nixPath; };
|
||||
|
||||
# Unreladed to use in NixOS module
|
||||
environment.extraInit = ''
|
||||
|
|
Loading…
Add table
Reference in a new issue