Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{
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

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