Getting very simple functions first.
This commit is contained in:
parent
9a5044959f
commit
219dd073ff
4 changed files with 20 additions and 8 deletions
|
|
@ -1 +0,0 @@
|
|||
locations: builtins.attrNames locations
|
||||
9
lib/functions/location.nix
Normal file
9
lib/functions/location.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{ data, lib }:
|
||||
|
||||
let
|
||||
mkLocationsList = locations: builtins.attrNames locations;
|
||||
mkLocationIndex = data: location: lib.lists.findFirstIndex (x: x == location) null (mkLocationsList data);
|
||||
in
|
||||
{
|
||||
inherit mkLocationsList mkLocationIndex;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
let
|
||||
buildLocationList = import ../lib/functions/buildLocationList.nix;
|
||||
sampleData = import ./meta.nix;
|
||||
in
|
||||
{
|
||||
result = buildLocationList sampleData.locations;
|
||||
}
|
||||
11
test/test-location.nix
Normal file
11
test/test-location.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
let
|
||||
nixpkgs = import <nixpkgs> { };
|
||||
sampleData = import ./meta.nix;
|
||||
locationLib = import ../lib/functions/location.nix {
|
||||
data = sampleData;
|
||||
lib = nixpkgs.lib;
|
||||
};
|
||||
in
|
||||
{
|
||||
result = locationLib.mkLocationIndex sampleData.locations "home";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue