Skip to content

Instantly share code, notes, and snippets.

@rsms
Created November 27, 2021 18:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsms/760629442a5b87d7562332bc7e931fa6 to your computer and use it in GitHub Desktop.
Save rsms/760629442a5b87d7562332bc7e931fa6 to your computer and use it in GitHub Desktop.
{
pkgs ? (import <nixpkgs> {}).pkgsMusl
}:
let
inherit (pkgs) lib;
llvmPkgs = pkgs.llvmPackages_13;
stdenv = llvmPkgs.stdenv;
# stdenv = llvmPkgs.libcxxStdenv;
mkShell = pkgs.mkShell.override { inherit stdenv; };
hello_c = pkgs.writeText "hello.c" ''
#include <stdio.h>
int main() { printf("hello\n"); return 0; }
'';
hello_cc = pkgs.writeText "hello.cc" ''
#include <iostream>
int main() { std::cout << "hello\n"; return 0; }
'';
in
mkShell {
name = "playsys";
buildInputs = with pkgs; [
cmake
nano
ninja
python3
x11
git
xorg.libX11
xorg.libXext
xorg.libXinerama
xorg.libXrandr
xorg.libXcursor
xorg.libXi
];
nativeBuildInputs = with pkgs; [
pkg-config
];
shellHook = ''
#PROMPT_COMMAND='if [ $? = 0 ]; then PS1a="\e[42;1m"; else PS1a="\e[41;1m"; fi'
#PS1='$(echo -ne $PS1a);\[\e[0m\] '
export EDITOR=nano
PROMPT_COMMAND='if [ $? = 0 ]; then PS1a="\e[32;1m"; else PS1a="\e[31;1m"; fi'
PS1='$(echo -ne $PS1a)[nix \W]\[\e[0m\] '
alias l='ls --color=auto --group-directories-first -lAhpo'
ln ${hello_c} hello.c
ln ${hello_cc} hello.cc
echo "clang -Wall -std=c17 -O2 -static -o hello_sc hello.c && ./hello_sc"
clang -Wall -std=c17 -O2 -static -o hello_sc hello.c && ./hello_sc
echo "clang -Wall -std=c17 -O2 -o hello_dc hello.c && ./hello_dc"
clang -Wall -std=c17 -O2 -o hello_dc hello.c && ./hello_dc
echo "clang++ -Wall -std=gnu++17 -O2 -static -o hello_scc hello.cc && ./hello_scc"
clang++ -Wall -std=gnu++17 -O2 -static -o hello_scc hello.cc && ./hello_scc
echo "clang++ -Wall -std=gnu++17 -O2 -o hello_dcc hello.cc && ./hello_dcc"
clang++ -Wall -std=gnu++17 -O2 -o hello_dcc hello.cc && ./hello_dcc
'';
}
@rsms
Copy link
Author

rsms commented Nov 27, 2021

nix-shell --pure llvm13-clang-musl.nix

@erikside
Copy link

did:3:kjzl6cwe1jw147ckqaac76pphyonucspv15nhrna3y49rhla9zz86drygs9ai8r

@erikside
Copy link

``did:3:kjzl6cwe1jw147ckqaac76pphyonucspv15nhrna3y49rhla9zz86drygs9ai8r

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment