Closed nixinator closed 1 year ago
After fixing up the mgmt make scripts , from !/bin/bash to !/usr/bin/env bash
trying to build from
'nix-shell -p go git'
git clone https://github.com/purpleidea/mgmt.git cd mgmt make path make deps
make Building: mgmt, os/arch: linux-amd64, version: 0.0.21-90-g5c6a66e-dirty... go build runtime/cgo: copying /run/user/1000/go-build892927552/b057/pkg.a: open /nix/store/y2nrzzz2yz7k36xvwr7bbfx76cb8jg16-go-1.14.8/share/go/pkg/linux_amd64/runtime/cgo.a: read-only file system
make: *** [Makefile:175: build/mgmt-linux-amd64] Error 1
go env GO111MODULE="" GOARCH="amd64" GOBIN="/home/demo/gopath/bin/" GOCACHE="/home/demo/.cache/go-build" GOENV="/home/demo/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/demo/gopath/" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/nix/store/y2nrzzz2yz7k36xvwr7bbfx76cb8jg16-go-1.14.8/share/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/nix/store/y2nrzzz2yz7k36xvwr7bbfx76cb8jg16-go-1.14.8/share/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/demo/mgmt/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/run/user/1000/go-build275716735=/tmp/go-build -gno-record-gcc-switches"
mgmt now compiles under a shell.nix. I'm going to need a little bit of help to turn this into a nix package, as i'm not too sure how to handle it , as there are buildgopackage, buildgomodule , vgo2nix etc etc . Any pointers welcomed.
to avoid
go build runtime/cgo: copying /run/user/1000/go-cache/a8/a8c43676c0bd05331491ea4b76385e1daa149d053f9a1f55a25589358611653c-d: open /nix/store/y2nrzzz2yz7k36xvwr7bbfx76cb8jg16-go-1.14.8/share/go/pkg/linux_amd64/runtime/cgo.a: read-only file system
make: *** [Makefile:175: build/mgmt-linux-amd64] Error 1
I had to remove the -i from the go build
time env GOOS=${GOOS} GOARCH=${GOARCH} go build -i -ldflags=$(PKGNAME)="-X main.program=$(PROGRAM) -X main.version=$(SVERSION) ${LDFLAGS}" -o $@ $(BUILD_FLAGS); \
this seems to be related to this
NixOS/nixpkgs#52706 golang/go#24674
shell.nix
with import <nixpkgs> {};
pkgs.mkShell rec {
name = "mgmt";
buildInputs = with pkgs; [
go git pkgconfig augeas libvirt libxml2
];
shellHook = ''
mkdir $HOME/gopath
export GOPATH=$HOME/gopath
export GOCACHE=$HOME/go-cache
export CGO_ENABLED=1
[ -z "$GOPATH" ] && mkdir ~/go/ || mkdir -p $GOPATH/src/github.com/purpleidea/
cd $GOPATH/src/github.com/purpleidea/ || cd ~/go/
git clone --recursive https://github.com/purpleidea/mgmt/
cd $GOPATH/src/github.com/purpleidea/mgmt/ || cd ~/go/src/github.com/purpleidea/mgmt/
export PATH=$PATH:$HOME/gopath/bin
for i in misc/*.sh
do
substituteInPlace $i \
--replace "#!/bin/bash" "#!/usr/bin/env bash"
done
#go get golang.org/x/tools/...
go get -v -d ./...
go get github.com/blynn/nex # for lexing
go get golang.org/x/tools/cmd/goyacc # formerly `go tool yacc`
go get golang.org/x/tools/cmd/stringer # for automatic stringer-ing
go get golang.org/x/lint/golint # for `golint`-ing
go get golang.org/x/tools/cmd/goimports # for fmt
go get github.com/tmthrgd/go-bindata/go-bindata # for compiling in non golang files
go get github.com/dvyukov/go-fuzz/go-fuzz # for fuzzing the mcl lang bits
TMPDIR=/tmp
make
'';
}
to run
./mgmt version
NAME:
mgmt - next generation config management
USAGE:
mgmt [global options] command [command options] [arguments...]
VERSION:
0.0.21-98-g76ede10-dirty
COMMANDS:
run, r run
deploy, d deploy
get, g get
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--license prints the software license (default: false)
--help, -h show help (default: false)
--version, -v print the version (default: false)
I marked this as stale due to inactivity. → More info
Project description mgmt: next generation config management!
Metadata