mirror of
https://github.com/khuedoan/homelab.git
synced 2025-03-10 12:51:28 +07:00

- Nix is more reproducible (pinned to a specific hash) - Faster rebuild after changing the package list (due to /nix caching in volume) - Users can still use make tools (wrapped in Docker) without installing Nix - Using nix-shell will work if you have nix installed.
33 lines
572 B
Go
33 lines
572 B
Go
package test
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/gruntwork-io/terratest/modules/docker"
|
|
)
|
|
|
|
func TestToolsContainer(t *testing.T) {
|
|
image := "nixos/nix"
|
|
projectRoot, _ := filepath.Abs("../")
|
|
|
|
options := &docker.RunOptions{
|
|
Remove: true,
|
|
Volumes: []string{
|
|
fmt.Sprintf("%s:%s", projectRoot, projectRoot),
|
|
"homelab-tools-cache:/root/.cache",
|
|
"homelab-tools-nix:/nix",
|
|
},
|
|
OtherOptions: []string{
|
|
"--workdir", projectRoot,
|
|
},
|
|
Command: []string{
|
|
"nix-shell",
|
|
"--command", "exit",
|
|
},
|
|
}
|
|
|
|
docker.Run(t, image, options)
|
|
}
|