From 36a2b1aeace22517b396d9ff502fa532d173cac0 Mon Sep 17 00:00:00 2001 From: Ethel Morgan Date: Wed, 1 Jul 2020 15:48:24 +0100 Subject: move overlays module to a general nix one --- nixos/modules/module-list.nix | 2 +- nixos/modules/nix.nix | 54 +++++++++++++++++++++++++++++++++++++++++++ nixos/modules/overlays.nix | 22 ------------------ 3 files changed, 55 insertions(+), 23 deletions(-) create mode 100644 nixos/modules/nix.nix delete mode 100644 nixos/modules/overlays.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 001f376..b0d788c 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -2,7 +2,7 @@ ./hardware/keyboard.nix ./hardware/linode.nix ./hardware/yubikey.nix - ./overlays.nix + ./nix.nix ./programs/dwm.nix ./services/ambience.nix ./services/catbus-lgtv.nix 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 [] ) + ]; + }; +} diff --git a/nixos/modules/overlays.nix b/nixos/modules/overlays.nix deleted file mode 100644 index 7820e96..0000000 --- a/nixos/modules/overlays.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ config, lib, pkgs, ... }: -with lib; - -let - cfg = config.eth.overlays; - - mozilla = import (builtins.fetchTarball - "https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz"); - - eth = import ../../pkgs; - -in { - options.eth.overlays = { - eth = mkEnableOption "Eth (yours truly)"; - mozilla = mkEnableOption "Mozilla (Rust, Firefox, etc)"; - }; - - config.nixpkgs.overlays = builtins.concatLists [ - ( if cfg.eth then [ eth ] else [] ) - ( if cfg.mozilla then [ mozilla ] else [] ) - ]; -} -- cgit v1.2.3