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: build *args:
@just rebuild build {{args}} @just rebuild build {{args}}
home *args:
nix run .\#homeConfigurations.winston.activationPackage
[linux] [linux]
boot *args: boot *args:
@just rebuild boot {{args}} @just rebuild boot {{args}}

View file

@ -31,7 +31,7 @@
}; };
outputs = {flake-parts, ...} @ inputs: let outputs = {flake-parts, ...} @ inputs: let
inherit (import ./lib {inherit inputs;}) mkSystems overlays; inherit (import ./machines/lib.nix {inherit inputs;}) mkSystems overlays;
in in
flake-parts.lib.mkFlake {inherit inputs;} flake-parts.lib.mkFlake {inherit inputs;}
{ {
@ -84,6 +84,19 @@
inherit (self'.checks.pre-commit-check) shellHook; inherit (self'.checks.pre-commit-check) shellHook;
nativeBuildInputs = with pkgs; [git-crypt just sops]; 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; sway-unwrapped = inputs.swayfx.packages.${prev.system}.default;
}; };
commonHMConfig = {username}: ({ hmCommonConfig = {username}: ({
config, config,
pkgs, pkgs,
... ...
}: { }: let
homeLib = import ../home/lib.nix {inherit inputs username pkgs;};
in {
config = { config = {
nixpkgs.overlays = [overlays]; nixpkgs.overlays = [overlays];
home-manager = { home-manager = {
backupFileExtension = "backup"; backupFileExtension = "backup";
extraSpecialArgs = homeLib.extraSpecialArgs;
sharedModules = homeLib.modules;
useGlobalPkgs = true; useGlobalPkgs = true;
useUserPackages = 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]; 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 else if isDarwin
then "darwinConfigurations" then "darwinConfigurations"
else throw "Unsupported system"; else throw "Unsupported system";
builder = builder = with inputs;
if isLinux if isLinux
then inputs.nixpkgs.lib.nixosSystem then nixpkgs.lib.nixosSystem
else if isDarwin 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"; else throw "Unsupported system";
pkgs = inputs.nixpkgs.legacyPackages.${system}; pkgs = inputs.nixpkgs.legacyPackages.${system};
inherit (pkgs) lib; inherit (pkgs.stdenv) isDarwin isLinux;
inherit (pkgs.stdenv) isLinux isDarwin;
in { in {
${target}."${host}" = builder { ${target}."${host}" = builder {
inherit system; inherit system;
modules = modules = with inputs;
[../machines/common ../machines/${host}] [./common ./${host} home-manager.${module}.home-manager]
++ lib.optionals isLinux [inputs.home-manager.nixosModules.home-manager] ++ [(hmCommonConfig {inherit username;})]
++ lib.optionals isDarwin [inputs.home-manager.darwinModules.home-manager]
++ [(commonHMConfig {inherit username;})]
++ extraModules; ++ extraModules;
}; };
}; };