forked from irl/nix-configs
feat: use pipes to create homeConfigurations
This commit is contained in:
parent
de5a9787f6
commit
671533f47c
2 changed files with 57 additions and 28 deletions
49
flake.nix
49
flake.nix
|
@ -36,11 +36,6 @@
|
|||
sops-nix,
|
||||
}@inputs:
|
||||
let
|
||||
homeRoles = [
|
||||
"desktop"
|
||||
"minimal"
|
||||
"server"
|
||||
];
|
||||
outputs = inputs.self;
|
||||
overlays = [
|
||||
apple-silicon.overlays.apple-silicon-overlay
|
||||
|
@ -74,23 +69,35 @@
|
|||
};
|
||||
};
|
||||
homeManagerModules = import ./modules/home-manager;
|
||||
homeConfigurations = nixpkgs.lib.foldl' (c: e:
|
||||
c // {
|
||||
"irl-${e.role}-${e.system}" = home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = import nixpkgs {
|
||||
inherit overlays;
|
||||
system = e.system;
|
||||
};
|
||||
extraSpecialArgs = {
|
||||
inherit outputs;
|
||||
};
|
||||
modules = [
|
||||
./home-manager/irl.nix
|
||||
{ role = "${e.role}"; }
|
||||
];
|
||||
};
|
||||
homeConfigurations =
|
||||
{
|
||||
role = [
|
||||
"desktop"
|
||||
"minimal"
|
||||
"server"
|
||||
];
|
||||
system = supportedSystems;
|
||||
}
|
||||
) { } (nixpkgs.lib.cartesianProduct { role = homeRoles; system = supportedSystems; });
|
||||
|> nixpkgs.lib.cartesianProduct
|
||||
|> nixpkgs.lib.foldl' (
|
||||
c: e:
|
||||
c
|
||||
// {
|
||||
"irl-${e.role}-${e.system}" = home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = import nixpkgs {
|
||||
inherit overlays;
|
||||
system = e.system;
|
||||
};
|
||||
extraSpecialArgs = {
|
||||
inherit outputs;
|
||||
};
|
||||
modules = [
|
||||
./home-manager/irl.nix
|
||||
{ role = "${e.role}"; }
|
||||
];
|
||||
};
|
||||
}
|
||||
) { };
|
||||
}
|
||||
// flake-utils.lib.eachSystem supportedSystems (system: {
|
||||
formatter = nixpkgs.legacyPackages.${system}.nixfmt-tree;
|
||||
|
|
|
@ -11,26 +11,48 @@
|
|||
options.role = lib.mkOption {
|
||||
description = "Home role to set up";
|
||||
default = "minimal";
|
||||
type = with lib.types; enum ["desktop" "minimal" "server"];
|
||||
type =
|
||||
with lib.types;
|
||||
enum [
|
||||
"desktop"
|
||||
"minimal"
|
||||
"server"
|
||||
];
|
||||
};
|
||||
|
||||
config = {
|
||||
feature.cli.enable = builtins.elem config.role ["desktop" "minimal" "server"];
|
||||
feature.cli.enable = builtins.elem config.role [
|
||||
"desktop"
|
||||
"minimal"
|
||||
"server"
|
||||
];
|
||||
feature.firefox.enable = config.role == "desktop";
|
||||
feature.git.enable = builtins.elem config.role ["desktop" "server"];
|
||||
feature.git.enable = builtins.elem config.role [
|
||||
"desktop"
|
||||
"server"
|
||||
];
|
||||
feature.ops.enable = config.role == "desktop";
|
||||
feature.tmux.enable = builtins.elem config.role ["desktop" "server"];
|
||||
feature.vim.enable = builtins.elem config.role ["desktop" "minimal" "server"];
|
||||
feature.tmux.enable = builtins.elem config.role [
|
||||
"desktop"
|
||||
"server"
|
||||
];
|
||||
feature.vim.enable = builtins.elem config.role [
|
||||
"desktop"
|
||||
"minimal"
|
||||
"server"
|
||||
];
|
||||
|
||||
home.username = "irl";
|
||||
home.homeDirectory =
|
||||
if lib.strings.hasSuffix "darwin" pkgs.system then "/Users/irl" else "/home/irl";
|
||||
home.file.".config/nix/nix.conf".text = ''
|
||||
experimental-features = nix-command flakes pipe-operators
|
||||
'';
|
||||
home.packages = with pkgs; [
|
||||
neofetch
|
||||
];
|
||||
home.shellAliases = {
|
||||
hms =
|
||||
"home-manager switch --flake ~/.config/nix-configs#irl-${config.role}-${pkgs.system}";
|
||||
hms = "home-manager switch --flake ~/.config/nix-configs#irl-${config.role}-${pkgs.system}";
|
||||
drs = "sudo darwin-rebuild switch --flake ~/.config/nix-configs";
|
||||
};
|
||||
home.stateVersion = "25.05";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue