GithubHelp home page GithubHelp logo

juspay / nix-dev-home Goto Github PK

View Code? Open in Web Editor NEW
111.0 7.0 34.0 143 KB

A `home-manager` template providing useful tools & settings for Nix-based development (macOS & Linux supported)

License: GNU Affero General Public License v3.0

Nix 93.22% Just 6.68% Shell 0.10%
home-manager home-manager-config nix

nix-dev-home's Introduction

project chat

nix-dev-home

A home-manager template providing useful tools & settings for Nix-based development. See home/default.nix to see what's available.

Getting Started

NOTE: These instructions do not apply if you use NixOS.1

  1. Install Nix.
  2. Initialize your home-manager config using this repo as template:
    mkdir ~/nixconfig 
    cd ~/nixconfig
    nix flake init -t github:juspay/nix-dev-home
    nix run .#sd "runner" "$USER" flake.nix
  3. Run nix run2 to activate your configuration.
  4. Restart your terminal.

After steps 1-4, you should expect to see the starship prompt.

Anytime you modify your home configuration in ./home/*.nix, re-run nix run to activate the new configuration.

Demo

A sample demo of the setup process is shown below:

asciicast

Details

The configuration repo has flake.nix file in the current directory and a ./home/default.nix file containing the home-manager configuration that you can review. It also has a justfile, which provides a set of recipes analogous to Make targets to interact with the nix flake.

You can then execute nix develop, to ensure you are in the development shell with just installed, followed by just run to activate this configuration in your $HOME. On most systems you are likely to experience at least one of the issues mentioned below in Troubleshooting. A more complete sequence might be

nix-dev-env setup
> nix develop
(nix:nix-dev-home-env) > rm ~/.bashrc ~/.profile && just run && direnv allow
(nix:nix-dev-home-env) > exit
> bash
runner on 12ca6a64c923 work on  feature/branch via ❄️  impure (nix-dev-home-env) 
⬢ [Docker] ❯ 

If you prefer, you can simply execute nix run, but using just will perform some additional validation and ensure you are able to use the other commands in the justfile.

To browse the capabilities of home-manager (and to see what else can go in your ./home/default.nix -- such as shell aliases), consult home-manager options reference. You can also run man home-configuration.nix in the terminal.

Troubleshooting

error: opening lock file ...

Problem: nix run shows an error like: error: opening lock file '/nix/var/nix/profiles/per-user/utkarsh.pandey1/profile.lock': No such file or directory

Solution: This is an instance of nix-community/home-manager#4611. Run sudo mkdir /nix/var/nix/profiles/per-user/$USER/ && sudo chown $USER /nix/var/nix/profiles/per-user/$USER and try again.

Existing file ... is in the way of ...

Problem: Running nix run (home-manager) complains "Existing file ... is in the way of ..."

Solution: Delete those existing dotfiles (take a backup first), and try again. In home-manager, you can configure your shell directly in Nix (for macOS zsh, this is programs.zsh.envExtra) and may also include your existing dotfile verbatim.

Cannot use cache / cachix

Problem: Cannot use cachix: Running nix run nixpkgs#cachix use nammayatri (for example) does not succeed.

Solution: Add yourself to the trusted-users nix config and restart the nix daemon.

mkdir -p ~/.config/nix
echo "trusted-users = root $USER" >> $HOME/.config/nix/nix.conf
sudo pkill nix-daemon

FAQ

But I use NixOS

You can embed this configuration inside your NixOS configuration, and thus share it with non-NixOS systems (like macOS and Ubuntu). See the "both" template of https://github.com/srid/nixos-flake for an example. If you don't want to share the configuration with macOS (ie., you use only Linux for development), see the "linux" template instead.

/nix/store garbage collection

By default garbage collection is run automatically every week. If your projects use nix-direnv, you don't have to worry about having to download the dependencies again while in a remote area with limited internet access (see prominent features of nix-direnv).

Footnotes

  1. If you use NixOS, you can adapt the NixOS template of nixos-flake by using configuration from this repo.

  2. Executing this step will modify the contents of your $HOME directory. You will be warned before overwriting, but not before creating links to newly created configuration files in the nix store. Since home-manager does not currently provide an integrated and automated feature to eliminate the links it creates, be aware that if you would like to reverse this operation, you will need to curate your home directory manually.

nix-dev-home's People

Contributors

cameronraysmith avatar github-actions[bot] avatar ifcoltransg avatar rsrohitsingh682 avatar sakshatshinde avatar shivaraj-bh avatar srid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nix-dev-home's Issues

should factoring, imports, and directory tree mirror `srid/nixos-config`?

I realize if this is home-manager only and forever it wouldn't matter much, but it might be helpful if the factoring were a bit more in line with srid/nixos-config to support comprehension of the abstraction that arises with multiple systems, beyond home-manager, etc.

An example of this leads to a directory tree like

.
├── .envrc
├── .github
│   └── workflows
├── .gitignore
├── flake.lock
├── flake.nix
├── home
│   ├── default.nix
│   ├── neovim
│   ├── starship.nix
│   └── terminal.nix
└──justfile

but, more importantly, I find the contents of flake.nix, default.nix + terminal.nix (vs home.nix), etc to be more legible.

I'd be happy to submit those changes in reasonable chunks or feel free to consider doing so in future updates since it is essentially just turning the dial slightly further in the direction of srid/nixos-config. No worries if this is undesirable for some reason I haven't accounted for.

Many thanks for nix-dev-home among other things!

nix-command error

On a brand new install, I get the following error:

error: experimental Nix feature 'nix-command' is disabled; use '--extra-experimental-features nix-command' to override

Simplify README

The README needs to be simplified to make the steps perfectly clear and easy to understand.

Images for ref

image

Automated install

Instead of pairing with folks to do manual setup of nix-dev-home on a computer with Nix installed, it'd be great to have an automated script that works like DetSys nix-installer.

It should do:

Stretch:

  • "Use template" via Github API to create the remote repo
  • nix-health
    • Offer to resolve max-jobs/trusted-users automatically (requires Temp Admin Access)

Pin nixpkgs

... so that nix run nipxkgs#.. will always use the same flake input.

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.