-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-shell
More file actions
executable file
·20 lines (15 loc) · 845 Bytes
/
dev-shell
File metadata and controls
executable file
·20 lines (15 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#! /bin/sh -eu
# Executes nix-shell with side-effect of adding nix-shell dependencies to gc-root
# (to prevent dependencies from being garbage-collected on next gc run)
#
# Usage:
# ./dev-shell
# ./dev-shell --command 'nixform apply'
# ./dev-shell --command 'srghma_gitlab_runner_ssh -t "journalctl --catalog --pager-end --follow"'
mkdir -p .gcroots
# add shell as gc-root in /nix/var/nix/gcroots/auto
nix-instantiate shell.nix --indirect --add-root $PWD/.gcroots/shell.drv
# add shell dependencies as gc-root in /nix/var/nix/gcroots/auto
# NOTE: one can use keep-outputs=true in /etc/nix/nix.conf and omit this step (https://github.com/NixOS/nix/issues/2208)
nix-store --indirect --add-root $PWD/.gcroots/shell.dep --realise $(nix-store --query --references $PWD/.gcroots/shell.drv)
exec nix-shell $(readlink $PWD/.gcroots/shell.drv) "$@"