Giter Site home page Giter Site logo

nome's Introduction

Nome

built with nix

Nome is my Nix home. It encapsulates a range of Nix goodies that I use to declutter and bring order to my entire laptop environment, including:

  • My Home Manager configuration
  • Shell aliases and helper scripts
  • Nix functions and overlays that I can apply to my personal projects

Home Manager configuration

What I run to activate my Home Manager configuration:

nix build "github:the-nix-way/nome#homeConfigurations.lucperkins.activationPackage"
./result/activate

That's right: with Nix installed and flakes enabled, this is all that I need to run to stand up a new machine according to my exact specifications, including configuration for Vim, tmux, zsh, Visual Studio Code, Git, and more. This has enabled me to eliminate Homebrew from my machine.

Creating new development environments

While I use Home Manager to cover my global settings, I strive to provide project-specific settings as much as possible. So I've set up a Nix flake template that drops a flake.nix, flake.lock, and .envrc into the current directory. All I have to do is run proj to initialize that template:

proj

Here's my baseline flake.nix:

{
  description = "Local dev environment";

  inputs = { nome.url = "github:the-nix-way/nome"; };

  outputs = { self, nome, ... }:
    nome.lib.mkEnv {
      # Custom language-specific toolchains that I've assembled
      toolchains = with nome.lib.toolchains; elixir ++ go ++ node ++ protobuf ++ rust;
      # Any additional executables I want loaded into the project
      extras = with nome.pkgs; [ jq ];
      # A custom shell hook to run when the shell is initialized
      shellHook = ''
        echo "Welcome to this Nix-provided project env!"
      '';
    };
}

As you can see, the only input in this flake is nome itself, which provides everything I need for my dev environments. In any given project I'm likely to only use one toolchain, so I remove the ones I don't need. So this series of actions gets me precisely what I need on most of my local projects:

  1. Run proj.
  2. Edit the flake.nix to remove any toolchains I won't need.
  3. Run direnv allow to activate the shell environment.

In cases where this template doesn't provide enough granularity, I create a flake.nix from scratch or use a template from my dev-templates project, which provides Nix flake templates for a wide variety of languages and platforms. Over time, however, I hope to add personal templates that get me ever closer to not needing to hand-craft my Nix logic or use external templates.

An important side effect of building tools to provide project-specific environments is that I've begun to slowly phase out global executables in favor of project-specific ones. Some tools do need to be globally available, such as Git, jq, curl, and wget, but others don't. Tools like Go, cargo, mix (Elixir), and Node.js should all be project specific, and so I've phased them all out of my global environment.

Applying my NixOS configuration

nixos-rebuild switch --flake "github:the-nix-way/nome#lucperkins"

Scope

I should make it clear that this project is a personal project and not necessarily intended as a blueprint or a reproducible template. I do hope that you find some inspiration in it, but don't necessarily interpret what you see here as best practices. It's just an evolving project that I find quite useful and it's meant above all to show what Nix is capable of.

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.