From 5f41fd8b8b7cc2db152d4c353ce7da4c75e2dcf2 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sun, 1 May 2022 13:35:46 -0700 Subject: build: slowly moving to nix Add a `flake.nix' configuration to pull the required dependencies and run the server. Remove a few targets from the Makefile and move the deployment part to a script. --- users/fcuny/blog/.envrc | 1 + users/fcuny/blog/Makefile | 17 +---------------- users/fcuny/blog/flake.lock | 26 ++++++++++++++++++++++++++ users/fcuny/blog/flake.nix | 19 +++++++++++++++++++ users/fcuny/blog/scripts/deploy.sh | 10 ++++++++++ 5 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 users/fcuny/blog/.envrc create mode 100644 users/fcuny/blog/flake.lock create mode 100644 users/fcuny/blog/flake.nix create mode 100755 users/fcuny/blog/scripts/deploy.sh (limited to 'users/fcuny') diff --git a/users/fcuny/blog/.envrc b/users/fcuny/blog/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/users/fcuny/blog/.envrc @@ -0,0 +1 @@ +use flake diff --git a/users/fcuny/blog/Makefile b/users/fcuny/blog/Makefile index 5414dde..e2731d4 100644 --- a/users/fcuny/blog/Makefile +++ b/users/fcuny/blog/Makefile @@ -5,22 +5,7 @@ DOCKER_IMAGE_REF := $(shell git rev-parse HEAD) DOCKERFILE := Dockerfile PROJECT_DIR := $(realpath $(CURDIR)) -.PHONY: server deploy docker-build docker-run worktree-clean - -server: - @echo "Running hugo server ..." - hugo server - -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 | "fcuny.net/v\(.Version)"') $$(flyctl info -j |jq -r '.App | "fcuny.net/v\(.Version)"') - @git push origin --all - @git push origin --tags +.PHONY: docker-build docker-run docker-build: @echo "Building Docker image ..." diff --git a/users/fcuny/blog/flake.lock b/users/fcuny/blog/flake.lock new file mode 100644 index 0000000..d7426e1 --- /dev/null +++ b/users/fcuny/blog/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1651345462, + "narHash": "sha256-4wf9sMUKGBjC2jWnUwG52ychtXRKlS3LfX/HEY6DjhM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "870249df2cc640e2278cd0bc599ebbb246b00802", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/users/fcuny/blog/flake.nix b/users/fcuny/blog/flake.nix new file mode 100644 index 0000000..59ef578 --- /dev/null +++ b/users/fcuny/blog/flake.nix @@ -0,0 +1,19 @@ +{ + description = "Franck Cuny's personal website."; + + inputs = { nixpkgs.url = "github:nixos/nixpkgs"; }; + + outputs = { self, nixpkgs }: + let pkgs = nixpkgs.legacyPackages.x86_64-linux; + in { + defaultApp.x86_64-linux = self.apps.server; + apps.server = pkgs.writers.writeBashBin "server" '' + set -e + set -o pipefail + PATH=${pkgs.lib.makeBinPath [ pkgs.hugo pkgs.git ]} + hugo server + ''; + devShell.x86_64-linux = + pkgs.mkShell { buildInputs = with pkgs; [ hugo flyctl git ]; }; + }; +} diff --git a/users/fcuny/blog/scripts/deploy.sh b/users/fcuny/blog/scripts/deploy.sh new file mode 100755 index 0000000..82919c6 --- /dev/null +++ b/users/fcuny/blog/scripts/deploy.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +git diff --exit-code +git diff --staged --exit-code + +VERSION=$(flyctl info -j |jq -r '.App | "fcuny.net/v\(.Version)"') + +git tag -a --message ${VERSION} ${VERSION} +git push origin --all +git push origin --tags -- cgit 1.4.1