From 5a64745fceebcc13ab0d83d1346968e301bd0d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Fri, 24 Jan 2020 14:46:46 +0100 Subject: [PATCH] nix: throw error if 'make nix-purge' is called on NixOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index dc489141be..3acb13784f 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,9 @@ export NIX_IGNORE_SYMLINK_STORE=1 export _NIX_ROOT = /opt/nix endif +# Useful for checking if we are on NixOS +OS_NAME = $(shell grep -oP '^NAME=\K\w(.*)' /etc/os-release) + #---------------- # Nix targets #---------------- @@ -80,7 +83,11 @@ nix-clean: ##@nix Remove all status-react build artifacts from /nix/store nix-purge: SHELL := /bin/sh nix-purge: ##@nix Completely remove the complete Nix setup +ifeq ($(OS_NAME), NixOS) + $(error $(RED)You should not purge Nix files on NixOS!$(RESET)) +else sudo rm -rf $(_NIX_ROOT)/* ~/.nix-profile ~/.nix-defexpr ~/.nix-channels ~/.cache/nix ~/.status .nix-gcroots +endif nix-add-gcroots: export TARGET := default nix-add-gcroots: ##@nix Add Nix GC roots to avoid status-react expressions being garbage collected