Skip to content

Commit

Permalink
nixos/storage/lib: Propagate devspec's config
Browse files Browse the repository at this point in the history
This is handy if we want to look up configuration options for a specific
device specification, so with only the internal representation of a
devspec we can simply say devspec.uuid to get a generated UUID.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
  • Loading branch information
aszlig committed Jan 6, 2017
1 parent 8e861d2 commit 2b00955
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nixos/modules/tasks/storage/lib.nix
Expand Up @@ -89,9 +89,13 @@ let
*/
decodeSpec = spec: let
typeAndName = builtins.match "([a-z]+)\\.([a-zA-Z0-9_-]+)" spec;
in if typeAndName == null then null else {
in if typeAndName == null then null else rec {
type = lib.head typeAndName;
name = lib.last typeAndName;
# The configuration entry for the storage spec. Note that we don't need to
# check whether ${type} and ${name} exist, because they're already checked
# in assertSpec.
config = cfg.${type}.${name};
};

/* Validate the device specification and return true if it's valid or false if
Expand Down

0 comments on commit 2b00955

Please sign in to comment.