summaryrefslogtreecommitdiff
path: root/system-profiles/core.nix
blob: 79c2fe827fe1ef0d560ef896cb87d03f8f0932ad (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
{ flake, flakeInputs, path, hostName, config, lib, pkgs, customUtils, ... }:
let
  profileSet = customUtils.types.attrNameSet flake.nixosModules.systemProfiles;
in {
  imports = with flakeInputs;
    [ sops-nix.nixosModules.sops
      home-manager.nixosModules.home-manager
    ];
  
  options = {
    # See mkSystemProfile in ../flake.nix
    system.profiles = lib.mkOption {
      type = profileSet;
      default = [];
      description = ''
        Set (list without duplicates) of ‘systemProfiles’ enabled for this host
      '';
    };
  };

  config = {
    networking.hostName = hostName;
    system.configurationRevision = lib.mkIf (flake ? rev) flake.rev;

    nixpkgs.pkgs = flake.legacyPackages.${config.nixpkgs.system};

    nix = {
      package = pkgs.nixUnstable;
      useSandbox = true;
      allowedUsers = [ "@wheel" ];
      trustedUsers = [ "root" "@wheel" ];
      extraOptions = ''
        experimental-features = nix-command flakes ca-references
      '';
      nixPath = [
        "nixpkgs=${flakeInputs.nixpkgs.legacyPackages.${config.nixpkgs.system}.path}"
        "nixpkgs-overlays=${flake.overlays-path.${config.nixpkgs.system}}"
      ];
      registry = {
        nixpkgs.flake = flakeInputs.nixpkgs;
        home-manager.flake = flakeInputs.home-manager;
        sops-nix.flake = flakeInputs.sops-nix;
        nixos.flake = flake;
      };
    };

    users.mutableUsers = false;

    # documentation.nixos.includeAllModules = true; # incompatible with home-manager (build fails)

    home-manager.useGlobalPkgs = true; # Otherwise home-manager would only work impurely
  };
}