flake.nix: Use a Nixpkgs scope for components

This commit is contained in:
Robert Hensing 2024-06-26 02:38:07 +02:00
parent a92f3071bb
commit a14faa869d
2 changed files with 96 additions and 87 deletions

View file

@ -172,93 +172,16 @@
};
});
# TODO: define everything here instead of top level?
nix-components = {
inherit (final)
nix-util
nix-util-test-support
nix-util-test
nix-util-c
nix-store
nix-fetchers
nix-perl-bindings
;
};
# A new scope, so that we can use `callPackage` to inject our own interdependencies
# without "polluting" the top level "`pkgs`" attrset.
# This also has the benefit of providing us with a distinct set of packages
# we can iterate over.
nixComponents = lib.makeScope final.newScope (import ./packaging/components.nix {
pkgs = final;
inherit stdenv versionSuffix officialRelease;
});
nix-util = final.callPackage ./src/libutil/package.nix {
inherit
fileset
stdenv
officialRelease
versionSuffix
;
};
nix-util-test-support = final.callPackage ./tests/unit/libutil-support/package.nix {
inherit
fileset
stdenv
versionSuffix
;
};
nix-util-test = final.callPackage ./tests/unit/libutil/package.nix {
inherit
fileset
stdenv
versionSuffix
;
};
nix-util-c = final.callPackage ./src/libutil-c/package.nix {
inherit
fileset
stdenv
versionSuffix
;
};
nix-store = final.callPackage ./src/libstore/package.nix {
inherit
fileset
stdenv
officialRelease
versionSuffix
;
libseccomp = final.libseccomp-nix;
busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell;
};
nix-fetchers = final.callPackage ./src/libfetchers/package.nix {
inherit
fileset
stdenv
officialRelease
versionSuffix
;
};
nix =
final.callPackage ./package.nix {
inherit
fileset
stdenv
officialRelease
versionSuffix
;
boehmgc = final.boehmgc-nix;
libgit2 = final.libgit2-nix;
libseccomp = final.libseccomp-nix;
busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell;
};
nix-perl-bindings = final.callPackage ./src/perl/package.nix {
inherit
fileset
stdenv
versionSuffix
;
};
nix = final.nixComponents.nix;
nix-internal-api-docs = final.callPackage ./src/internal-api-docs/package.nix {
inherit
@ -340,7 +263,7 @@
"static-" = nixpkgsFor.${system}.static;
})
(nixpkgsPrefix: nixpkgs:
flatMapAttrs nixpkgs.nix-components
flatMapAttrs nixpkgs.nixComponents
(pkgName: pkg:
flatMapAttrs pkg.tests or {}
(testName: test: {

86
packaging/components.nix Normal file
View file

@ -0,0 +1,86 @@
{pkgs, stdenv, officialRelease, versionSuffix}: scope:
let
inherit (scope) callPackage;
# TODO: push fileset parameter into package.nix files as `lib` parameter
inherit (callPackage (args@{ lib }: args) {}) lib;
inherit (lib) fileset;
in
# This becomes the pkgs.nixComponents attribute set
{
# TODO: build the nix CLI with meson
nix = pkgs.callPackage ../package.nix {
inherit
fileset
stdenv
officialRelease
versionSuffix
;
boehmgc = pkgs.boehmgc-nix;
libgit2 = pkgs.libgit2-nix;
libseccomp = pkgs.libseccomp-nix;
busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox-shell;
};
nix-util = callPackage ../src/libutil/package.nix {
inherit
fileset
stdenv
officialRelease
versionSuffix
;
};
nix-util-test-support = callPackage ../tests/unit/libutil-support/package.nix {
inherit
fileset
stdenv
versionSuffix
;
};
nix-util-test = callPackage ../tests/unit/libutil/package.nix {
inherit
fileset
stdenv
versionSuffix
;
};
nix-util-c = callPackage ../src/libutil-c/package.nix {
inherit
fileset
stdenv
versionSuffix
;
};
nix-store = callPackage ../src/libstore/package.nix {
inherit
fileset
stdenv
officialRelease
versionSuffix
;
libseccomp = pkgs.libseccomp-nix;
busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox-shell;
};
nix-fetchers = callPackage ../src/libfetchers/package.nix {
inherit
fileset
stdenv
officialRelease
versionSuffix
;
};
nix-perl-bindings = callPackage ../src/perl/package.nix {
inherit
fileset
stdenv
versionSuffix
;
};
}