From ec690b93589463b81e2d6c91981d28905ee17eda Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 30 Jun 2024 12:54:51 +0200 Subject: [PATCH] template/package: Use fileset --- template/package/hello/package.nix | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/template/package/hello/package.nix b/template/package/hello/package.nix index cfc64bc..0990a0c 100644 --- a/template/package/hello/package.nix +++ b/template/package/hello/package.nix @@ -1,12 +1,19 @@ { stdenv, lib, runtimeShell }: +let + # Bring fileset functions into scope. + # See https://nixos.org/manual/nixpkgs/stable/index.html#sec-functions-library-fileset + inherit (lib.fileset) toSource unions; +in + # Example package in the style that `mkDerivation`-based packages in Nixpkgs are written. stdenv.mkDerivation (finalAttrs: { name = "hello"; - src = lib.cleanSourceWith { - src = ./.; - filter = path: type: - type == "regular" -> baseNameOf path == "hello.sh"; + src = toSource { + root = ./.; + fileset = unions [ + ./hello.sh + ]; }; buildPhase = '' # Note that Nixpkgs has builder functions for simple packages