modules: system: nix: make it configurable

This commit is contained in:
Bruno BELANYI 2021-05-29 20:28:27 +02:00
parent 6728b50d3a
commit 003c08cb09

View file

@ -1,10 +1,28 @@
# Nix related settings # Nix related settings
{ inputs, pkgs, ... }: { config, inputs, lib, pkgs, ... }:
let
cfg = config.my.system.nix;
in
{
options.my.system.nix = with lib; {
enable = my.mkDisableOption "nix configuration";
addToRegistry = my.mkDisableOption "add inputs and self to registry";
};
config = lib.mkIf cfg.enable (lib.mkMerge [
{ {
nix = { nix = {
package = pkgs.nixFlakes; package = pkgs.nixFlakes;
registry = {
extraOptions = ''
experimental-features = nix-command flakes
'';
};
}
(lib.mkIf cfg.addToRegistry {
nix.registry = {
# Allow me to use my custom package using `nix run self#pkg` # Allow me to use my custom package using `nix run self#pkg`
self.flake = inputs.self; self.flake = inputs.self;
# Use pinned nixpkgs when using `nix run pkgs#<whatever>` # Use pinned nixpkgs when using `nix run pkgs#<whatever>`
@ -12,8 +30,6 @@
# Add NUR to run some packages that are only present there # Add NUR to run some packages that are only present there
nur.flake = inputs.nur; nur.flake = inputs.nur;
}; };
extraOptions = '' })
experimental-features = nix-command flakes ]);
'';
};
} }