From fc21e3a1b2255d82afcc45770704920da875cbfc Mon Sep 17 00:00:00 2001 From: Grigory Shipunov Date: Tue, 14 Feb 2023 22:00:22 +0100 Subject: refactor basic tools a bit --- modules/basic-tools/nix.nix | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 modules/basic-tools/nix.nix (limited to 'modules/basic-tools/nix.nix') diff --git a/modules/basic-tools/nix.nix b/modules/basic-tools/nix.nix new file mode 100644 index 0000000..4a481ae --- /dev/null +++ b/modules/basic-tools/nix.nix @@ -0,0 +1,36 @@ +{ lib, pkgs, inputs, ... }: { + + nix = { + extraOptions = '' + experimental-features = nix-command flakes + ''; + }; + + # override default nix shell nixpkgs# behaviour to use current flake lock + nix.registry = + let flakes = lib.filterAttrs (_name: value: value ? outputs) inputs.self.inputs; + in builtins.mapAttrs (_name: v: { flake = v; }) flakes; + + nix.nixPath = lib.mapAttrsToList (name: value: "${name}=${value.outPath}") inputs.self.inputs; + + environment.shellAliases = { + nix-build="${pkgs.nix-output-monitor}/bin/nom-build"; + nix-shell="${pkgs.nix-output-monitor}/bin/nom-shell"; + }; + + programs.zsh.interactiveShellInit = '' + # hacky wrapper for nix, so we can use nom automagically + export _nom_cmd=${pkgs.nix-output-monitor}/bin/nom + function nix { + case $1 in + build|shell|develop) + echo \[SUBSTITUTION\] ''$_nom_cmd ''${@:1} 1>&2 + ''$_nom_cmd ''${@:1} + ;; + *) + ${pkgs.nix}/bin/nix $@ + esac + } + compdef nix=_nix + ''; +} -- cgit v1.3.1