From 4bbc7b8f75409aa8e99a0f3284bdc5f11f804cfb Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 25 Jan 2024 12:21:13 -0500 Subject: [PATCH] Use the Nixpkgs `fileset` library to filter source Now I can change Nix files without causing rebuilds. --- flake.nix | 5 +++-- package.nix | 26 +++++++++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 0ab25018..71fd6c6d 100644 --- a/flake.nix +++ b/flake.nix @@ -10,7 +10,7 @@ # 23.11 and has `lib.fileset`. inputs.nixpkgs-for-fileset.url = "github:NixOS/nixpkgs/nixos-23.11"; - outputs = { self, nixpkgs, nix }: + outputs = { self, nixpkgs, nix, nixpkgs-for-fileset }: let systems = [ "x86_64-linux" "aarch64-linux" ]; forEachSystem = nixpkgs.lib.genAttrs systems; @@ -65,7 +65,8 @@ }; hydra = final.callPackage ./package.nix { - src = self; + inherit (nixpkgs-for-fileset.lib) fileset; + rawSrc = self; }; }; diff --git a/package.nix b/package.nix index f91e7a24..eff9ed37 100644 --- a/package.nix +++ b/package.nix @@ -1,7 +1,8 @@ { stdenv , lib +, fileset -, src +, rawSrc , buildEnv @@ -128,13 +129,28 @@ let ]; }; - version = "${builtins.readFile ./version.txt}.${builtins.substring 0 8 (src.lastModifiedDate or "19700101")}.${src.shortRev or "DIRTY"}"; + version = "${builtins.readFile ./version.txt}.${builtins.substring 0 8 (rawSrc.lastModifiedDate or "19700101")}.${rawSrc.shortRev or "DIRTY"}"; in -stdenv.mkDerivation { +stdenv.mkDerivation (finalAttrs: { pname = "hydra"; inherit version; - inherit src; + src = fileset.toSource { + root = ./.; + fileset = fileset.unions ([ + ./version.txt + ./configure.ac + ./Makefile.am + ./src + ./doc + ./hydra-module.nix + # TODO only when `doCheck` + ./t + ] ++ lib.optionals finalAttrs.doCheck [ + ./.perlcriticrc + ./.yath.rc + ]); + }; strictDeps = true; @@ -251,4 +267,4 @@ stdenv.mkDerivation { meta.description = "Build of Hydra on ${stdenv.system}"; passthru = { inherit perlDeps nix; }; -} +})