Skip to content

no simplistic development example via shell.nix and direnv #3

@matu3ba

Description

@matu3ba

Your examples assume that the user wants to build everything with flakes etc, but the user might also just want to reuse upstream as environment and use relative paths.

Reasoning:

    1. found no simple way to reference via relative path other flakes etc on system.
    1. shell.nix + direnv is the most simple way to get a reproducible dev setup
    1. flakes and other methods copy things to global nix store and user might not want copies of files lying around

Paths:

~/dev/zdev/zig/
~/dev/zdev/zig-bootstrap/
~/dev/zdev/shell.nix
~/dev/zdev/.envrc
~/dev/zi/shell.nix
~/dev/zi/.envrc

~/dev/zdev/shell.nix

{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/01441e14af5e29c9d27ace398e6dd0b293e25a54.tar.gz") {} }:
pkgs.stdenvNoCC.mkDerivation {
  name = "shell";
  nativeBuildInputs = with pkgs; [
      cmake
      gdb
      libxml2
      ninja
      python3
      qemu
      valgrind
      wasmtime
  ] ++ (with llvmPackages_16; [
    clang
    clang-unwrapped
    lld
    llvm
  ]);
}

~/dev/zi/shell.nix with shellHook example:

{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/01441e14af5e29c9d27ace398e6dd0b293e25a54.tar.gz") {} }:
pkgs.stdenvNoCC.mkDerivation {
  name = "shell";
  nativeBuildInputs = with pkgs; [
      gdb
      qemu
      valgrind
      wasmtime
  ];
  PROJECT_ROOT = builtins.toString ./.;
  shellHook = ''
    PATH=$PATH:$PROJECT_ROOT/../zdev/zig/master/rel/bin/
  '';
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions