fix homeConfiguration errors and add recipe for home-manager

This commit is contained in:
ulic-youthlic 2025-02-17 01:33:30 +08:00
parent b79c00310c
commit 66b740a123
Signed by: youthlic
GPG key ID: 63E86C3C14A0D721
7 changed files with 89 additions and 76 deletions

View file

@ -2,6 +2,9 @@
FLAKE_HOME := justfile_directory()
DEFAULT_SPECIALISATION := "default"
DEFAULT_KEEP_SINCE := "1w"
DEFAULT_USER := env('USER')
DEFAULT_HOST := shell('hostname')
default:
@just --list
@ -18,15 +21,27 @@ build specialisation=DEFAULT_SPECIALISATION:
deploy host:
deploy {{ FLAKE_HOME }}#{{ host }}
clean keep_since="1w":
nh clean all --verbose -K {{ keep_since }} -k 5
clean keepSince=DEFAULT_KEEP_SINCE:
nh clean all --verbose -K {{ keepSince }} -k 5
health:
nix --accept-flake-config run github:juspay/nix-health
switchHome host=DEFAULT_HOST $USER=DEFAULT_USER:
@echo USER: $USER
@echo HOST: {{ host }}
nh home switch -b backup {{ if host != DEFAULT_HOST { "-c \"" + USER + "@" + host + "\"" } else { "" } }} {{ FLAKE_HOME }}
buildHome host=DEFAULT_HOST $USER=DEFAULT_USER:
@echo USER: $USER
@echo HOST: {{ host }}
nh home build -b backup {{ if host != DEFAULT_HOST { "-c \"" + USER + "@" + host + "\"" } else { "" } }} {{ FLAKE_HOME }}
alias s := switch
alias u := update
alias d := deploy
alias c := clean
alias h := health
alias b := build
alias H := switchHome
alias B := buildHome

View file

@ -183,15 +183,15 @@
pkgs = nixpkgs.legacyPackages."${system}";
modules =
[
(./home + "/${unixName}/configurations/${hostName}")
"${toString ./home}/${unixName}/configurations/${hostName}"
]
++ (with outputs.homeManagerModules; [
default
"${unixName}"
extra
])
++ (with inputs; [
stylix.homeManagerModules.stylix
]);
++ [
outputs.homeManagerModules."${unixName}"
];
extraSpecialArgs = {
inherit
inputs
@ -220,18 +220,26 @@
homeManagerModules =
{
default = import ./home/modules;
extra = import ./home/extra;
}
// (
let
allEntries = builtins.readDir ./home;
allUsers = nixpkgs.lib.filterAttrs (
key: value: value == "directory" && key != "modules"
key: value:
value == "directory"
&& (
!builtins.elem key [
"modules"
"extra"
]
)
) allEntries;
in
builtins.listToAttrs (
map (name: {
name = name;
value = import (./home + "/${name}/modules");
value = import "${toString ./home}/${name}/modules";
}) (builtins.attrNames allUsers)
)
);

11
home/extra/default.nix Normal file
View file

@ -0,0 +1,11 @@
{ inputs, ... }:
{
imports =
(with inputs; [
niri-flake.homeModules.niri
stylix.homeManagerModules.stylix
])
++ [
./nix.nix
];
}

46
home/extra/nix.nix Normal file
View file

@ -0,0 +1,46 @@
{
outputs,
lib,
pkgs,
inputs,
...
}:
{
config = {
nixpkgs = {
config = {
allowUnfree = true;
allowUnfreePredicate = (_: true);
};
overlays = [
outputs.overlays.modifications
outputs.overlays.additions
];
};
nix = {
package = pkgs.nix;
settings = {
inherit (outputs.nix.settings) substituters;
trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE="
];
auto-optimise-store = lib.mkDefault true;
experimental-features = [
"nix-command"
"flakes"
];
warn-dirty = false;
use-xdg-base-directories = true;
};
registry.home = lib.mkDefault {
from = {
type = "indirect";
id = "home";
};
flake = inputs.nixpkgs;
};
};
};
}

View file

@ -1,6 +1,5 @@
{
inputs,
lib,
...
}:
{
@ -9,21 +8,10 @@
sops-nix.homeManagerModules.sops
])
++ [
./nix.nix
./programs
./xdg-dirs.nix
];
options = {
youthlic.nixos.enable = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = ''
whether the os is nixos
'';
};
};
config = {
programs.direnv = {
enable = true;

View file

@ -1,51 +0,0 @@
{
inputs,
lib,
config,
pkgs,
outputs,
...
}:
{
config =
let
cfg = config.youthlic.nixos;
in
(lib.mkIf (!cfg.enable) {
nixpkgs = {
config = {
allowUnfree = true;
allowUnfreePredicate = (_: true);
};
overlays = [
outputs.overlays.modifications
outputs.overlays.additions
];
};
nix = {
package = pkgs.nix;
settings = {
inherit (outputs.nix.settings) substituters;
trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE="
];
auto-optimise-store = lib.mkDefault true;
experimental-features = [
"nix-command"
"flakes"
];
warn-dirty = false;
use-xdg-base-directories = true;
};
registry.home = lib.mkDefault {
from = {
type = "indirect";
id = "home";
};
flake = inputs.nixpkgs;
};
};
});
}

View file

@ -50,10 +50,6 @@
outputs.homeManagerModules."${unixName}"
(rootPath + "/home/${unixName}/configurations/${hostName}")
];
config = {
youthlic.nixos.enable = true;
};
}
);
extraSpecialArgs = {