Reproducible development environment powered by Nix Flakes
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
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'
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
Update lock file.
nix flake update
Update a single input:
nix flake metadata
nix flake lock --update-input nixpkgs-unstable
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
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