Files
jsl-home/flake.nix
2025-07-06 23:59:40 -05:00

103 lines
3.2 KiB
Nix

{
description = "Home Manager configuration flake for JSL";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
_1password-shell-plugins.url = "github:1Password/shell-plugins";
nixgl = {
url = "github:nix-community/nixGL";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, ... }@inputs:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
# These will get applied to both the configured user and the root user (if enabled)
userOptions = config: {
openssh.authorizedKeys = lib.mkIf config.ssh (lib.mkMerge [
(lib.mkIf (config.profile == "personal") { keyFiles = [ ./keys/personal ]; })
(lib.mkIf (config.profile == "work") { keyFiles = [ ./keys/work ]; })
]);
shell = lib.mkIf config.enableShell pkgs.zsh;
};
mkhomeManagerModules = config: [
self.homeManagerModules.default
# { inherit (config) extraImports; }
{
user = config.user;
stateVersion = config.stateVersion;
profile = config.profile;
enableShell = config.enableShell;
ssh = config.ssh;
_1password = config._1password;
docker = config.docker;
graphical = config.graphical;
}
] ++ config.extraImports;
in
{
lib = { inherit mkhomeManagerModules; };
homeManagerModules.default = { ... }: { imports = [ ./homeManagerModules ]; };
nixosModules.default = { config, ... }: {
imports = [
./nixosModules
inputs.home-manager.nixosModules.default
];
nix.settings.trusted-users = [ "root" "@wheel" ];
users.users.${config.user} = lib.mkMerge [
{
isNormalUser = true;
description = "John Lancaster";
extraGroups = []
++ lib.optional config.root "wheel"
++ lib.optional config.docker "docker"
++ lib.optional config.networking.networkmanager.enable "networkmanager";
}
(userOptions config)
];
users.users.root = lib.mkIf config.root (userOptions config);
security.sudo-rs = lib.mkIf config.root {
enable = true;
execWheelOnly = false;
wheelNeedsPassword = false;
extraConfig = "Defaults timestamp_timeout=1440";
};
programs.zsh.enable = lib.mkIf config.enableShell true;
virtualisation.docker = lib.mkIf config.docker {
enable = true;
enableOnBoot = true;
package = pkgs.docker;
};
home-manager = {
useUserPackages = true;
extraSpecialArgs = { inherit inputs; nixgl = inputs.nixgl; };
users = {
${config.user} = {
imports = mkhomeManagerModules config;
};
} // lib.optionalAttrs config.root {
root = {
imports = mkhomeManagerModules (config // { user = "root"; });
};
};
};
};
};
}