2023-02-21 18:24:18 +01:00
|
|
|
# Nix related settings
|
|
|
|
{ config, inputs, lib, options, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.my.home.nix;
|
2023-02-25 02:32:09 +01:00
|
|
|
|
|
|
|
channels = lib.my.merge [
|
|
|
|
{
|
|
|
|
# Allow me to use my custom package using `nix run self#pkg`
|
|
|
|
self = inputs.self;
|
|
|
|
# Add NUR to run some packages that are only present there
|
|
|
|
nur = inputs.nur;
|
|
|
|
# Use pinned nixpkgs when using `nix run pkgs#<whatever>`
|
|
|
|
pkgs = inputs.nixpkgs;
|
|
|
|
}
|
|
|
|
(lib.optionalAttrs cfg.overrideNixpkgs {
|
|
|
|
# ... And with `nix run nixpkgs#<whatever>`
|
|
|
|
nixpkgs = inputs.nixpkgs;
|
|
|
|
})
|
|
|
|
];
|
2023-02-21 18:24:18 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.home.nix = with lib; {
|
|
|
|
enable = my.mkDisableOption "nix configuration";
|
|
|
|
|
|
|
|
addToRegistry = my.mkDisableOption "add inputs and self to registry";
|
|
|
|
|
|
|
|
overrideNixpkgs = my.mkDisableOption "point nixpkgs to pinned system version";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable (lib.mkMerge [
|
|
|
|
{
|
|
|
|
nix = {
|
2023-02-25 02:30:28 +01:00
|
|
|
package = lib.mkDefault pkgs.nix; # NixOS module sets it unconditionally
|
2023-02-21 18:24:18 +01:00
|
|
|
|
|
|
|
settings = {
|
|
|
|
experimental-features = [ "nix-command" "flakes" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
(lib.mkIf cfg.addToRegistry {
|
2023-02-25 02:32:09 +01:00
|
|
|
nix.registry =
|
|
|
|
let
|
|
|
|
makeEntry = v: { flake = v; };
|
|
|
|
makeEntries = lib.mapAttrs (lib.const makeEntry);
|
|
|
|
in
|
|
|
|
makeEntries channels;
|
2023-02-21 18:24:18 +01:00
|
|
|
})
|
|
|
|
]);
|
|
|
|
}
|