Created
January 16, 2019 15:48
-
-
Save madjar/2836e0727b9ff1a1103c98a906ad5b8c to your computer and use it in GitHub Desktop.
Lazy binaries, that install the underlying command on invocation (the missing part is a gc root)
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
with import <nixpkgs> {}; | |
let | |
mkLazyBin = { pkg, bin }: | |
writeTextFile { | |
name = bin; | |
executable = true; | |
text = '' | |
#!/bin/sh | |
[[ -d ${builtins.unsafeDiscardStringContext (pkg.outPath)} ]] || nix build --no-link ${builtins.unsafeDiscardStringContext (pkg.drvPath)} | |
${builtins.unsafeDiscardStringContext (pkg.outPath)}/bin/${bin} | |
''; | |
}; | |
in mkLazyBin { | |
pkg = hello; | |
bin = "hello"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment