Skip to content

Commit

Permalink
modules/shared/nix-daemon: disable channels and set flake registry, n…
Browse files Browse the repository at this point in the history
…ix path
  • Loading branch information
zowoq committed Sep 4, 2024
1 parent 9a2c568 commit a0b6bc0
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions modules/shared/nix-daemon.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
{ pkgs, ... }:
{
config,
inputs,
pkgs,
...
}:

let
asGB = size: toString (size * 1024 * 1024 * 1024);

# srvos
flake-registry = pkgs.writers.writeJSON "flake-registry.json" {
version = 2;
flakes = pkgs.lib.mapAttrsToList (name: value: {
exact = true;
from = {
id = name;
type = "indirect";
};
to = {
path = toString value;
type = "path";
};
}) ({ inherit (inputs) self; } // inputs.self.inputs);
};
in
{
nix = {
Expand All @@ -15,9 +36,16 @@ in
settings.min-free = asGB 1;
settings.max-free = asGB 50;

# useful for ad-hoc nix-shell's for debugging
# use mkForce to avoid search path warnings with nix-darwin
nixPath = pkgs.lib.mkForce [ "nixpkgs=${pkgs.path}" ];
channel.enable = false;
# disable system registry
registry = pkgs.lib.mkForce { };
settings = {
# set global registry
inherit flake-registry;
};
# explicitly set nix-path, NIX_PATH to nixpkgs from global registry
settings.nix-path = [ "nixpkgs=flake:nixpkgs" ];
nixPath = config.nix.settings.nix-path;

gc.automatic = pkgs.lib.mkDefault true;
gc.options = pkgs.lib.mkDefault "--delete-older-than 14d";
Expand Down

0 comments on commit a0b6bc0

Please sign in to comment.