2021-02-06 15:35:38 +01:00
|
|
|
# Nix related settings
|
2021-12-22 23:47:27 +01:00
|
|
|
{ config, inputs, lib, options, pkgs, ... }:
|
2021-05-29 20:28:27 +02:00
|
|
|
let
|
|
|
|
cfg = config.my.system.nix;
|
|
|
|
in
|
2021-02-06 15:35:38 +01:00
|
|
|
{
|
2021-05-29 20:28:27 +02:00
|
|
|
options.my.system.nix = with lib; {
|
|
|
|
enable = my.mkDisableOption "nix configuration";
|
|
|
|
|
|
|
|
addToRegistry = my.mkDisableOption "add inputs and self to registry";
|
2021-12-22 23:47:27 +01:00
|
|
|
|
|
|
|
addToNixPath = my.mkDisableOption "add inputs and self to nix path";
|
2023-02-11 12:03:32 +01:00
|
|
|
|
|
|
|
overrideNixpkgs = my.mkDisableOption "point nixpkgs to pinned system version";
|
2021-02-06 15:35:38 +01:00
|
|
|
};
|
2021-05-29 20:28:27 +02:00
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable (lib.mkMerge [
|
|
|
|
{
|
|
|
|
nix = {
|
2022-09-29 21:58:48 +02:00
|
|
|
package = pkgs.nix;
|
2021-05-29 20:28:27 +02:00
|
|
|
|
2022-02-08 14:32:00 +01:00
|
|
|
settings = {
|
|
|
|
experimental-features = [ "nix-command" "flakes" ];
|
|
|
|
};
|
2021-05-29 20:28:27 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
(lib.mkIf cfg.addToRegistry {
|
|
|
|
nix.registry = {
|
|
|
|
# Allow me to use my custom package using `nix run self#pkg`
|
|
|
|
self.flake = inputs.self;
|
|
|
|
# Use pinned nixpkgs when using `nix run pkgs#<whatever>`
|
|
|
|
pkgs.flake = inputs.nixpkgs;
|
2023-02-11 12:03:32 +01:00
|
|
|
# ... And with `nix run nixpkgs#<whatever>`
|
|
|
|
nixpkgs.flake = lib.mkIf cfg.overrideNixpkgs inputs.nixpkgs;
|
2021-05-29 20:28:27 +02:00
|
|
|
# Add NUR to run some packages that are only present there
|
|
|
|
nur.flake = inputs.nur;
|
|
|
|
};
|
|
|
|
})
|
2021-12-22 23:47:27 +01:00
|
|
|
|
|
|
|
(lib.mkIf cfg.addToNixPath {
|
2023-02-11 11:53:52 +01:00
|
|
|
nix.nixPath = [
|
2021-12-22 23:47:27 +01:00
|
|
|
"self=${inputs.self}"
|
|
|
|
"pkgs=${inputs.nixpkgs}"
|
|
|
|
"nur=${inputs.nur}"
|
2023-02-11 12:03:32 +01:00
|
|
|
]
|
|
|
|
++ lib.optional cfg.overrideNixpkgs "nixpkgs=${inputs.nixpkgs}"
|
2023-02-11 11:53:52 +01:00
|
|
|
++ options.nix.nixPath.default;
|
2021-12-22 23:47:27 +01:00
|
|
|
})
|
2021-05-29 20:28:27 +02:00
|
|
|
]);
|
2021-02-06 15:35:38 +01:00
|
|
|
}
|