-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- import -> callPackage - don't use complex filter src function
- Loading branch information
Showing
1 changed file
with
25 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,31 @@ | ||
self: pkgs: rec { | ||
fossbeamer_crates = import ../Cargo.nix { | ||
inherit pkgs; | ||
nixpkgs = pkgs.path; | ||
_: pkgs: { | ||
fossbeamer = (pkgs.callPackage ../Cargo.nix { | ||
defaultCrateOverrides = pkgs.defaultCrateOverrides // { | ||
fossbeamer = prev: { | ||
src = pkgs.lib.fileset.toSource rec { | ||
root = prev.src.origSrc; | ||
fileset = (pkgs.lib.fileset.intersection | ||
(pkgs.lib.fileset.fromSource root) # We build our final fileset from the original src | ||
(pkgs.lib.fileset.fileFilter (f: f.hasExt "rs") root) | ||
); | ||
}; | ||
|
||
defaultCrateOverrides = | ||
let | ||
lib = pkgs.lib; | ||
# Filters the given source, only keeping files related to the build, preventing unnecessary rebuilds. | ||
# Includes src in the root, all other .rs files, as well as Cargo.toml. | ||
# Additional files to be included can be specified in extraFileset. | ||
filterRustCrateSrc = | ||
{ root # The original src | ||
, extraFileset ? null # Additional filesets to include (e.g. test fixtures) | ||
}: | ||
lib.fileset.toSource { | ||
inherit root; | ||
fileset = (lib.fileset.intersection | ||
(lib.fileset.fromSource root) # We build our final fileset from the original src | ||
(lib.fileset.unions ([ | ||
(root + "/src") | ||
(lib.fileset.fileFilter (f: f.hasExt "rs") root) | ||
# We assume that every Rust crate will at a minimum have .rs files and a Cargo.toml | ||
(lib.fileset.fileFilter (f: f.name == "Cargo.toml") root) | ||
] ++ lib.optional (extraFileset != null) extraFileset))); | ||
}; | ||
in | ||
pkgs.defaultCrateOverrides // { | ||
fossbeamer = prev: { | ||
src = filterRustCrateSrc { root = prev.src.origSrc; }; | ||
nativeBuildInputs = [ | ||
pkgs.wrapGAppsHook | ||
]; | ||
|
||
nativeBuildInputs = [ pkgs.wrapGAppsHook ]; | ||
buildInputs = with pkgs; [ | ||
glib-networking | ||
] ++ (with gst_all_1; [ | ||
gstreamer | ||
gst-plugins-base | ||
gst-plugins-good | ||
gst-plugins-bad | ||
gst-libav | ||
]); | ||
}; | ||
buildInputs = with pkgs; [ | ||
glib-networking | ||
] ++ (with gst_all_1; [ | ||
gstreamer | ||
gst-plugins-base | ||
gst-plugins-good | ||
gst-plugins-bad | ||
gst-libav | ||
]); | ||
}; | ||
}; | ||
|
||
fossbeamer = fossbeamer_crates.rootCrate.build.override { | ||
}; | ||
}).rootCrate.build.override { | ||
runTests = true; | ||
}; | ||
} |