2024-03-05 22:57:41 +01:00
|
|
|
{
|
2024-06-02 22:56:02 +02:00
|
|
|
config,
|
2024-03-05 22:57:41 +01:00
|
|
|
nix-index-database,
|
|
|
|
nixpkgs-unstable,
|
|
|
|
nixpkgs,
|
|
|
|
...
|
|
|
|
}: {
|
2023-08-01 15:35:09 +02:00
|
|
|
imports = [
|
|
|
|
nix-index-database.nixosModules.nix-index
|
|
|
|
];
|
|
|
|
|
|
|
|
nix = {
|
|
|
|
# https://nixos.wiki/wiki/Storage_optimization
|
|
|
|
gc = {
|
2023-11-12 03:03:15 +01:00
|
|
|
# Automatically run the nix garbage collector, removing files from
|
|
|
|
# the store that are not referenced by any generation.
|
|
|
|
# https://nixos.org/manual/nix/stable/package-management/garbage-collection
|
2023-08-01 15:35:09 +02:00
|
|
|
automatic = true;
|
|
|
|
dates = "weekly";
|
2023-12-29 16:12:01 +01:00
|
|
|
options = "--delete-older-than 7d";
|
2023-08-01 15:35:09 +02:00
|
|
|
};
|
2024-03-05 22:17:26 +01:00
|
|
|
|
2023-08-01 15:35:09 +02:00
|
|
|
settings = {
|
2023-11-12 03:03:15 +01:00
|
|
|
# Automatically optimise the store after each build. Store optimisation
|
|
|
|
# reduces nix store space by 25-35% by finding identical files and
|
|
|
|
# hard-linking them to each other.
|
|
|
|
# https://nixos.org/manual/nix/unstable/command-ref/nix-store/optimise.html
|
2023-08-01 15:35:09 +02:00
|
|
|
auto-optimise-store = true;
|
2024-03-05 22:17:26 +01:00
|
|
|
|
|
|
|
# Enable flakes
|
2024-03-28 15:53:10 +01:00
|
|
|
experimental-features = ["nix-command" "flakes" "repl-flake"];
|
2024-03-05 22:17:26 +01:00
|
|
|
|
|
|
|
# Timeout connections to the binary cache instead of waiting forever
|
|
|
|
connect-timeout = 5;
|
2023-08-01 15:35:09 +02:00
|
|
|
};
|
2023-11-11 00:49:55 +01:00
|
|
|
|
|
|
|
# The nix registry is used to refer to flakes using symbolic identifiers
|
|
|
|
# when running commands such as `nix run nixpkgs#hello`. By default,
|
2024-06-02 22:56:02 +02:00
|
|
|
# `nixpkgs` is an alias of the system's nixpkgs, but no such alias is made
|
|
|
|
# for unstable.
|
2023-11-11 00:49:55 +01:00
|
|
|
registry = {
|
|
|
|
nixpkgs-unstable.flake = nixpkgs-unstable;
|
|
|
|
};
|
2023-08-01 15:35:09 +02:00
|
|
|
};
|
|
|
|
|
2024-03-09 23:25:35 +01:00
|
|
|
# The system-wide garbage collection service configured above does not know
|
2024-06-02 22:56:02 +02:00
|
|
|
# about our user profile.
|
|
|
|
home-manager.users.caspervk.nix.gc = {
|
|
|
|
inherit (config.nix.gc) automatic options;
|
|
|
|
frequency = config.nix.gc.dates;
|
|
|
|
};
|
2024-03-09 23:25:35 +01:00
|
|
|
|
2024-05-13 17:19:21 +02:00
|
|
|
# Run unpatched dynamic binaries on NixOS.
|
|
|
|
# https://github.com/Mic92/nix-ld
|
|
|
|
programs.nix-ld.enable = true;
|
|
|
|
|
|
|
|
# Comma runs software without installing it. Basically it just wraps together
|
|
|
|
# `nix shell -c` and `nix-index`. You stick a `,` in front of a command to
|
|
|
|
# run it from whatever location it happens to occupy in nixpkgs without
|
|
|
|
# really thinking about it.
|
2023-08-01 15:35:09 +02:00
|
|
|
# https://github.com/nix-community/comma
|
|
|
|
programs.nix-index-database.comma.enable = true;
|
|
|
|
programs.command-not-found.enable = false;
|
|
|
|
}
|