summary refs log tree commit diff stats
path: root/system/modules/configuration/nix.nix
diff options
context:
space:
mode:
Diffstat (limited to 'system/modules/configuration/nix.nix')
-rw-r--r--system/modules/configuration/nix.nix38
1 files changed, 38 insertions, 0 deletions
diff --git a/system/modules/configuration/nix.nix b/system/modules/configuration/nix.nix
new file mode 100644
index 00000000..9aa83435
--- /dev/null
+++ b/system/modules/configuration/nix.nix
@@ -0,0 +1,38 @@
+{ config, pkgs, ... }:
+
+{ nix = {
+    buildCores = 0;
+
+    daemonNiceLevel = 19;
+    daemonIONiceLevel = 7;
+
+    autoOptimiseStore = true;
+    gc = {
+      automatic = true;
+      options = "--delete-older-than 14d";
+    };
+  };
+
+  nixpkgs.config = {
+    packageOverrides = pkgs: {
+      unstable = import <nixos-unstable> {
+        config = config.nixpkgs.config;
+      };
+    };
+  };
+
+  environment.systemPackages = with pkgs; [
+    cachix
+  ];
+
+  system.autoUpgrade = {
+    enable = true;
+    flags = [ "--max-jobs" "1" ];
+  };
+  systemd.services.nixos-upgrade = {
+    script = pkgs.lib.mkForce ''
+      ${pkgs.nix}/bin/nix-channel --update nixos-unstable
+      ${config.system.build.nixos-rebuild}/bin/nixos-rebuild boot --no-build-output --upgrade ${toString config.system.autoUpgrade.flags}
+    '';
+  };
+}