feat: add home-manager only config

This commit is contained in:
winston 2023-06-15 01:40:55 +02:00
parent a1b282277e
commit 6145561132
Signed by: winston
GPG key ID: 3786770EDBC2B481
4 changed files with 69 additions and 25 deletions

View file

@ -21,6 +21,9 @@ rebuild *args:
build *args:
@just rebuild build {{args}}
home *args:
nix run .\#homeConfigurations.winston.activationPackage
[linux]
boot *args:
@just rebuild boot {{args}}

View file

@ -31,7 +31,7 @@
};
outputs = {flake-parts, ...} @ inputs: let
inherit (import ./lib {inherit inputs;}) mkSystems overlays;
inherit (import ./machines/lib.nix {inherit inputs;}) mkSystems overlays;
in
flake-parts.lib.mkFlake {inherit inputs;}
{
@ -84,6 +84,19 @@
inherit (self'.checks.pre-commit-check) shellHook;
nativeBuildInputs = with pkgs; [git-crypt just sops];
};
legacyPackages.homeConfigurations = let
homeLib = import ./home/lib.nix {
inherit inputs pkgs username;
isNixos = false;
};
username = "winston";
in {
${username} = inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
inherit (homeLib) extraSpecialArgs modules;
};
};
};
};

33
home/lib.nix Normal file
View file

@ -0,0 +1,33 @@
{
inputs,
pkgs,
username,
isNixOS ? true,
}: rec {
extraSpecialArgs = {
flakePath =
if pkgs.stdenv.isDarwin
then "/Users/${username}/.config/nixpkgs"
else "/home/${username}/.config/nixpkgs";
};
hmStandaloneConfig = {
home.homeDirectory =
if pkgs.stdenv.isLinux
then "/home/${username}"
else if pkgs.stdenv.isDarwin
then "/Users/${username}"
else throw "Unsupported system";
home.stateVersion = "23.05";
home.username = username;
targets.genericLinux.enable = true;
xdg.mime.enable = true;
};
modules = with inputs;
[
nix-index-database.hmModules.nix-index
sops.homeManagerModules.sops
caarlos0-nur.homeManagerModules.default
nekowinston-nur.homeManagerModules.default
]
++ pkgs.lib.optionals (!isNixOS) [hmStandaloneConfig];
}

View file

@ -10,30 +10,22 @@
};
sway-unwrapped = inputs.swayfx.packages.${prev.system}.default;
};
commonHMConfig = {username}: ({
hmCommonConfig = {username}: ({
config,
pkgs,
...
}: {
}: let
homeLib = import ../home/lib.nix {inherit inputs username pkgs;};
in {
config = {
nixpkgs.overlays = [overlays];
home-manager = {
backupFileExtension = "backup";
extraSpecialArgs = homeLib.extraSpecialArgs;
sharedModules = homeLib.modules;
useGlobalPkgs = true;
useUserPackages = true;
sharedModules = with inputs; [
nix-index-database.hmModules.nix-index
sops.homeManagerModules.sops
caarlos0-nur.homeManagerModules.default
nekowinston-nur.homeManagerModules.default
];
users.${username}.imports = [../home];
extraSpecialArgs = {
flakePath =
if pkgs.stdenv.isDarwin
then "/Users/${username}/.config/nixpkgs"
else "/home/${username}/.config/nixpkgs";
};
};
};
});
@ -53,23 +45,26 @@
else if isDarwin
then "darwinConfigurations"
else throw "Unsupported system";
builder =
builder = with inputs;
if isLinux
then inputs.nixpkgs.lib.nixosSystem
then nixpkgs.lib.nixosSystem
else if isDarwin
then inputs.darwin.lib.darwinSystem
then darwin.lib.darwinSystem
else throw "Unsupported system";
module =
if isLinux
then "nixosModules"
else if isDarwin
then "darwinModules"
else throw "Unsupported system";
pkgs = inputs.nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
inherit (pkgs.stdenv) isLinux isDarwin;
inherit (pkgs.stdenv) isDarwin isLinux;
in {
${target}."${host}" = builder {
inherit system;
modules =
[../machines/common ../machines/${host}]
++ lib.optionals isLinux [inputs.home-manager.nixosModules.home-manager]
++ lib.optionals isDarwin [inputs.home-manager.darwinModules.home-manager]
++ [(commonHMConfig {inherit username;})]
modules = with inputs;
[./common ./${host} home-manager.${module}.home-manager]
++ [(hmCommonConfig {inherit username;})]
++ extraModules;
};
};