summary refs log tree commit diff
path: root/pkgs/default.nix
blob: 13ac8437601bda7d40f9550f59cbbfda589efbb2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is>
# SPDX-License-Identifier: MIT

{ ... } @ args:

let
  config = import ../lib/config.nix args;
  pkgs = import ./overlaid.nix ({ elaboratedConfig = config; } // args);

  inherit (pkgs.lib)
    cleanSource cleanSourceWith hasSuffix makeScope optionalAttrs;

  scope = self: let pkgs = self.callPackage ({ pkgs }: pkgs) {}; in {
    inherit config;

    callSpectrumPackage =
      path: (import path { inherit (self) callPackage; }).override;

    lseek = self.callSpectrumPackage ../tools/lseek {};
    rootfs = self.callSpectrumPackage ../host/rootfs {};
    start-vm = self.callSpectrumPackage ../host/start-vm {};

    # Packages from the overlay, so it's possible to build them from
    # the CLI easily.
    inherit (pkgs) cloud-hypervisor foot;

    pkgsStatic = makeScope pkgs.pkgsStatic.newScope scope;

    src = cleanSourceWith {
      filter = path: type:
        path != toString ../Documentation/_site &&
        path != toString ../Documentation/.jekyll-cache &&
        path != toString ../Documentation/diagrams/stack.svg &&
        (type == "regular" -> !hasSuffix ".nix" path) &&
        (type == "directory" -> builtins.baseNameOf path != "build");
      src = cleanSource ../.;
    };
  };
in

pkgs.makeScopeWithSplicing' {
  otherSplices = {
    selfBuildBuild = makeScope pkgs.pkgsBuildBuild.newScope scope;
    selfBuildHost = makeScope pkgs.pkgsBuildHost.newScope scope;
    selfBuildTarget = makeScope pkgs.pkgsBuildTarget.newScope scope;
    selfHostHost = makeScope pkgs.pkgsHostHost.newScope scope;
    selfTargetTarget = optionalAttrs (pkgs.pkgsTargetTarget ? newScope)
      (makeScope pkgs.pkgsTargetTarget.newScope scope);
  };
  f = scope;
}