Skip to content

Commit

Permalink
nix: fix Nix shell (abiosoft#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
abiosoft authored Oct 8, 2022
1 parent c074356 commit 37f1357
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ BIN_NAME := colima
LDFLAGS := $(VERSION_VARIABLES)

.PHONY: all
all: build
all: build

.PHONY: clean
clean:
Expand Down Expand Up @@ -60,6 +60,10 @@ install:
lint: ## Assumes that golangci-lint is installed and in the path. To install: https://golangci-lint.run/usage/install/
golangci-lint --timeout 3m run

.PHONY: print-binary-name
print-binary-name:
@echo $(OUTPUT_DIR)/$(OUTPUT_BIN)

.PHONY: nix-derivation-shell
nix-derivation-shell:
$(eval DERIVATION=$(shell nix-build))
Expand Down
7 changes: 5 additions & 2 deletions colima.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

with pkgs;

buildGo118Module {
buildGoModule {
name = "colima";
pname = "colima";
src = ./.;
nativeBuildInputs = [ installShellFiles makeWrapper git ];
vendorSha256 = "sha256-jDzDwK7qA9lKP8CfkKzfooPDrHuHI4OpiLXmX9vOpOg=";
vendorSha256 = "sha256-tsMQMWEkTE1NhevcqBETGWiboqL6QTepgnIo4B5Y4wQ=";
CGO_ENABLED = 1;

subPackages = [ "cmd/colima" ];

# `nix-build` has .git folder but `nix build` does not, this caters for both cases
preConfigure = ''
Expand Down
13 changes: 12 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ pkgs.mkShell {
];
shellHook = ''
echo Nix Shell with $(go version)
alias colima="$PWD/_output/binaries/colima-Darwin-arm64"
echo
COLIMA_BIN="$PWD/$(make print-binary-name)"
if [ ! -f "$COLIMA_BIN" ]; then
echo "Run 'make' to build Colima."
echo
fi
set -x
set -x
alias colima="$COLIMA_BIN"
set +x
'';
}

0 comments on commit 37f1357

Please sign in to comment.