nixos/ccache: do not "with lib;"

This commit is contained in:
Emery Hemingway 2024-02-08 11:39:29 +01:00
parent e7d3db0954
commit d843ec4e3d

View file

@ -1,29 +1,28 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
cfg = config.programs.ccache; cfg = config.programs.ccache;
in { in {
options.programs.ccache = { options.programs.ccache = {
# host configuration # host configuration
enable = mkEnableOption (lib.mdDoc "CCache"); enable = lib.mkEnableOption (lib.mdDoc "CCache");
cacheDir = mkOption { cacheDir = lib.mkOption {
type = types.path; type = lib.types.path;
description = lib.mdDoc "CCache directory"; description = lib.mdDoc "CCache directory";
default = "/var/cache/ccache"; default = "/var/cache/ccache";
}; };
# target configuration # target configuration
packageNames = mkOption { packageNames = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
description = lib.mdDoc "Nix top-level packages to be compiled using CCache"; description = lib.mdDoc "Nix top-level packages to be compiled using CCache";
default = []; default = [];
example = [ "wxGTK32" "ffmpeg" "libav_all" ]; example = [ "wxGTK32" "ffmpeg" "libav_all" ];
}; };
}; };
config = mkMerge [ config = lib.mkMerge [
# host configuration # host configuration
(mkIf cfg.enable { (lib.mkIf cfg.enable {
systemd.tmpfiles.rules = [ "d ${cfg.cacheDir} 0770 root nixbld -" ]; systemd.tmpfiles.rules = [ "d ${cfg.cacheDir} 0770 root nixbld -" ];
# "nix-ccache --show-stats" and "nix-ccache --clear" # "nix-ccache --show-stats" and "nix-ccache --clear"
@ -50,9 +49,9 @@ in {
}) })
# target configuration # target configuration
(mkIf (cfg.packageNames != []) { (lib.mkIf (cfg.packageNames != []) {
nixpkgs.overlays = [ nixpkgs.overlays = [
(self: super: genAttrs cfg.packageNames (pn: super.${pn}.override { stdenv = builtins.trace "with ccache: ${pn}" self.ccacheStdenv; })) (self: super: lib.genAttrs cfg.packageNames (pn: super.${pn}.override { stdenv = builtins.trace "with ccache: ${pn}" self.ccacheStdenv; }))
(self: super: { (self: super: {
ccacheWrapper = super.ccacheWrapper.override { ccacheWrapper = super.ccacheWrapper.override {