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.confInstall flake into profile:
nix profile install github:svend/user-env-nix#userEnvUpdate to the latest version of the flake.
nix profile upgrade --refresh --verbose '.*\.userEnv'https://nixos.org/manual/nixos/stable/#sect-nixos-systemd-nixos
On NixOS, refresh user systemd unit files.
systemctl --user daemon-reloadNixOS 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 --failedCheck for broken unit files.
find ~/.config/systemd/user -xtype l
``` shell
# rm -rf ~/.config/systemd/user
find ~/.config/systemd/user -xtype l | xargs rm
mkdir -p ~/.config/systemd/user/timers.target.wants
ln -s ~/.nix-profile/etc/xdg/systemd/user/mbsync.timer ~/.config/systemd/user/timers.target.wants/
mkdir -p ~/.config/systemd/user/mbsync.service.wants
ln -s .nix-profile/etc/xdg/systemd/user/commit-mail@.service ~/.config/systemd/user/mbsync.service.wants/
systemctl --user daemon-reload
systemctl --user --failedUpdate lock file.
nix flake updateUpdate a single input:
nix flake metadata
nix flake lock --update-input nixpkgs-unstableRunning 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/emacsnix 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