1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-09-13 01:27:56 +00:00

rebuild: fix nh

This commit is contained in:
RGBCube 2025-07-26 19:59:48 +03:00
parent c5f3572631
commit 86f136d9fd
Signed by: RGBCube
SSH key fingerprint: SHA256:CzqbPcfwt+GxFYNnFVCqoN5Itn4YFrshg1TrnACpA5M
3 changed files with 35 additions and 3 deletions

View file

@ -0,0 +1,87 @@
{ self, config, inputs, lib, pkgs, ... }: let
inherit (lib) attrsToList concatStringsSep const disabled filter filterAttrs flip id isType mapAttrs mapAttrsToList merge mkAfter optionalAttrs optionals;
inherit (lib.strings) toJSON;
registryMap = inputs
|> filterAttrs (const <| isType "flake");
in {
# We don't want this to be garbage collected away because if
# that happens rebuilds are slow thanks to my garbage WiFi.
environment.etc.".system-inputs.json".text = toJSON registryMap;
nix.distributedBuilds = true;
nix.buildMachines = self.nixosConfigurations
|> attrsToList
|> filter ({ name, value }:
name != config.networking.hostName &&
value.config.users.users ? build)
|> map ({ name, value }: {
hostName = name;
maxJobs = 20;
protocol = "ssh-ng";
sshUser = "build";
supportedFeatures = [ "benchmark" "big-parallel" "kvm" "nixos-test" ];
system = value.config.nixpkgs.hostPlatform.system;
});
nix.channel = disabled;
nix.gc = merge {
automatic = true;
options = "--delete-older-than 3d";
} <| optionalAttrs config.isLinux {
dates = "weekly";
persistent = true;
};
nix.nixPath = registryMap
|> mapAttrsToList (name: value: "${name}=${value}")
|> (if config.isDarwin then concatStringsSep ":" else id);
nix.registry = registryMap // { default = inputs.nixpkgs; }
|> mapAttrs (_: flake: { inherit flake; });
nix.settings = (import <| self + /flake.nix).nixConfig
|> flip removeAttrs (optionals config.isDarwin [ "use-cgroups" ]);
# |> (if config.isLinux && config.services.nix-serve.enable then
# (cfg: cfg // {
# extra-substituters = cfg.extra-substituters
# |> filter (x: match ".*cache.rgbcu.be.*" x == null);
# })
# else
# id);
nix.optimise.automatic = true;
environment.systemPackages = [
(pkgs.nh.overrideAttrs (old: {
patches = old.patches or [] ++ [
./nh.patch
];
}))
pkgs.nix-index
pkgs.nix-output-monitor
];
home-manager.sharedModules = [{
programs.nushell.configFile.text = mkAfter /* nu */ ''
def --wrapped * [program: string = "", ...arguments] {
if ($program | str contains "#") or ($program | str contains ":") {
nix run $program -- ...$arguments
} else {
nix run ("default#" + $program) -- ...$arguments
}
}
def --wrapped > [...programs] {
nix shell ...($programs | each {
if ($in | str contains "#") or ($in | str contains ":") {
$in
} else {
"default#" + $in
}
})
}
'';
}];
}