summaryrefslogtreecommitdiff
path: root/nixos/modules/nix.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules/nix.nix')
-rw-r--r--nixos/modules/nix.nix54
1 files changed, 54 insertions, 0 deletions
diff --git a/nixos/modules/nix.nix b/nixos/modules/nix.nix
new file mode 100644
index 0000000..635a96b
--- /dev/null
+++ b/nixos/modules/nix.nix
@@ -0,0 +1,54 @@
+{ config, lib, pkgs, ... }:
+with lib;
+
+let
+ cfg = config.eth.nix;
+
+ mozilla = import (builtins.fetchTarball
+ "https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz");
+
+ eth = import ../../pkgs;
+
+in {
+ options.eth.nix = {
+ allowUnfree = mkOption {
+ type = types.bool;
+ description = "Allow non-free software.";
+ default = false;
+ };
+
+ gc = {
+ enable = mkEnableOption "Enable the garbage collector.";
+ schedule = mkOption {
+ type = types.str;
+ default = config.nix.gc.dates;
+ description = "A systemd.time(7) timespec";
+ };
+ olderThan = mkOption {
+ type = types.str;
+ default = "30d";
+ description = "Garbage-collect NixOS configurations older than this.";
+ };
+ };
+
+ overlays = {
+ eth = mkEnableOption "Eth (yours truly)";
+ mozilla = mkEnableOption "Mozilla (Rust, Firefox, etc)";
+ };
+ };
+
+ config = {
+ nixpkgs.config.allowUnfree = cfg.allowUnfree;
+
+ nix.gc = {
+ automatic = cfg.gc.enable;
+ dates = cfg.gc.schedule;
+ options = "--delete-older-than ${cfg.gc.olderThan}";
+ };
+
+ nixpkgs.overlays = builtins.concatLists [
+ ( if cfg.overlays.eth then [ eth ] else [] )
+ ( if cfg.overlays.mozilla then [ mozilla ] else [] )
+ ];
+ };
+}