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:
parent
5ed359d561
commit
1379670cd9
@ -3,5 +3,6 @@
|
||||
imports = [
|
||||
./wm.nix
|
||||
./nodm.nix
|
||||
./nix.nix
|
||||
];
|
||||
}
|
||||
|
45
home/common/nix.nix
Normal file
45
home/common/nix.nix
Normal 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";
|
||||
};
|
||||
}
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user