Skip to content

Reproducible development environment powered by Nix Flakes

Notifications You must be signed in to change notification settings

svend/user-env-nix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nix User Environment Flake

Reproducible development environment powered by Nix Flakes

Initial Setup

Use nix version 2.4 or newer.

See https://nixos.wiki/wiki/Flakes

For NixOS, add the following to /etc/nixos/configuration.nix:

{
  nix = {
    package = pkgs.nixUnstable;
    extraOptions = ''
      experimental-features = nix-command flakes
    '';
  };
}

For non-NixOS systems:

mkdir -p ~/.config/nix
echo 'experimental-features = nix-command flakes' > ~/.config/nix/nix.conf

Installation

Install flake into profile:

nix profile install github:svend/user-env-nix#userEnv

Update to the latest version of the flake.

nix profile upgrade --refresh --verbose '.*\.userEnv'

Systemd

On NixOS, refresh user systemd unit files.

systemctl --user daemon-reload

NixOS adds ~/.nix-profile/etc/xdg/systemd/user to the user unit search path.

systemd-path systemd-search-user-unit | tr : '\n'

Check for failed units.

systemctl --user --failed

To start from scratch:

rm -rf ~/.config/systemd/user
systemctl --user enable --now backup-laptop.timer
systemctl --user enable --now mbsync.timer
systemctl --user add-wants mbsync.service [email protected]
systemctl --user daemon-reload
systemctl --user --failed

Updating

Update lock file.

nix flake update

Update a single input:

nix flake metadata
nix flake lock --update-input nixpkgs-unstable

Development

Running nix build will create result/ which is a link to the build.

To print build logs, run nix build --print-build-logs or nix build -L. (These flags do not show up in --help.)

To run Emacs from the build, run:

EMACSLOADPATH= result/bin/emacs

REPL

NixOS/nix#8059

nix repl --file repl.nix
nix repl --extra-experimental-features repl-flake .#
nix repl (followed by ":lf .")
$ nix repl --file repl.nix
nix-repl> :b outputs.packages.x86_64-linux.gitWithConfig
this derivation produced the following outputs:
  out -> /nix/store/1s5d89anqhq1f6a1bgyagvri4q82918j-gitWithConfig

About

Reproducible development environment powered by Nix Flakes

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published