about summary refs log tree commit diff
path: root/modules/nix/default.nix
blob: 9df65c72b3c91006a75ddfa6d5325232df0e9934 (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
{ config, pkgs, options, lib, ... }:

let
  # Most of the standard Darwin-detection methods cause infinite recursion.
  isDarwin = options.environment ? "darwinConfig";

in {
  nix.nixPath = [
    "nixos-config=/run/current-system/nixlib/sys/${config.networking.hostName}.nix"
    "/run/current-system/nixlib"
  ];

  nix.settings.auto-optimise-store = true;
  nix.daemonCPUSchedPolicy = "idle";
  nix.settings.trusted-users = [ "@wheel" ];

  system.extraSystemBuilderCmds = ''
    ln -s ${lib.cleanSource ../..} $out/nixlib
  '';

  nixpkgs.overlays =
    let
      inherit (builtins) attrNames readDir;
      dir = ../../overlays;
      names = attrNames (readDir dir);
    in
      map (o: import "${dir}/${o}") names;

  services = lib.optionalAttrs isDarwin
    { nix-daemon.enable = true; };

  systemd.tmpfiles.rules = [
    "d ${config.users.users.qyliss.home}/state/nix 0700 qyliss qyliss"
  ];

}