This ensures home-manager devices use the the already downloaded nixpkgs for ad-hoc commands like nix-shell and comma, as well as adds this flake to the registry (currently assumed to be located at ~/nixfiles, I should make this configurable later)
46 lines
1.0 KiB
Nix
46 lines
1.0 KiB
Nix
{ pkgs, lib, config, osConfig ? { }, options, nixpkgs, ... }:
|
|
let
|
|
cfg = config.nixfiles.common.nix;
|
|
standalone = !(osConfig ? home-manager);
|
|
in {
|
|
config = lib.mkIf cfg.enable (lib.mkMerge [
|
|
{
|
|
nix.registry = {
|
|
nixfiles = {
|
|
exact = true;
|
|
from = {
|
|
id = "nixfiles";
|
|
type = "indirect";
|
|
};
|
|
to = {
|
|
type = "git";
|
|
url = "file://${config.home.homeDirectory}/nixfiles";
|
|
};
|
|
};
|
|
};
|
|
}
|
|
|
|
(lib.mkIf standalone {
|
|
home.sessionVariables.NIX_PATH = "nixpkgs=${nixpkgs}\${NIX_PATH:+:\${NIX_PATH}}";
|
|
nix.registry = {
|
|
nixpkgs = {
|
|
exact = true;
|
|
from = {
|
|
id = "nixpkgs";
|
|
type = "indirect";
|
|
};
|
|
to = {
|
|
type = "github";
|
|
owner = "NixOS";
|
|
repo = "nixpkgs";
|
|
rev = "${nixpkgs.rev}";
|
|
};
|
|
};
|
|
};
|
|
})
|
|
]);
|
|
options.nixfiles.common.nix = {
|
|
enable = lib.mkEnableOption "Nix configuration";
|
|
};
|
|
}
|