Add nix configuration for home-manager

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)
This commit is contained in:
NullBite 2024-04-21 12:24:48 -04:00
parent 5ed359d561
commit 1379670cd9
Signed by: nullbite
GPG Key ID: 6C4D545385D4925A
3 changed files with 47 additions and 0 deletions

View File

@ -3,5 +3,6 @@
imports = [
./wm.nix
./nodm.nix
./nix.nix
];
}

45
home/common/nix.nix Normal file
View File

@ -0,0 +1,45 @@
{ 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";
};
}

View File

@ -15,6 +15,7 @@ in
config = lib.mkIf cfg.enable {
nixfiles.programs.comma.enable = true;
nixfiles.common.nix.enable = true;
home.sessionVariables = lib.mkMerge [
(lib.mkIf config.programs.neovim.enable {