From a0901fecde5a12b267739a546ef307cce6d607a8 Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Mon, 21 Feb 2022 13:38:22 +0000 Subject: [PATCH] home-manager: Add nix.conf --- home-manager/configs/castle.nix | 1 + home-manager/configs/macsimum.nix | 1 + home-manager/modules/common.nix | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/home-manager/configs/castle.nix b/home-manager/configs/castle.nix index 8116299..7a19f45 100644 --- a/home-manager/configs/castle.nix +++ b/home-manager/configs/castle.nix @@ -15,6 +15,7 @@ hostname = "h.nul.ie"; sshOpts = [ "-4" "-p" "8022" ]; }; + nix.config.cores = "16"; }; programs = { diff --git a/home-manager/configs/macsimum.nix b/home-manager/configs/macsimum.nix index 350df10..3bca8e8 100644 --- a/home-manager/configs/macsimum.nix +++ b/home-manager/configs/macsimum.nix @@ -9,6 +9,7 @@ { my = { deploy.enable = false; + nix.config.cores = "6"; }; programs = { diff --git a/home-manager/modules/common.nix b/home-manager/modules/common.nix index fa80f6f..8d62b33 100644 --- a/home-manager/modules/common.nix +++ b/home-manager/modules/common.nix @@ -3,7 +3,7 @@ let inherit (builtins) listToAttrs mapAttrs readFile; inherit (lib) optionalString nameValuePair concatMapStrings concatStringsSep optionalAttrs versionAtLeast - mkMerge mkIf mkDefault mkOption; + mapAttrsToList mkMerge mkIf mkDefault mkOption; inherit (lib.hm) dag; inherit (lib.my) mkOpt' dummyOption; in @@ -19,6 +19,11 @@ in shell = mkOpt' str null "User's shell (so NixOS or others can set it externally)."; fishCompletionsFrequency = mkOpt' (nullOr str) "daily" "How often to generate fish completions from manpages."; + nix = { + # TODO: Until https://github.com/nix-community/home-manager/issues/2324 + config = mkOpt' (attrsOf str) { } "nix.conf options"; + }; + ssh = { authKeys = { literal = mkOpt' (listOf singleLineStr) [ ] "List of OpenSSH keys to allow"; @@ -47,6 +52,11 @@ in isStandalone = !(args ? osConfig); shell = mkDefault "${config.programs.fish.package}/bin/fish"; + + nix.config = { + experimental-features = mkDefault "nix-command flakes ca-derivations"; + max-jobs = mkDefault "auto"; + }; }; home.file.".ssh/authorized_keys" = with config.my.ssh.authKeys; @@ -57,6 +67,10 @@ in ''; }; + xdg.configFile."nix/nix.conf" = mkIf (config.my.nix.config != { }) { + text = (concatStringsSep "\n" (mapAttrsToList (k: v: "${k} = ${v}") config.my.nix.config)) + "\n"; + }; + programs = { # Even when enabled this will only be actually installed in standalone mode # Note: `home-manager.path` is for telling home-manager is installed and setting it in NIX_PATH, which we should