Coder Social home page Coder Social logo

dezzw / nix-starters Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jacg/nix-starters

0.0 0.0 0.0 138 KB

Templates for getting started with Nix: home-manager, Rust projects, Python projects, C++ projects, etc.

Nix 5.08% Rust 0.05% Python 0.24% Shell 94.57% Julia 0.06%

nix-starters's Introduction

Test

Use Nix to provide isolated, per-project, declarative definitions of dependencies for projects in various languages

  • Key assumption: the target machine has Nix installed and available to your user.

  • Helpful but not strictly necessary: direnv is installed and enabled in your shell.

Quickly bootstrap development environments in various languages

  • Rust
  • Python
  • Julia [This one is different from the others. See julia/README.md.]
  • C++ [TODO If you need this, just ask. I do have a solution for a cmake-based project, but cleaning it up and publishing it isn't among my top priorities.

Assuming that you are using direnv

  1. Copy <chosen-language>/{shell.nix,.envrc} into the top directory of your project.
  2. cd <your project dir>
  3. The first time you do this, you will see the error message
    direnv: error <your project dir>/.envrc is blocked. Run `direnv allow` to approve its content
  4. Follow the hint: direnv allow
  5. Henceforth the environment will be activated automatically each time you cd into <your project dir> or any of its subdirectories, and deactivated when you cd back out.

Without direnv

  1. You only need shell.nix, not .envrc.
  2. Manually activate the environment with nix-shell <your project dir>/shell.nix. This will drop you into a bash with the environment. Exiting this shell deactivates the environment.

Specifying dependencies

The details will vary to some extent from language to language. Broadly speaking, add dependencies to buildInputs in shell.nix.

Take your toolset with you: home-manager

home-manager allows you to reproduce your arbitrarily complex personal toolset and configuration on a new machine, with minimal effort.

BEWARE the git config has contains my name and email address! So make sure to edit home-manager/gitconfig before deploying.

See home-manager/README.md for details.

Flakes

  • At present flakes are too painful to work with for Nix non-experts (the target audience).
  • I don't have time to maintain two versions.

Consequently, as far as these recipes are concerned, I am ignoring the existence of flakes until they are fully stabilized. But I do intend to migrate these recipes to flakes once they are stable.

Pinning

The nix versions are pinned. To switch to a more recent set of packages, change nixpkgs-commit-id in your chosen shell.nix:

To get a more recent version of nixpkgs, go to https://status.nixos.org/,
which lists the latest commit that passes all the tests for any release.
Unless there is an overriding reason, pick the latest stable NixOS release, at
the time of writing this is nixos-21.05.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.