Skip to content

Commit

Permalink
nix/fossbeamer: cleanup expression
Browse files Browse the repository at this point in the history
- import -> callPackage
- don't use complex filter src function
  • Loading branch information
Kranzes committed Jul 19, 2024
1 parent 4d564c3 commit d4c83db
Showing 1 changed file with 25 additions and 43 deletions.
68 changes: 25 additions & 43 deletions nix/overlay.nix
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;
};
}

0 comments on commit d4c83db

Please sign in to comment.