2023-03-31 17:40:22 +03:00
|
|
|
{ lib, inputs, config, ... }:
|
2022-10-12 02:56:07 +03:00
|
|
|
|
2022-11-13 23:14:04 +03:00
|
|
|
let
|
|
|
|
inherit (builtins) elem;
|
|
|
|
cfg = config.local.nix;
|
2023-03-31 17:40:22 +03:00
|
|
|
|
|
|
|
gitple = "https://git.pleshevski.ru";
|
|
|
|
mkRegistry = id: url: {
|
|
|
|
from = { type = "indirect"; inherit id; };
|
|
|
|
to = { type = "git"; inherit url; };
|
|
|
|
};
|
2022-11-13 23:14:04 +03:00
|
|
|
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 {
|
2023-03-02 16:00:19 +03:00
|
|
|
type = types.listOf types.str;
|
2022-11-13 23:14:04 +03:00
|
|
|
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);
|
|
|
|
|
2023-03-31 17:40:22 +03:00
|
|
|
nixpkgs.overlays = lib.mkBefore [
|
|
|
|
inputs.self.overlays.default
|
|
|
|
(final: prev: {
|
|
|
|
unstable = import inputs.nixpkgs-unstable {
|
|
|
|
inherit (config.nixpkgs) config overlays system;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2023-03-31 17:40:22 +03:00
|
|
|
registry = lib.mkMerge [
|
|
|
|
{
|
|
|
|
nixpkgs.flake = inputs.nixpkgs;
|
|
|
|
nixpkgs-unstable.flake = inputs.nixpkgs-unstable;
|
|
|
|
}
|
|
|
|
|
|
|
|
(lib.mkIf cfg.enableMyRegistry {
|
|
|
|
templates = mkRegistry "tmpl" "${gitple}/mynix/templates";
|
|
|
|
tools = mkRegistry "tools" "${gitple}/mynix/tools";
|
|
|
|
tools_wd2 = mkRegistry "wd2" "${gitple}/pleshevskiy/wd2";
|
|
|
|
})
|
|
|
|
];
|
2022-10-12 02:56:07 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|