blob: eb2f41c496977b8d9b8e6ab38578cf1accd11913 (
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
|
{ config, pkgs, options, lib, ... }:
let
# Most of the standard Darwin-detection methods cause infinite recursion.
isDarwin = options.environment ? "darwinConfig";
# Copy entire nixlib tree to the store.
root =
let
# Just needed for runCommand and git.
bootstrapPkgs = import ../.. {};
# Remove .git before adding to the store, because it's likely to
# be large. Ideally, we would also remove files in .gitignore
# here too, but that would require either a builtin for running a
# shell command, or a gitignore parser written in Nix (eww).
workingTree = builtins.filterSource (path: type: baseNameOf path != ".git") ../..;
in
# Now, use a derivation to delete any gitignored files. Then, we
# can use the resulting Nix store path as root tree.
toString (bootstrapPkgs.runCommand "nixlib-root" {} ''
cp -R ${workingTree} "$out"
chmod -R u+w "$out"
${bootstrapPkgs.git}/bin/git init "$out"
${bootstrapPkgs.git}/bin/git -C "$out" clean -fX
rm -rf "$out/.git"
'');
in {
nix.nixPath = [
"nixos-config=${root}/sys/${config.networking.hostName}.nix"
root
];
nixpkgs.overlays =
let
inherit (builtins) attrNames readDir;
dir = ../../nixpkgs-overlays;
names = attrNames (readDir dir);
in
map (o: import "${root}/nixpkgs-overlays/${o}") names;
services = lib.optionalAttrs isDarwin
{ nix-daemon.enable = true; };
nix.package = pkgs.nixUnstable;
nix.daemonNiceLevel = 2;
}
|