aboutsummaryrefslogtreecommitdiff
path: root/nixos/default.nix
blob: 7a3d1bf959e9f120680047bb4b00ff966be47d2f (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
66
67
68
69
70
71
72
73
74
75
76
let
  sources = import ./npins;

  mkConfiguration =
    _hostName:
    { channel, module, ... }:
    let
      nixpkgsPath = sources.${channel}.outPath;
    in
    import "${nixpkgsPath}/nixos/lib/eval-config.nix" {
      modules = [ module ];
      specialArgs = {
        inherit sources nixpkgsPath;
        configurationPath = module;
      };
    };

  mkConfigurations =
    selectModule: hostDefs:
    builtins.mapAttrs (
      hostName: hostDef: mkConfiguration hostName (hostDef // { module = selectModule hostDef; })
    ) hostDefs;

  mkSystems = builtins.mapAttrs (_: configuration: configuration.config.system.build.toplevel);
in
rec {
  hostDefs = {
    ev = {
      description = "home server";
      channel = "nixos-small";
      module = ./hosts/ev/private.nix;
      standaloneModule = ./hosts/ev/default.nix;
    };

    hamac = {
      description = "laptop";
      channel = "nixos";
      module = ./hosts/hamac/private.nix;
      standaloneModule = ./hosts/hamac/default.nix;
    };

    tente = {
      description = "VPS";
      channel = "nixos-small";
      module = ./hosts/tente/default.nix;
      standaloneModule = ./hosts/tente/default.nix;
    };
  };

  configurations = mkConfigurations (host: host.module) hostDefs;

  systems = mkSystems configurations;

  standaloneConfigurations = mkConfigurations (host: host.standaloneModule) hostDefs;

  packages = {
    server =
      let
        pkgs = import sources.nixos-small.outPath { };
      in
      pkgs.lib.packagesFromDirectoryRecursive {
        directory = ./profiles/server/pkgs;
        callPackage = pkgs.newScope { inherit sources; };
      };

    workstation =
      let
        pkgs = import sources.nixos.outPath { };
        pkgs-unstable = import sources.nixos-unstable.outPath { };
      in
      pkgs.lib.packagesFromDirectoryRecursive {
        directory = ./profiles/workstation/pkgs;
        callPackage = pkgs.newScope { inherit (pkgs-unstable) pi-coding-agent; };
      };
  };
}