ccache code reorg
This commit is contained in:
parent
57d08c6c0e
commit
e99c3dafec
71
pkgs/ccache.nix
Normal file
71
pkgs/ccache.nix
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
{ pkgs
|
||||||
|
, pkgs'
|
||||||
|
, lib
|
||||||
|
, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
# there are few direct hits with the linux kernel, so use CCACHE_NODIRECT
|
||||||
|
# (direct hits are file-based, non-direct are preprocessed file-based)
|
||||||
|
ccacheVars = {
|
||||||
|
CCACHE_CPP2 = "yes";
|
||||||
|
CCACHE_COMPRESS = "1";
|
||||||
|
CCACHE_UMASK = "007";
|
||||||
|
CCACHE_DIR = "/var/cache/ccache";
|
||||||
|
CCACHE_SLOPPINESS = "include_file_mtime,time_macros";
|
||||||
|
CCACHE_NODIRECT = "1";
|
||||||
|
};
|
||||||
|
|
||||||
|
buildCachedFirefox = useSccache: unwrapped:
|
||||||
|
(unwrapped.override {
|
||||||
|
buildMozillaMach = x: pkgs'.buildMozillaMach (x // {
|
||||||
|
extraConfigureFlags = (x.extraConfigureFlags or [])
|
||||||
|
++ lib.toList (if useSccache then "--with-ccache=sccache" else "--with-ccache");
|
||||||
|
});
|
||||||
|
}).overrideAttrs (prev: if useSccache then {
|
||||||
|
nativeBuildInputs = (prev.nativeBuildInputs or []) ++ [ pkgs'.sccache ];
|
||||||
|
SCCACHE_DIR = "/var/cache/sccache";
|
||||||
|
SCCACHE_MAX_FRAME_LENGTH = "104857600";
|
||||||
|
RUSTC_WRAPPER = "${pkgs'.sccache}/bin/sccache";
|
||||||
|
} else ccacheVars // {
|
||||||
|
nativeBuildInputs = (prev.nativeBuildInputs or []) ++ [ pkgs'.ccache ];
|
||||||
|
});
|
||||||
|
|
||||||
|
ccacheConfig = ''
|
||||||
|
${builtins.concatStringsSep "\n" (lib.mapAttrsToList (k: v: "export ${k}=${v}") ccacheVars)}
|
||||||
|
if [ ! -d "$CCACHE_DIR" ]; then
|
||||||
|
echo "====="
|
||||||
|
echo "Directory '$CCACHE_DIR' does not exist"
|
||||||
|
echo "Please create it with:"
|
||||||
|
echo " sudo mkdir -m0770 '$CCACHE_DIR'"
|
||||||
|
echo " sudo chown root:nixbld '$CCACHE_DIR'"
|
||||||
|
echo "====="
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ! -w "$CCACHE_DIR" ]; then
|
||||||
|
echo "====="
|
||||||
|
echo "Directory '$CCACHE_DIR' is not accessible for user $(whoami)"
|
||||||
|
echo "Please verify its access permissions"
|
||||||
|
echo "====="
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
|
||||||
|
overrides = { extraConfig = ccacheConfig; };
|
||||||
|
|
||||||
|
cacheStdenv = pkgs: pkgs.ccacheStdenv.override overrides;
|
||||||
|
|
||||||
|
in {
|
||||||
|
# read by system/modules/ccache.nix
|
||||||
|
__dontIncludeCcacheOverlay = true;
|
||||||
|
ccacheWrapper = pkgs.ccacheWrapper.override overrides;
|
||||||
|
|
||||||
|
buildFirefoxWithCcache = buildCachedFirefox false;
|
||||||
|
buildFirefoxWithSccache = buildCachedFirefox true;
|
||||||
|
|
||||||
|
buildLinuxWithCcache = linux: linux.override {
|
||||||
|
stdenv = cacheStdenv pkgs';
|
||||||
|
buildPackages = pkgs'.buildPackages // {
|
||||||
|
stdenv = cacheStdenv pkgs'.buildPackages;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -10,24 +10,6 @@ let
|
||||||
inherit (pkgs) fetchgit fetchurl fetchFromGitHub dockerTools;
|
inherit (pkgs) fetchgit fetchurl fetchFromGitHub dockerTools;
|
||||||
};
|
};
|
||||||
nixForNixPlugins = pkgs.nixVersions.nix_2_17;
|
nixForNixPlugins = pkgs.nixVersions.nix_2_17;
|
||||||
buildCachedFirefox = useSccache: unwrapped:
|
|
||||||
(unwrapped.override {
|
|
||||||
buildMozillaMach = x: pkgs'.buildMozillaMach (x // {
|
|
||||||
extraConfigureFlags = (x.extraConfigureFlags or [])
|
|
||||||
++ lib.toList (if useSccache then "--with-ccache=sccache" else "--with-ccache");
|
|
||||||
});
|
|
||||||
}).overrideAttrs (prev: if useSccache then {
|
|
||||||
nativeBuildInputs = (prev.nativeBuildInputs or []) ++ [ pkgs'.sccache ];
|
|
||||||
SCCACHE_DIR = "/var/cache/sccache";
|
|
||||||
SCCACHE_MAX_FRAME_LENGTH = "104857600";
|
|
||||||
RUSTC_WRAPPER = "${pkgs'.sccache}/bin/sccache";
|
|
||||||
} else {
|
|
||||||
nativeBuildInputs = (prev.nativeBuildInputs or []) ++ [ pkgs'.ccache ];
|
|
||||||
CCACHE_CPP2 = "yes";
|
|
||||||
CCACHE_COMPRESS = "1";
|
|
||||||
CCACHE_UMASK = "007";
|
|
||||||
CCACHE_DIR = "/var/cache/ccache";
|
|
||||||
});
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -80,11 +62,10 @@ in
|
||||||
|
|
||||||
clang-tools_latest = pkgs.clang-tools_16;
|
clang-tools_latest = pkgs.clang-tools_16;
|
||||||
clang_latest = pkgs.clang_16;
|
clang_latest = pkgs.clang_16;
|
||||||
buildFirefoxWithCcache = buildCachedFirefox false;
|
|
||||||
buildFirefoxWithSccache = buildCachedFirefox true;
|
|
||||||
/*ghidra = pkgs.ghidra.overrideAttrs (old: {
|
/*ghidra = pkgs.ghidra.overrideAttrs (old: {
|
||||||
patches = old.patches ++ [ ./ghidra-stdcall.patch ];
|
patches = old.patches ++ [ ./ghidra-stdcall.patch ];
|
||||||
});*/
|
});*/
|
||||||
|
gimp = callPackage ./gimp { inherit (pkgs) gimp; };
|
||||||
home-daemon = callPackage ./home-daemon { };
|
home-daemon = callPackage ./home-daemon { };
|
||||||
# pin version
|
# pin version
|
||||||
looking-glass-client = pkgs.looking-glass-client.overrideAttrs (old: {
|
looking-glass-client = pkgs.looking-glass-client.overrideAttrs (old: {
|
||||||
|
@ -121,7 +102,7 @@ in
|
||||||
techmino = callPackage ./techmino { };
|
techmino = callPackage ./techmino { };
|
||||||
|
|
||||||
firefox-addons = lib.recurseIntoAttrs (callPackage ./firefox-addons { inherit nur sources; });
|
firefox-addons = lib.recurseIntoAttrs (callPackage ./firefox-addons { inherit nur sources; });
|
||||||
mpvScripts = pkgs.mpvScripts // (callPackage ./mpv-scripts { });
|
mpvScripts = pkgs.mpvScripts // callPackage ./mpv-scripts { };
|
||||||
|
|
||||||
qemu_7 = callPackage ./qemu_7.nix {
|
qemu_7 = callPackage ./qemu_7.nix {
|
||||||
stdenv = pkgs'.ccacheStdenv;
|
stdenv = pkgs'.ccacheStdenv;
|
||||||
|
@ -139,8 +120,15 @@ in
|
||||||
# TODO: when https://gitlab.com/virtio-fs/virtiofsd/-/issues/96 is fixed remove this
|
# TODO: when https://gitlab.com/virtio-fs/virtiofsd/-/issues/96 is fixed remove this
|
||||||
virtiofsd = callPackage ./qemu_virtiofsd.nix {
|
virtiofsd = callPackage ./qemu_virtiofsd.nix {
|
||||||
qemu = pkgs'.qemu_7;
|
qemu = pkgs'.qemu_7;
|
||||||
|
};
|
||||||
|
|
||||||
|
qemu_7_ccache = pkgs'.qemu_7.override {
|
||||||
|
stdenv = pkgs'.ccacheStdenv;
|
||||||
|
};
|
||||||
|
virtiofsd_ccache = pkgs'.virtiofsd.override {
|
||||||
|
qemu = pkgs'.qemu_7_ccache;
|
||||||
stdenv = pkgs'.ccacheStdenv;
|
stdenv = pkgs'.ccacheStdenv;
|
||||||
};
|
};
|
||||||
gimp = callPackage ./gimp { inherit (pkgs) gimp; };
|
|
||||||
}
|
}
|
||||||
// (import ../system/hardware/bpi-r3/pkgs.nix { inherit pkgs pkgs' lib sources; })
|
// import ./ccache.nix { inherit pkgs pkgs' lib sources; }
|
||||||
|
// import ../system/hardware/bpi-r3/pkgs.nix { inherit pkgs pkgs' lib sources; }
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{ pkgs
|
{ pkgs
|
||||||
, pkgs'
|
|
||||||
, lib
|
, lib
|
||||||
, sources
|
, sources
|
||||||
, ... }:
|
, ... }:
|
||||||
|
@ -60,31 +59,6 @@ let
|
||||||
url = "ftp://ftp.denx.de/pub/u-boot/u-boot-${ubootVersion}.tar.bz2";
|
url = "ftp://ftp.denx.de/pub/u-boot/u-boot-${ubootVersion}.tar.bz2";
|
||||||
hash = "sha256-tqp9fnGPQFeNGrkU/A6AusDEz7neh2KiR9HWbR7+WTY=";
|
hash = "sha256-tqp9fnGPQFeNGrkU/A6AusDEz7neh2KiR9HWbR7+WTY=";
|
||||||
};
|
};
|
||||||
# there are few direct hits with the linux kernel, so use CCACHE_NODIRECT
|
|
||||||
# (direct hits are file-based, non-direct are preprocessed file-based)
|
|
||||||
ccacheConfig = ''
|
|
||||||
export CCACHE_COMPRESS=1
|
|
||||||
export CCACHE_DIR="/var/cache/ccache"
|
|
||||||
export CCACHE_UMASK=007
|
|
||||||
export CCACHE_SLOPPINESS=include_file_mtime,time_macros
|
|
||||||
export CCACHE_NODIRECT=1
|
|
||||||
if [ ! -d "$CCACHE_DIR" ]; then
|
|
||||||
echo "====="
|
|
||||||
echo "Directory '$CCACHE_DIR' does not exist"
|
|
||||||
echo "Please create it with:"
|
|
||||||
echo " sudo mkdir -m0770 '$CCACHE_DIR'"
|
|
||||||
echo " sudo chown root:nixbld '$CCACHE_DIR'"
|
|
||||||
echo "====="
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ ! -w "$CCACHE_DIR" ]; then
|
|
||||||
echo "====="
|
|
||||||
echo "Directory '$CCACHE_DIR' is not accessible for user $(whoami)"
|
|
||||||
echo "Please verify its access permissions"
|
|
||||||
echo "====="
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
|
|
||||||
in rec {
|
in rec {
|
||||||
ubootBpiR3Sd = pkgs.buildUBoot {
|
ubootBpiR3Sd = pkgs.buildUBoot {
|
||||||
|
@ -334,12 +308,5 @@ in rec {
|
||||||
MMC_MTK = yes;
|
MMC_MTK = yes;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
linux_bpiR3_ccache = linux_bpiR3.override {
|
|
||||||
stdenv = pkgs'.ccacheStdenv.override { extraConfig = ccacheConfig; };
|
|
||||||
buildPackages = pkgs'.buildPackages // {
|
|
||||||
stdenv = pkgs'.buildPackages.ccacheStdenv.override { extraConfig = ccacheConfig; };
|
|
||||||
};
|
|
||||||
};
|
|
||||||
linuxPackages_bpiR3 = pkgs.linuxPackagesFor linux_bpiR3;
|
linuxPackages_bpiR3 = pkgs.linuxPackagesFor linux_bpiR3;
|
||||||
linuxPackages_bpiR3_ccache = pkgs.linuxPackagesFor linux_bpiR3_ccache;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
{ config, lib, ... }:
|
{ config
|
||||||
|
, lib
|
||||||
|
, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
nix.settings.extra-sandbox-paths = lib.mkIf config.programs.ccache.enable [
|
nix.settings.extra-sandbox-paths = lib.mkIf config.programs.ccache.enable [
|
||||||
config.programs.ccache.cacheDir
|
(assert config.programs.ccache.cacheDir == "/var/cache/ccache"; config.programs.ccache.cacheDir)
|
||||||
"/var/cache/sccache"
|
|
||||||
];
|
|
||||||
impermanence.directories = lib.mkIf config.programs.ccache.enable [
|
|
||||||
config.programs.ccache.cacheDir
|
|
||||||
"/var/cache/sccache"
|
"/var/cache/sccache"
|
||||||
];
|
];
|
||||||
nixpkgs.overlays = lib.mkIf (config.programs.ccache.enable && config.programs.ccache.packageNames == []) [
|
nixpkgs.overlays = lib.mkIf (config.programs.ccache.enable && config.programs.ccache.packageNames == []) [
|
||||||
(self: super: {
|
(self: super: {
|
||||||
ccacheWrapper = super.ccacheWrapper.override {
|
ccacheWrapper = if self?__dontIncludeCcacheOverlay then super.ccacheWrapper else super.ccacheWrapper.override {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
export CCACHE_COMPRESS=1
|
export CCACHE_COMPRESS=1
|
||||||
export CCACHE_DIR="${config.programs.ccache.cacheDir}"
|
export CCACHE_DIR="${config.programs.ccache.cacheDir}"
|
||||||
|
|
|
@ -127,6 +127,9 @@ in {
|
||||||
{ directory = /var/lib/openldap; inherit (config.services.openldap) user group; mode = "0755"; }
|
{ directory = /var/lib/openldap; inherit (config.services.openldap) user group; mode = "0755"; }
|
||||||
] ++ lib.optionals (config.services.scanservjs.enable or false) [
|
] ++ lib.optionals (config.services.scanservjs.enable or false) [
|
||||||
{ directory = /var/lib/scanservjs; user = "scanservjs"; group = "scanservjs"; mode = "0750"; }
|
{ directory = /var/lib/scanservjs; user = "scanservjs"; group = "scanservjs"; mode = "0750"; }
|
||||||
|
] ++ lib.optionals config.programs.ccache.enable [
|
||||||
|
{ directory = config.programs.ccache.cacheDir; user = "root"; group = "nixbld"; mode = "0770"; }
|
||||||
|
{ directory = /var/cache/sccache; user = "root"; group = "nixbld"; mode = "0770"; }
|
||||||
] ++ cfg.directories);
|
] ++ cfg.directories);
|
||||||
files = map (x:
|
files = map (x:
|
||||||
if builtins.isPath x then toString x
|
if builtins.isPath x then toString x
|
||||||
|
|
|
@ -192,6 +192,6 @@ in {
|
||||||
};
|
};
|
||||||
virtualisation.spiceUSBRedirection.enable = true;
|
virtualisation.spiceUSBRedirection.enable = true;
|
||||||
users.groups.libvirtd.members = [ "root" ] ++ cfg.libvirtdGroup;
|
users.groups.libvirtd.members = [ "root" ] ++ cfg.libvirtdGroup;
|
||||||
environment.systemPackages = with pkgs; [ virtiofsd ];
|
environment.systemPackages = [ (pkgs.virtiofsd_ccache or pkgs.virtiofsd) ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue