From 51c559b7e0e36119b4b41faeae1bc19bcbedb875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20K=C3=A1n=C4=9B?= Date: Tue, 4 May 2021 10:51:12 +0200 Subject: [PATCH] Filter source in Nix build to prevent spurious rebuilds --- flake.lock | 17 +++++++++++++++++ flake.nix | 6 ++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/flake.lock b/flake.lock index 1f949c7..7daec1d 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "nix-filter": { + "locked": { + "lastModified": 1619956448, + "narHash": "sha256-4OZjkK1vot9vdg+8jj9+hm4c6mSEc9/OJDQzNvLHBKE=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "cf06efe613a06f1505f187712a307c05b3901884", + "type": "github" + }, + "original": { + "owner": "numtide", + "ref": "master", + "repo": "nix-filter", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1618886496, @@ -18,6 +34,7 @@ }, "root": { "inputs": { + "nix-filter": "nix-filter", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index d9031ed..812ff6b 100644 --- a/flake.nix +++ b/flake.nix @@ -1,16 +1,18 @@ { + description = "Tinyquiz – an open source online quiz platform"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + inputs.nix-filter.url = "github:numtide/nix-filter/master"; - outputs = { self, nixpkgs }: + outputs = { self, nixpkgs, nix-filter }: let pkgs = nixpkgs.legacyPackages.x86_64-linux; buildCmd = name: (pkgs.buildGoPackage { pname = "tinyquiz-${name}"; version = "dev"; - src = ./.; + src = with nix-filter.lib; filter { root = ./.; include = [ (inDirectory "cmd") (inDirectory "pkg") (inDirectory "ui") "go.mod" "go.sum" ]; }; goDeps = ./deps.nix; preBuild = "go generate vkane.cz/tinyquiz/..."; checkPhase = "go test -race vkane.cz/tinyquiz/...";