summaryrefslogtreecommitdiffstats
path: root/nixpkgs/nixos/default.nix
blob: 6c5adf36591c719b0e3cc436bb6ebeae513ae966 (plain)
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
61
62
63
64
65
{ configuration ? import <upstream-nixpkgs/nixos/lib/from-env.nix> "NIXOS_CONFIG" <nixos-config>
, system ? builtins.currentSystem
}:

let
  eval-config = modules: import <upstream-nixpkgs/nixos/lib/eval-config.nix> {
    inherit system;
    modules = modules ++ [({ config, lib, ... }: with lib; {
      imports = filter dir.has-default-nix (concatLists [
        (map (p: p + "/2configs") [ <stockholm-private> ])
        (map (p: p + "/3modules") [ <stockholm-krebs> <stockholm-private> ])
      ]);

      krebs.current = {
        enable = true;
        host = config.krebs.hosts.${readFile /proc/sys/kernel/hostname};
        user = config.krebs.users.${getEnv "LOGNAME"};
      };

      nixpkgs.config.packageOverrides = pkgs: let
        kpkgs = import <stockholm-krebs/5pkgs> { inherit lib pkgs; };
        upkgs = import <stockholm-private/5pkgs> { inherit lib; pkgs = pkgs // kpkgs; };
      in kpkgs // upkgs;
    })];
    specialArgs = {
      lib = let
        nlib = import <upstream-nixpkgs/lib> // builtins;
        klib = nlib // import <stockholm-krebs/4lib> { lib = nlib; };
        ulib = klib // (with klib; let p = <stockholm-private> + "/4lib"; in
          optionalAttrs (dir.has-default-nix p)
                        (import p { lib = klib; }));
      in ulib;
    };
  };

  eval = eval-config [
    configuration
  ];

  # This is for `nixos-rebuild build-vm'.
  vm = eval-config [
    configuration
    <upstream-nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
  ];

  # This is for `nixos-rebuild build-vm-with-bootloader'.
  vm-with-bootloader = eval-config [
    configuration
    <upstream-nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
    { virtualisation.useBootLoader = true; }
  ];
in

{
  inherit (eval) config options;

  system = eval.config.system.build.toplevel;

  vm = vm.config.system.build.vm;

  vmWithBootLoader = vm-with-bootloader.config.system.build.vm;

  # The following are used by nixos-rebuild.
  nixFallback = eval.pkgs.nixUnstable;
}