Created
September 10, 2017 19:55
-
-
Save infinisil/7b0879ae420147805815ec6eb0b5dc14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
pkgs = import <nixpkgs> {}; | |
lib = pkgs.lib; | |
valToPath = name: value: if builtins.isAttrs value then '' | |
mkdir "${name}" && pushd "${name}" | |
${lib.concatMapStringsSep "\n" (attrName: valToPath attrName value.${attrName}) (builtins.attrNames value)} | |
popd | |
'' else '' | |
echo "${toString value}" > "${name}" | |
''; | |
attrToDerivation = name: attrs: pkgs.runCommand name {} (valToPath "$out" attrs); | |
in | |
attrToDerivation "example" { | |
foo = "Hello"; | |
bar = { | |
baz = "There"; | |
qux = ":D"; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment