Last active
August 5, 2023 16:40
-
-
Save danidiaz/744606d4daa496982421c28b9b8f5594 to your computer and use it in GitHub Desktop.
ifd
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
# https://nixos.wiki/wiki/Import_From_Derivation | |
# https://discourse.nixos.org/t/how-to-import-a-derivation-with-import/15375 | |
# https://nixos.org/manual/nix/stable/language/builtins#builtins-import | |
# https://nixos.org/manual/nix/stable/language/values.html#type-string | |
let | |
pkgs = import <nixpkgs> {}; | |
derivation-to-import = pkgs.writeText "inner" "5"; | |
imported-nix-value = import derivation-to-import; | |
in pkgs.writeText "foo" '' | |
The value from the inner derivation was: ${toString imported-nix-value} | |
'' |
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
# https://nixos.wiki/wiki/Import_From_Derivation | |
# https://discourse.nixos.org/t/how-to-import-a-derivation-with-import/15375 | |
# https://nixos.org/manual/nix/stable/language/builtins#builtins-import | |
# https://nixos.org/manual/nix/stable/language/values.html#type-string | |
let | |
pkgs = import <nixpkgs> {}; | |
derivation-to-import = pkgs.writeText "inner" '' | |
pkgs : | |
pkgs.runCommand "imported" {} | |
''' | |
sleep 6 | |
# This is the out of the imported derivation, | |
# not of the outer derivation | |
# https://releases.nixos.org/nix-dev/2015-December/019018.html | |
echo 5 > ''$out | |
''' | |
''; | |
imported-nix-value = import derivation-to-import pkgs; | |
in pkgs.writeText "outer" '' | |
The value from the inner derivation was: ${imported-nix-value} | |
'' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment