Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add positive source filter #8832

Merged
merged 3 commits into from
Aug 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 50 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,52 @@
})
stdenvs);

# Experimental fileset library: https://github.com/NixOS/nixpkgs/pull/222981
# Not an "idiomatic" flake input because:
# - Propagation to dependent locks: https://github.com/NixOS/nix/issues/7730
# - Subflake would download redundant and huge parent flake
# - No git tree hash support: https://github.com/NixOS/nix/issues/6044
inherit (import (builtins.fetchTarball { url = "https://github.com/NixOS/nixpkgs/archive/1bdcd7fc8a6a40b2e805bad759b36e64e911036b.tar.gz"; sha256 = "sha256:14ljlpdsp4x7h1fkhbmc4bd3vsqnx8zdql4h3037wh09ad6a0893"; }))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is from an unmerged PR is there a risk it would go away?

Could we merge it and back port it? Or is that too much?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the tree to this repo using a merge commit now.

fileset;

baseFiles =
# .gitignore has already been processed, so any changes in it are irrelevant
# at this point. It is not represented verbatim for test purposes because
# that would interfere with repo semantics.
fileset.fileFilter (f: f.name != ".gitignore") ./.;

nixSrc = fileset.toSource {
root = ./.;
fileset = fileset.intersect baseFiles (
fileset.difference
(fileset.unions [
./.version
./boehmgc-coroutine-sp-fallback.diff
./bootstrap.sh
./configure.ac
./doc
./local.mk
./m4
./Makefile
./Makefile.config.in
./misc
./mk
./precompiled-headers.h
./src
./tests
./COPYING
./scripts/local.mk
(fileset.fileFilter (f: lib.strings.hasPrefix "nix-profile" f.name) ./scripts)
# TODO: do we really need README.md? It doesn't seem used in the build.
./README.md
])
(fileset.unions [
# Removed file sets
./tests/nixos
./tests/installer
])
);
};

# Memoize nixpkgs for different platforms for efficiency.
nixpkgsFor = forAllSystems
Expand Down Expand Up @@ -209,7 +255,7 @@
"-${client.version}-against-${daemon.version}";
inherit version;

src = self;
src = nixSrc;

VERSION_SUFFIX = versionSuffix;

Expand Down Expand Up @@ -320,18 +366,11 @@
};
let
canRunInstalled = currentStdenv.buildPlatform.canExecute currentStdenv.hostPlatform;

sourceByRegexInverted = rxs: origSrc: final.lib.cleanSourceWith {
filter = (path: type:
let relPath = final.lib.removePrefix (toString origSrc + "/") (toString path);
in ! lib.any (re: builtins.match re relPath != null) rxs);
src = origSrc;
};
in currentStdenv.mkDerivation (finalAttrs: {
name = "nix-${version}";
inherit version;

src = sourceByRegexInverted [ "tests/nixos/.*" "tests/installer/.*" ] self;
src = nixSrc;
VERSION_SUFFIX = versionSuffix;

outputs = [ "out" "dev" "doc" ];
Expand Down Expand Up @@ -529,7 +568,7 @@
releaseTools.coverageAnalysis {
name = "nix-coverage-${version}";

src = self;
src = nixSrc;

configureFlags = testConfigureFlags;

Expand Down Expand Up @@ -557,7 +596,7 @@
pname = "nix-internal-api-docs";
inherit version;

src = self;
src = nixSrc;

configureFlags = testConfigureFlags ++ internalApiDocsConfigureFlags;

Expand Down