From fa3351f0099096419ef72d4fbc71b32c178396bc Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 5 Jan 2019 17:24:38 +0000 Subject: Add config --- modules/nix/default.nix | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 modules/nix/default.nix (limited to 'modules/nix/default.nix') diff --git a/modules/nix/default.nix b/modules/nix/default.nix new file mode 100644 index 000000000000..eb2f41c49697 --- /dev/null +++ b/modules/nix/default.nix @@ -0,0 +1,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; +} -- cgit 1.4.1