From 97185faedaf8efbff15e2b06eecf02e40292348c Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Wed, 11 May 2022 18:17:35 -0700 Subject: add a flake.nix to the repository --- tools/govanity/flake.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tools/govanity/flake.nix (limited to 'tools/govanity/flake.nix') diff --git a/tools/govanity/flake.nix b/tools/govanity/flake.nix new file mode 100644 index 0000000..15b13d0 --- /dev/null +++ b/tools/govanity/flake.nix @@ -0,0 +1,27 @@ +{ + description = "govanity"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/release-21.11"; + utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, utils, nixpkgs, pre-commit-hooks }: + utils.lib.eachDefaultSystem (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in { + + defaultPackage = self.packages.${system}.vanity; + + packages.vanity = pkgs.buildGoModule { + pname = "vanity"; + version = "0.0.1"; + src = ./.; + vendorSha256 = "sha256-iu2QE+vvenFWpOOz1NHVQHudiWkvkKqZvD4ZX4Xa1sY="; + nativeBuildInputs = with pkgs; [ go ]; + }; + + devShell = with pkgs; + mkShell { nativeBuildInputs = [ git go gopls golangci-lint bash ]; }; + }); +} -- cgit 1.4.1 From ec02496f673820244fabb3fadc903d1315218497 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Wed, 11 May 2022 18:45:05 -0700 Subject: scripts: add a script to deploy Remove the target from the Makefile, add a target to the flake configuration. --- tools/govanity/Makefile | 7 +------ tools/govanity/flake.nix | 10 ++++++++++ tools/govanity/scripts/deploy.sh | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) create mode 100755 tools/govanity/scripts/deploy.sh (limited to 'tools/govanity/flake.nix') diff --git a/tools/govanity/Makefile b/tools/govanity/Makefile index 9632386..6392551 100644 --- a/tools/govanity/Makefile +++ b/tools/govanity/Makefile @@ -5,7 +5,7 @@ DOCKER_IMAGE_REF := $(shell git rev-parse HEAD) DOCKERFILE := Dockerfile PROJECT_DIR := $(realpath $(CURDIR)) -.PHONY: deploy docker-build docker-run worktree-clean server +.PHONY: docker-build docker-run worktree-clean server server: @echo "Running server ..." @@ -15,11 +15,6 @@ worktree-clean: git diff --exit-code git diff --staged --exit-code -deploy: worktree-clean docker-build - @echo "Deploying to fly ..." - flyctl deploy - git tag -a --message $$(flyctl info -j |jq -r '.App | "\(.Name)/v\(.Version)"') $$(flyctl info -j |jq -r '.App | "\(.Name)/v\(.Version)"') - docker-build: @echo "Building Docker image ..." $(DOCKER) build $(DOCKER_BUILD_ARGS) \ diff --git a/tools/govanity/flake.nix b/tools/govanity/flake.nix index 15b13d0..d2c2254 100644 --- a/tools/govanity/flake.nix +++ b/tools/govanity/flake.nix @@ -21,6 +21,16 @@ nativeBuildInputs = with pkgs; [ go ]; }; + apps = { + deploy = pkgs.pkgs.writeShellScriptBin "run-deploy" '' + set -euxo pipefail + export PATH=${ + pkgs.lib.makeBinPath [ pkgs.go pkgs.git pkgs.jq pkgs.flyctl ] + }:$PATH + bash ./scripts/deploy.sh + ''; + }; + devShell = with pkgs; mkShell { nativeBuildInputs = [ git go gopls golangci-lint bash ]; }; }); diff --git a/tools/govanity/scripts/deploy.sh b/tools/govanity/scripts/deploy.sh new file mode 100755 index 0000000..4f46b68 --- /dev/null +++ b/tools/govanity/scripts/deploy.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +git diff --exit-code +git diff --staged --exit-code + +flyctl deploy + +VERSION=$(flyctl info -j |jq -r '.App | "\(.Name)/v\(.Version)"') + +git tag -a --message ${VERSION} ${VERSION} +git push origin --all +git push origin --tags + +flyctl agent stop -- cgit 1.4.1