summary refs log tree commit diff
path: root/pkgs/default.nix
blob: ed2762dab061ad6c32bf4490215a84607e78a93b (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
52
53
54
55
56
57
58
59
60
# SPDX-FileCopyrightText: 2023-2024 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 fileset makeScope optionalAttrs;

  makeScopeWithSplicing = pkgs: 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;
  };

  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 {};
    run-spectrum-vm = self.callSpectrumPackage ../scripts/run-spectrum-vm.nix {};

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

    pkgsStatic = makeScopeWithSplicing pkgs.pkgsStatic;

    srcWithNix = fileset.difference
      (fileset.fromSource (cleanSource ../.))
      (fileset.unions (map fileset.maybeMissing [
        ../Documentation/.jekyll-cache
        ../Documentation/_site
        ../Documentation/diagrams/stack.svg
        ../host/initramfs/build
        ../host/rootfs/build
        ../img/app/build
        ../release/live/build
        ../vm/sys/net/build
      ]));

    src = fileset.difference
      self.srcWithNix
      (fileset.fileFilter ({ hasExt, ... }: hasExt "nix") ../.);
  };
in

makeScopeWithSplicing pkgs