-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplify and drop features from nix build/shell
Remove a bunch of stuff from the "dev" shell and rely on normal nix builds/shell instead. This does drop some features like automatically updating the vendorSha256, but hopefully the simpler setup means running `go get -u`, `nix-build` and manually ensuring hash consistency feels intuitive
- Loading branch information
Showing
5 changed files
with
22 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Intentionally impure for CI against nixos-unstable | ||
builtins.fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,20 @@ | ||
{ nixpkgs ? builtins.fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz" | ||
{ nixpkgs ? import ./nixpkgs.nix | ||
, pkgs ? import nixpkgs {} | ||
}: | ||
|
||
with pkgs; | ||
let | ||
packagingOut = "./nix-packaging"; | ||
|
||
shellHook = '' | ||
if [[ -f ./result/bin/morph ]]; then | ||
if [[ `${which} morph 2>&1 >/dev/null` ]]; then | ||
export PATH=$PATH:$(pwd)/result/bin | ||
fi | ||
source <(morph --completion-script-bash) | ||
fi | ||
''; | ||
makeEnv = writeScriptBin "make-env" ('' | ||
#!${bashInteractive}/bin/bash | ||
'' + shellHook); | ||
makeDeps = writeShellScriptBin "make-deps" '' | ||
set -e | ||
export GO111MODULE=on | ||
# update the modules if requested | ||
if [ "$1" == "update" ]; then | ||
${go}/bin/go get -u | ||
source="$( nix eval --raw '(with import ${nixpkgs} {}; import ./nix-packaging/source.nix { inherit lib; })' )" | ||
# compute the sha256 of the dependencies | ||
pushd "$source" >/dev/null | ||
export GOPATH="$(mktemp -d)" GOCACHE="$(mktemp -d)" | ||
${go}/bin/go mod download | ||
sha256="$( ${nix}/bin/nix hash-path --base32 "$GOPATH/pkg/mod/cache/download" | tr -d '\n' )" | ||
popd >/dev/null | ||
# replace the sha256 in the default.nix | ||
sed -e "s#vendorSha256.*#vendorSha256 = \"$sha256\";#" -i ${packagingOut}/default.nix | ||
unset GOPATH GOCACHE | ||
fi | ||
# Populate /vendor (for convenience in local dev) | ||
${go}/bin/go mod vendor | ||
unset GO111MODULE | ||
''; | ||
makeBuild = writeShellScriptBin "make-build" '' | ||
set -e | ||
${nix}/bin/nix-build -E 'with import ${nixpkgs} {}; | ||
callPackage ./nix-packaging/default.nix {}' $@ | ||
make-env | ||
morph = pkgs.callPackage ./default.nix {}; | ||
gen-assets = pkgs.writeShellScriptBin "gen-assets" '' | ||
${pkgs.go-bindata}/bin/go-bindata -pkg assets -o assets/assets.go data/ | ||
''; | ||
in | ||
# Change to mkShell once that hits stable! | ||
stdenv.mkDerivation { | ||
name = "morph-build-env"; | ||
|
||
buildInputs = [ | ||
bashInteractive | ||
git | ||
makeEnv | ||
makeDeps | ||
makeBuild | ||
nix | ||
nix-prefetch-git | ||
openssh | ||
]; | ||
pkgs.mkShell { | ||
buildInputs = [ | ||
gen-assets | ||
]; | ||
|
||
inherit shellHook; | ||
} | ||
inputsFrom = [ | ||
morph | ||
]; | ||
} |