system/modules/nixos/configs/nix.nix

80 lines
2 KiB
Nix
Raw Permalink Normal View History

{ 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;
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);
nixpkgs.overlays = lib.mkBefore [
(final: prev: {
image-roll = prev.image-roll.override {
rustPlatform = prev.rustPlatform // {
buildRustPackage = args:
prev.rustPlatform.buildRustPackage (args // {
checkFlags = args.checkFlags ++ [
# Image type “ico” is not supported
"--skip=image::tests::save_image_uses_extensions_for_file_types_supported_by_pixbuf_save"
];
});
};
};
})
2024-10-07 21:20:41 +03:00
(final: prev: {
sniffnet = (import inputs.nixpkgs-unstable {
inherit (config.nixpkgs) config system;
}).sniffnet;
})
(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" ];
};
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";
})
];
2022-10-12 02:56:07 +03:00
};
};
}