Skip to content

Instantly share code, notes, and snippets.

@dmjio

dmjio/foo.nix Secret

Created January 21, 2021 18:37
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 dmjio/9db44c1b21175bbd2482fdcab785c96b to your computer and use it in GitHub Desktop.
Save dmjio/9db44c1b21175bbd2482fdcab785c96b to your computer and use it in GitHub Desktop.
{ pkgs ? import <nixpkgs> { config.allowUnfree = true; } }:
let
src = pkgs.writeTextFile {
name = "Main.hs";
text = ''module Main where
main = print =<< readFile "/opt/cisco/anyconnect/lol.txt"
'';
};
lol = pkgs.writeTextFile { name = "lol.txt"; text = "loooooool\n"; };
app = pkgs.stdenv.mkDerivation {
name = "anyconnect";
inherit src;
buildInputs = with pkgs; [ ghc makeWrapper ];
buildCommand = ''
mkdir -p $out/bin
cp -v ${lol} $out
ghc $src -o $out/bin/foo
wrapProgram $out/bin/foo \
--set LD_PRELOAD "${pkgs.libredirect}/lib/libredirect.so" \
--set NIX_REDIRECTS /opt/cisco/anyconnect=$out
'';
};
test = pkgs.writeScriptBin "runner" ''
${pkgs.strace}/bin/strace ${app}/bin/foo
${app}/bin/foo
'';
in
test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment