33 lines
968 B
Plaintext
Executable File
33 lines
968 B
Plaintext
Executable File
#! /usr/bin/env nix-shell
|
|
#! nix-shell -p python3 -i python3
|
|
|
|
# let's say you have a C++ project in Nix that you want to work on with CLion so that the Nix dependencies are available
|
|
# put this script in your project directory
|
|
# then, in Settings -> Build, Execution, Deployment -> Toolchains set CMake to this script
|
|
# if you need any extra nix-shell arguments, add them to the invocation at the bottom
|
|
|
|
# Adapted script from https://gist.github.com/chpatrick/61a5d486dd0d806bdf07e1b1ddc85ce5
|
|
|
|
import os
|
|
import sys
|
|
import shlex
|
|
|
|
scriptDir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
args = list(map(shlex.quote, sys.argv[1:]))
|
|
|
|
# Use the cmakeFlags set by Nix - this doesn't work with --build
|
|
if "--build" not in args:
|
|
args.insert(0, "$cmakeFlags")
|
|
args.append("--no-warn-unused-cli")
|
|
|
|
cwd = shlex.quote(os.getcwd())
|
|
cmd = 'cd ' + cwd + ' && cmake ' + ' '.join(args)
|
|
|
|
os.chdir(scriptDir)
|
|
os.execvp("nix-shell", [
|
|
'nix-shell',
|
|
'--pure',
|
|
'--run', cmd
|
|
])
|