about summary refs log tree commit diff
path: root/shells
diff options
context:
space:
mode:
Diffstat (limited to 'shells')
-rw-r--r--shells/README27
-rw-r--r--shells/c.nix18
-rw-r--r--shells/go.nix11
-rw-r--r--shells/linux.nix23
-rw-r--r--shells/rust.nix17
5 files changed, 96 insertions, 0 deletions
diff --git a/shells/README b/shells/README
new file mode 100644
index 000000000000..388ce777448e
--- /dev/null
+++ b/shells/README
@@ -0,0 +1,27 @@
+                               ========
+                               <shells>
+                               ========
+
+This is a collection of Nix expressions for use with nix-shell.
+
+The idea is that if I'm working on a bunch of Rust programs, I don't
+want to have to copy or write a shell.nix with all the standard Rust
+stuff for every program -- rustc, cargo, rust-analyzer, etc.
+
+So instead of doing that, I have a "shells" directory in my NIX_PATH,
+containing a "rust.nix" file.  When I just want to build some program
+as a one off, I'll just do this:
+
+    nix-shell rust.nix
+
+And if it's something I'm going to be working on long term, and I want
+to use lorri and stuff, I can create a shell.nix that just contains
+
+    import <shells/rust.nix>
+
+I could even extend it with project-specific dependencies like
+pkg-config or OpenSSL.
+
+Either way, I can now just modify rust.nix to add things to all my
+Rust environments at once, and store these environments with all my
+other Nix configuration.  Yay!
diff --git a/shells/c.nix b/shells/c.nix
new file mode 100644
index 000000000000..cbcc9db39643
--- /dev/null
+++ b/shells/c.nix
@@ -0,0 +1,18 @@
+{ pkgs ? import ../. {} }:
+with pkgs;
+
+stdenv.mkDerivation {
+  name = "c-shell";
+  buildInputs = [
+    autoconf automake bc bear bison bmake llvmPackages_latest.clang clang-tools
+    cmake flex gettext libtool meson ninja pkg-config
+  ];
+
+  NIX_CFLAGS_COMPILE = "-g3 -O0";
+
+  hardeningDisable = [ "fortify" ];
+
+  buildCommand = ''
+    printf "%s\n" ''${buildInputsArray[*]} > $out
+  '';
+}
diff --git a/shells/go.nix b/shells/go.nix
new file mode 100644
index 000000000000..b88d29772e26
--- /dev/null
+++ b/shells/go.nix
@@ -0,0 +1,11 @@
+{ pkgs ? import ../. {} }:
+with pkgs;
+
+stdenv.mkDerivation {
+  name = "go-shell";
+  buildInputs = [ go goimports gopls ];
+
+  buildCommand = ''
+    printf "%s\n" ''${buildInputsArray[*]} > $out
+  '';
+}
diff --git a/shells/linux.nix b/shells/linux.nix
new file mode 100644
index 000000000000..6b5857d7cc3e
--- /dev/null
+++ b/shells/linux.nix
@@ -0,0 +1,23 @@
+{ pkgs ? import ../. {} } @ args:
+with pkgs;
+
+(import ./c.nix args).overrideAttrs ({ buildInputs ? [], ... }: {
+  name = "linux-shell";
+
+  NIX_CFLAGS_COMPILE = null;
+
+  buildInputs = buildInputs ++ [
+    elfutils openssl
+
+    # For make {n,menu}config
+    ncurses
+
+    # For gcc plugins
+    gmp libmpc mpfr
+
+    # For documentation
+    asciidoc docbook-xsl-nons docbook_xml_dtd_45 graphviz imagemagick
+    python3Packages.sphinx python3Packages.sphinx_rtd_theme sourceHighlight
+    texlive.combined.scheme-minimal xmlto
+  ];
+})
diff --git a/shells/rust.nix b/shells/rust.nix
new file mode 100644
index 000000000000..74eafd4f3aaa
--- /dev/null
+++ b/shells/rust.nix
@@ -0,0 +1,17 @@
+{ pkgs ? import ../. {} }:
+with pkgs;
+
+stdenv.mkDerivation {
+  name = "rust-shell";
+  buildInputs = [
+    cargo cargo-deny cargo-edit clang clippy llvm pkg-config rust-analyzer rustc
+    rustfmt
+  ];
+
+  buildCommand = ''
+    printf "%s\n" $buildInputs > $out
+  '';
+
+  # For bindgen
+  LIBCLANG_PATH = "${llvmPackages.libclang}/lib";
+}