aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-04-25 15:55:54 -0300
committerEuAndreh <eu@euandre.org>2024-04-25 15:55:54 -0300
commit0b720343053dd0f67faa53698ebe748fbeddc6b3 (patch)
treecd6faedf9acf2c82405483f9f728079a33ea978e
parentetc/sh/rc: export $TD_USE_BUILTIN_HOOKS (diff)
downloaddotfiles-0b720343053dd0f67faa53698ebe748fbeddc6b3.tar.gz
dotfiles-0b720343053dd0f67faa53698ebe748fbeddc6b3.tar.xz
Revert "Remove Nix/NixOS support from configuration and utilities"
This reverts commit 3b2d27457db9ef8911893fa1b843560f1ccab2eb.
-rwxr-xr-xbin/gc21
-rwxr-xr-xbin/reconfigure6
-rwxr-xr-xbin/update9
-rw-r--r--etc/guix/system.scm1
-rw-r--r--etc/sh/rc16
-rwxr-xr-xopt/aux/gen-e-list.sh1
6 files changed, 53 insertions, 1 deletions
diff --git a/bin/gc b/bin/gc
index 8622a7d..4634f8c 100755
--- a/bin/gc
+++ b/bin/gc
@@ -18,6 +18,7 @@ help() {
TYPE what to do GC on (default: all):
- guix
+ - nix
- trash
- tmpdir
- coredump
@@ -93,6 +94,25 @@ gc_guix() {
fi
}
+gc_nix() {
+ if [ ! -e /nix/ ]; then
+ return
+ fi
+
+ PROFILES='
+ /nix/var/nix/profiles/per-user/root/channels
+ /nix/var/nix/profiles/system
+ '
+
+ for p in $PROFILES; do
+ pass show "$(hostname)"/andreh | head -n1 |
+ sudo -iS nix-env --delete-generations old -p "$p"
+ done
+ nix-env --delete-generations old
+ nix-store --gc
+ nix-collect-garbage -d
+}
+
gc_trash() {
yes | trash-empty
}
@@ -122,6 +142,7 @@ gc_docker() {
TYPES='
guix
+nix
trash
tmpdir
docker
diff --git a/bin/reconfigure b/bin/reconfigure
index 2df3ee7..14a8629 100755
--- a/bin/reconfigure
+++ b/bin/reconfigure
@@ -21,6 +21,7 @@ help() {
Switches the system:
- reconfigure the Guix "home" environment;
- Guix "system" if it exists;
+ - NixOS if it exists.
Examples:
@@ -94,6 +95,11 @@ pass show "$(hostname)"/andreh |
head -n1 |
sudo -ES guix system -v3 reconfigure "$XDG_CONFIG_HOME"/guix/system.scm
+if [ -e /etc/nixos/configuration.nix ]; then
+ pass show "$HOSTNAME"/andreh |
+ head -n1 |
+ sudo -S nixos-rebuild switch
+fi
bins > /dev/null
diff --git a/bin/update b/bin/update
index dc8a84f..6e6effc 100755
--- a/bin/update
+++ b/bin/update
@@ -64,6 +64,15 @@ done
shift $((OPTIND - 1))
+HOSTNAME="$(hostname)"
+if [ -e /etc/nixos/configuration.nix ]; then
+ pass show "$HOSTNAME"/andreh |
+ head -n1 |
+ sudo -S nix-channel --update
+else
+ nix-channel --update
+fi
+
guix pull -v3
rfc -u
diff --git a/etc/guix/system.scm b/etc/guix/system.scm
index 9157a16..5fdd436 100644
--- a/etc/guix/system.scm
+++ b/etc/guix/system.scm
@@ -143,6 +143,7 @@ Seiko Epson Color Ink Jet Printers.")
(append
(map (compose list specification->package+output symbol->string)
'(nss-certs
+ nix
cups
ghc
ghc-xmonad-contrib
diff --git a/etc/sh/rc b/etc/sh/rc
index fd6da27..e5fb5e9 100644
--- a/etc/sh/rc
+++ b/etc/sh/rc
@@ -297,6 +297,20 @@ guix_env() {
printf ')'
}
+in_nix_shell() {
+ if [ -z "${IN_NIX_SHELL:-}" ]; then
+ return
+ fi
+
+ printf '\n'
+ color -c blacki '~> '
+ color -c purpleb "$IN_NIX_SHELL "
+ color -c purple 'nix-shell '
+ printf '('
+ color -c blueb "${name:-}"
+ printf ')'
+}
+
in_ssh_session() {
if [ -n "${SSH_CLIENT:-}" ]; then
color -c blackb '\\u'
@@ -323,7 +337,7 @@ vcs_status() {
fi
}
-PS1='`error_marker`'$(timestamp)' '$(path)'`direnv_status``makeflags_status` `shell_status``vcs_status``guix_env`
+PS1='`error_marker`'$(timestamp)' '$(path)'`direnv_status``makeflags_status` `shell_status``vcs_status``guix_env``in_nix_shell`
'$(in_ssh_session)'$ '
export PS1
diff --git a/opt/aux/gen-e-list.sh b/opt/aux/gen-e-list.sh
index d0586f1..7102e27 100755
--- a/opt/aux/gen-e-list.sh
+++ b/opt/aux/gen-e-list.sh
@@ -8,6 +8,7 @@ set -eu
$XDG_CONFIG_HOME/sh/rc
$XDG_CONFIG_HOME/guix/home.scm
$XDG_CONFIG_HOME/guix/system.scm
+ $XDG_CONFIG_HOME/nix/configuration.nix
EOF
find \