examples
This commit is contained in:
81
README.md
Normal file
81
README.md
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
# JSL Home
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Shell alias for "nix home manager update"
|
||||||
|
|
||||||
|
```shell
|
||||||
|
nhmu
|
||||||
|
```
|
||||||
|
|
||||||
|
### Function
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
description = "Machine-specific Home Manager configuration";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
|
john-home-config = {
|
||||||
|
url = "git+https://gitea.john-stream.com/john/home-manager";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{ nixpkgs, ... }@inputs:
|
||||||
|
let
|
||||||
|
system = "x86_64-linux";
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
mkHomeJSL = inputs.john-home-config.lib.mkHomeConfiguration;
|
||||||
|
userName = "john";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
homeConfigurations."${userName}" = mkHomeJSL userName;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Module
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
description = "Home Manager configuration of john";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
|
home-manager = {
|
||||||
|
url = "github:nix-community/home-manager";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
john-home-config = {
|
||||||
|
url = "path:/home/john/home-manager";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
inputs.home-manager.follows = "home-manager";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{ nixpkgs, ... }@inputs:
|
||||||
|
let
|
||||||
|
system = "x86_64-linux";
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
homeManagerConfiguration = inputs.home-manager.lib.homeManagerConfiguration;
|
||||||
|
jslDefault = inputs.john-home-config.homeManagerModules.default;
|
||||||
|
userName = "john";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
homeConfigurations."${userName}" = homeManagerConfiguration {
|
||||||
|
inherit pkgs;
|
||||||
|
modules = [
|
||||||
|
jslDefault {
|
||||||
|
user = "${userName}";
|
||||||
|
# Add any additional configuration here
|
||||||
|
}
|
||||||
|
./home.nix
|
||||||
|
# Add other home manager modules here
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
22
flake.nix
22
flake.nix
@@ -16,19 +16,20 @@
|
|||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
lib = pkgs.lib;
|
lib = pkgs.lib;
|
||||||
|
|
||||||
# Define the module first (moved from below)
|
# Defined up separately up here so that it can be evaluated by itself to determine the username
|
||||||
homeManagerModule = { config, pkgs, ... }: {
|
homeManagerModule = { config, pkgs, ... }: {
|
||||||
options.user = lib.mkOption {
|
options.user = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = "The username for the Home Manager configuration.";
|
description = "The username for the Home Manager configuration.";
|
||||||
};
|
};
|
||||||
imports = [ ./home.nix ];
|
|
||||||
};
|
|
||||||
|
|
||||||
# Function to create a home configuration for any user
|
options.profile = lib.mkOption {
|
||||||
mkHomeConfiguration = username: home-manager.lib.homeManagerConfiguration {
|
type = lib.types.enum [ "personal" "work" ];
|
||||||
inherit pkgs;
|
default = "personal";
|
||||||
modules = [ homeManagerModule { user = username; } ];
|
description = "Profile type for the Home Manager configuration.";
|
||||||
|
};
|
||||||
|
|
||||||
|
imports = [ ./home.nix ];
|
||||||
};
|
};
|
||||||
|
|
||||||
# Default username from the module evaluation
|
# Default username from the module evaluation
|
||||||
@@ -40,7 +41,12 @@
|
|||||||
homeConfigurations.${userName} = mkHomeConfiguration userName;
|
homeConfigurations.${userName} = mkHomeConfiguration userName;
|
||||||
|
|
||||||
# Export the function so other flakes can create configurations for any user
|
# Export the function so other flakes can create configurations for any user
|
||||||
lib.mkHomeConfiguration = mkHomeConfiguration;
|
lib.mkHomeConfiguration = username: home-manager.lib.homeManagerConfiguration {
|
||||||
|
inherit pkgs;
|
||||||
|
modules = [
|
||||||
|
homeManagerModule { user = username; }
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
# Export modules for reuse in other flakes
|
# Export modules for reuse in other flakes
|
||||||
homeManagerModules.default = homeManagerModule;
|
homeManagerModules.default = homeManagerModule;
|
||||||
|
|||||||
Reference in New Issue
Block a user