From f88ff7682941fae91a969b76177c61e7b575c61c Mon Sep 17 00:00:00 2001 From: Yuval Kogman Date: Thu, 25 May 2023 22:27:41 +0300 Subject: [PATCH] [WIP] C/C++ development environment Package list may have redundancies or even inconsistencies, I don't really know what I'm doing. This does seem to work for code browsing (LSP support with ccls works with doom emacs), and building / debugging a few projects I tried... --- c-cpp/.envrc | 1 + c-cpp/flake.lock | 43 ++++++++++++++++++++++++++++++++++++++ c-cpp/flake.nix | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 5 +++++ 4 files changed, 103 insertions(+) create mode 100644 c-cpp/.envrc create mode 100644 c-cpp/flake.lock create mode 100644 c-cpp/flake.nix diff --git a/c-cpp/.envrc b/c-cpp/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/c-cpp/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/c-cpp/flake.lock b/c-cpp/flake.lock new file mode 100644 index 0000000..ecac920 --- /dev/null +++ b/c-cpp/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1678901627, + "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1679163677, + "narHash": "sha256-VC0tc3EjJZFPXgucFQAYMIHce5nJWYR0kVCk4TVg6gg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c3912035d00ef755ab19394488b41feab95d2e40", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/c-cpp/flake.nix b/c-cpp/flake.nix new file mode 100644 index 0000000..460caac --- /dev/null +++ b/c-cpp/flake.nix @@ -0,0 +1,54 @@ +{ + description = "A Nix-flake-based C/C++ development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/release-22.11"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { self + , nixpkgs + , flake-utils + }: + + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShells.default = pkgs.mkShell { + packages = with pkgs; [ + # FIXME split into 3 different profiles? + stdenv + clangStdenv + gccStdenv + + clang + llvmPackages_latest.bintools # lld https://matklad.github.io/2022/03/14/rpath-or-why-lld-doesnt-work-on-nixos.html + + lldb + gdb + + valgrind + + # FIXME is this necessary? shouldn't be in stdenv? + binutils + coreutils + util-linux + + pkg-config + libtool + + automake autoconf + cmake cmake-language-server + ninja + + unzip # needed for doom emacs gdb support + + ccls + #sourcekit-lsp + ]; + }; + }); +} diff --git a/flake.nix b/flake.nix index 51cd3b9..4f6227f 100644 --- a/flake.nix +++ b/flake.nix @@ -10,6 +10,11 @@ outputs = { self, flake-utils, nixpkgs }: { templates = rec { + c-cpp = { + path = ./c-cpp; + description = "C/CPP development environment based on nixpkg's stdenv"; + }; + clojure = { path = ./clojure; description = "Clojure development environment";