Filter source in Nix build to prevent spurious rebuilds

This commit is contained in:
Vojtěch Káně
2021-05-04 10:51:12 +02:00
parent f1ca80cbae
commit 51c559b7e0
2 changed files with 21 additions and 2 deletions

17
flake.lock generated
View File

@@ -1,5 +1,21 @@
{ {
"nodes": { "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": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1618886496, "lastModified": 1618886496,
@@ -18,6 +34,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"nix-filter": "nix-filter",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
} }

View File

@@ -1,16 +1,18 @@
{ {
description = "Tinyquiz an open source online quiz platform"; description = "Tinyquiz an open source online quiz platform";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; 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 let
pkgs = nixpkgs.legacyPackages.x86_64-linux; pkgs = nixpkgs.legacyPackages.x86_64-linux;
buildCmd = name: buildCmd = name:
(pkgs.buildGoPackage { (pkgs.buildGoPackage {
pname = "tinyquiz-${name}"; pname = "tinyquiz-${name}";
version = "dev"; version = "dev";
src = ./.; src = with nix-filter.lib; filter { root = ./.; include = [ (inDirectory "cmd") (inDirectory "pkg") (inDirectory "ui") "go.mod" "go.sum" ]; };
goDeps = ./deps.nix; goDeps = ./deps.nix;
preBuild = "go generate vkane.cz/tinyquiz/..."; preBuild = "go generate vkane.cz/tinyquiz/...";
checkPhase = "go test -race vkane.cz/tinyquiz/..."; checkPhase = "go test -race vkane.cz/tinyquiz/...";