From 8e1f14e82dcd87f484a5024a86e52399b1061416 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Wed, 22 Jul 2020 11:35:14 +0200 Subject: [PATCH] flattenTree: use / as the key separator That character is less likely to be used in normal packaging names. --- README.md | 4 ++-- default.nix | 4 ++-- example/flake.nix | 5 ++++- flattenTree.nix | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 907a73a..75d7a73 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,8 @@ Returns: ```nix { hello = «derivation»; - gitAndTools_git = «derivation»; - gitAndTools_hub = «derivation»; + "gitAndTools/git" = «derivation»; + "gitAndTools/hub" = «derivation»; # ... } ``` diff --git a/default.nix b/default.nix index 978a2ad..d9eeb77 100644 --- a/default.nix +++ b/default.nix @@ -52,8 +52,8 @@ let # # { # hello = «derivation»; - # gitAndTools_git = «derivation»; - # gitAndTools_hub = «derivation»; + # "gitAndTools/git" = «derivation»; + # "gitAndTools/hub" = «derivation»; # # ... # } flattenTree = tree: import ./flattenTree.nix tree; diff --git a/example/flake.nix b/example/flake.nix index a3cc11b..28bd85f 100644 --- a/example/flake.nix +++ b/example/flake.nix @@ -7,7 +7,10 @@ flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; in rec { - packages.hello = pkgs.hello; + packages = flake-utils.lib.flattenTree { + hello = pkgs.hello; + gitAndTools = pkgs.gitAndTools; + }; defaultPackage = packages.hello; apps.hello = flake-utils.lib.mkApp { drv = packages.hello; }; defaultApp = apps.hello; diff --git a/flattenTree.nix b/flattenTree.nix index a535f86..3ad30d0 100644 --- a/flattenTree.nix +++ b/flattenTree.nix @@ -2,7 +2,7 @@ tree: let op = sum: path: val: let - pathStr = builtins.concatStringsSep "_" path; + pathStr = builtins.concatStringsSep "/" path; in if (builtins.typeOf val) != "set" then # ignore that value