2022-10-12 02:56:07 +03:00
|
|
|
{ lib, config, ... }:
|
|
|
|
|
2022-11-13 23:14:04 +03:00
|
|
|
let
|
|
|
|
inherit (builtins) elem;
|
|
|
|
cfg = config.local.nix;
|
|
|
|
in
|
2022-10-12 02:56:07 +03:00
|
|
|
{
|
|
|
|
options.local.nix = with lib; {
|
|
|
|
enableMyRegistry = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Enable my custom nix registry";
|
|
|
|
};
|
2022-11-13 23:14:04 +03:00
|
|
|
allowUnfreePackages = mkOption {
|
|
|
|
type = types.listOf types.string;
|
|
|
|
default = [ ];
|
|
|
|
};
|
2022-10-12 02:56:07 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
2022-11-13 23:14:04 +03:00
|
|
|
nixpkgs.config.allowUnfreePredicate = lib.mkIf
|
|
|
|
(cfg.allowUnfreePackages != [ ])
|
|
|
|
(pkg: elem (lib.getName pkg) cfg.allowUnfreePackages);
|
|
|
|
|
2022-10-12 02:56:07 +03:00
|
|
|
nix = {
|
|
|
|
settings = {
|
|
|
|
auto-optimise-store = true;
|
|
|
|
|
|
|
|
trusted-users = [ "root" ];
|
|
|
|
|
|
|
|
experimental-features = [ "nix-command" "flakes" ];
|
|
|
|
|
|
|
|
# To protect nix-shell against garbage collection
|
|
|
|
# Source: https://github.com/nix-community/nix-direnv#installation
|
|
|
|
keep-derivations = true;
|
|
|
|
keep-outputs = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
registry = lib.mkIf cfg.enableMyRegistry (
|
|
|
|
let
|
|
|
|
gitple = "https://git.pleshevski.ru";
|
|
|
|
mkRegistry = id: url: {
|
|
|
|
from = { type = "indirect"; inherit id; };
|
|
|
|
to = { type = "git"; inherit url; };
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{ templates = mkRegistry "tmpl" "${gitple}/mynix/templates"; }
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|