nix-unstable-static: ship with complementary user script
This commit is contained in:
parent
bb3cbda9f3
commit
ac55a180db
2 changed files with 36 additions and 0 deletions
|
@ -6,3 +6,11 @@ into /bin.
|
||||||
|
|
||||||
The main use-case is to be able to run nix in the container, but share the
|
The main use-case is to be able to run nix in the container, but share the
|
||||||
`/nix/store` with the host.
|
`/nix/store` with the host.
|
||||||
|
|
||||||
|
## Using the container with the host store
|
||||||
|
|
||||||
|
This folder ships with a complementary script that you can use to run the
|
||||||
|
image as the current user and the host /nix/store.
|
||||||
|
|
||||||
|
Usage: `docker-nix-user.sh [<command> ...<args>]`
|
||||||
|
|
||||||
|
|
28
images/nix-unstable-static/docker-nix-user.sh
Executable file
28
images/nix-unstable-static/docker-nix-user.sh
Executable file
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Run nixpkgs/nix-unstable-static as the current user and the host /nix/store.
|
||||||
|
#
|
||||||
|
# Usage: docker-nix-user.sh [<command> ...<args>]
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
image=nixpkgs/nix-unstable-static
|
||||||
|
|
||||||
|
options=(
|
||||||
|
-ti
|
||||||
|
# Remove the container on exit
|
||||||
|
--rm
|
||||||
|
-e NIX_PATH="nixpkgs=channel:nixos-22.05"
|
||||||
|
# Used by /run_as_user.sh
|
||||||
|
-e user_id="$(id -u)"
|
||||||
|
-e user_name="$(id -nu)"
|
||||||
|
-e group_id="$(id -g)"
|
||||||
|
-e group_name="$(id -ng)"
|
||||||
|
# Use the host store
|
||||||
|
-v /nix:/nix
|
||||||
|
# Mount the code into the container
|
||||||
|
-v "$PWD:/workspace"
|
||||||
|
-w /workspace
|
||||||
|
--entrypoint /run_as_user.sh
|
||||||
|
)
|
||||||
|
exec docker run "${options[@]}" "$image" "$@"
|
Loading…
Add table
Add a link
Reference in a new issue