Skip to content

Instantly share code, notes, and snippets.

@LnL7

LnL7/aaa.sh Secret

Last active December 28, 2019 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LnL7/a85365a952b4cc582c1bb68875704d37 to your computer and use it in GitHub Desktop.
Save LnL7/a85365a952b4cc582c1bb68875704d37 to your computer and use it in GitHub Desktop.
$ nix-build foo.nix -A hello
/nix/store/xmlhf8g9hgjycwwh7ac4i44ayc3wa9zg-hello
$ nix-build foo.nix -A menosandbox
these derivations will be built:
/nix/store/g95122z1j2i9hh24irapybc4pmz36fsa-evil.drv
building '/nix/store/g95122z1j2i9hh24irapybc4pmz36fsa-evil.drv'...
chmod: changing permissions of '/nix/store/xmlhf8g9hgjycwwh7ac4i44ayc3wa9zg-hello/bin/hello': Operation not permitted
builder for '/nix/store/g95122z1j2i9hh24irapybc4pmz36fsa-evil.drv' failed with exit code 1
$ /nix/store/xmlhf8g9hgjycwwh7ac4i44ayc3wa9zg-hello/bin/hello
with import <nixpkgs> {};
rec {
hello = runCommand "hello" {} ''
mkdir -p $out/bin
cat <<-EOF > $out/bin/hello
#!/usr/bin/env bash
echo "Hello World!"
EOF
chmod +x $out/bin/hello
'';
menosandbox = runCommand "evil" { inherit hello; } ''
chmod -x $hello/bin/hello
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment