Skip to content

Commit

Permalink
abstract user configuration for general use, reorg, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ecarlson94 committed Mar 11, 2024
1 parent 84e91b0 commit d52f990
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 95 deletions.
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ If you have the repo installed locally at `~/gitrepos/dotnix`, you can rebuild w
rebuild
```

## System Modules

### CLI

#### [nvim](./modules/system/cli/nvim)
## [Nixvim Modules](./modules/nixvim)

- Nvim Configuration using [Nixvim](https://github.com/nix-community/nixvim)
- Available as a package
Expand All @@ -75,13 +71,31 @@ rebuild
nix run github:ecarlson94/dotnix/main#nvim
```

## [User Module](./modules/user/default.nix)

Configures a user for the NixOS using a dynamic user name that can be configured in `nixosConfiguration`.

## System Modules

### [Home](./modules/system/home.nix)

Configures Home Manager to be managed by the system for the configured user.

Downside: Changes to [home modules](./modules/home) require full system rebuild.

Upside: ONE COMMAND TO RULE THEM ALL (rebuild).

### Desktop

#### [Hyprland](./modules/system/desktop/hyprland)
#### [Hyprland](./modules/system/desktop/hyprland.nix)

Bare bones installation of the [Hyprland](https://hyprland.org) dynamic tiling Wayland compositor.

This is the starting point for configuring a UI.
This is the starting point for configuring a UI for NixOS.

#### [Sound](./modules/system/desktop/sound.nix)

Configures sound for NixOS.

## [Home Modules](./modules/home)

Expand Down
54 changes: 18 additions & 36 deletions hosts/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,35 @@
let
inherit (self) inputs packages;

desktop = ../modules/system/desktop;

createHomeManager = { system, user, homeFile }: {
useGlobalPkgs = true;
useUserPackages = true;
users.${user} = import homeFile;

# Optionally, use home-manager.extraSpecialArgs to pass
# arguments to home.nix
extraSpecialArgs = {
inherit (packages.${system}) nvim;
firefox-addons = inputs.firefox-addons.packages.${system};
theme = import ../theme;
};
};
userHomeModules = [
../modules/user
inputs.home-manager.nixosModules.home-manager
../modules/system/home.nix
];
in
{
nixos-wsl = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
modules = [
./nixos-wsl/configuration.nix
inputs.home-manager.nixosModules.home-manager
{
home-manager = createHomeManager {
inherit system;
user = "walawren";
homeFile = ./nixos-wsl/home.nix;
};
}
];
specialArgs = { inherit inputs; };
] ++ userHomeModules;
specialArgs = {
inherit inputs system packages;
target = "nixos-wsl";
homeOptions = { modules.cli.enable = true; };
};
};

desktop = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
modules = [
./desktop/configuration.nix
desktop
inputs.home-manager.nixosModules.home-manager
{
home-manager = createHomeManager {
inherit system;
user = "walawren";
homeFile = ./desktop/home.nix;
};
}
];
specialArgs = { inherit inputs; };
../modules/system/desktop
] ++ userHomeModules;
specialArgs = {
inherit inputs system packages;
target = "desktop";
homeOptions = { modules.desktop.enable = true; };
};
};
}
14 changes: 1 addition & 13 deletions hosts/desktop/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ pkgs, ... }:
let
target = "desktop";
in
{ pkgs, target, ... }:
{
imports =
[
Expand Down Expand Up @@ -53,15 +50,6 @@ in
LC_TIME = "en_US.UTF-8";
};

programs.zsh.enable = true;
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.walawren = {
shell = pkgs.zsh;
isNormalUser = true;
description = "Eric Carlson";
extraGroups = [ "networkmanager" "wheel" "audio" "sound" "video" ];
};

# Allow unfree packages
nixpkgs.config.allowUnfree = true;

Expand Down
10 changes: 0 additions & 10 deletions hosts/desktop/home.nix

This file was deleted.

19 changes: 3 additions & 16 deletions hosts/nixos-wsl/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@
# NixOS-WSL specific options are documented on the NixOS-WSL repository:
# https://github.com/nix-community/NixOS-WSL

{ pkgs, inputs, ... }:
let
target = "nixos-wsl";
in
{ pkgs, target, inputs, config, ... }:
{
imports = [
# include NixOS-WSL modules
inputs.nixos-wsl.nixosModules.wsl
];

wsl.enable = true;
wsl.defaultUser = "walawren";
wsl.defaultUser = config.user.name;


# This value determines the NixOS release from which the default
Expand All @@ -41,15 +38,5 @@ in
setSocketVariable = true;
};

programs = {
zsh.enable = true;
dconf.enable = true;
};

users.users = {
walawren = {
shell = pkgs.zsh;
extraGroups = [ "docker" ];
};
};
programs.dconf.enable = true; # Required for Home Manager
}
8 changes: 0 additions & 8 deletions hosts/nixos-wsl/home.nix

This file was deleted.

10 changes: 6 additions & 4 deletions modules/home/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
./desktop
];

home.packages = [
pkgs.curl
pkgs.wget
];
home = {
packages = [
pkgs.curl
pkgs.wget
];
};
}
2 changes: 1 addition & 1 deletion modules/system/desktop/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
imports = [
./hyprland
./hyprland.nix
./sound.nix
];
}
File renamed without changes.
21 changes: 21 additions & 0 deletions modules/system/home.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ system, inputs, packages, config, homeOptions ? { }, ... }:
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.${config.user.name} = {
imports = [ ../home ]; # Home Options

home.username = config.user.name;
home.homeDirectory = "/home/${config.user.name}";
} // homeOptions;

# Optionally, use home-manager.extraSpecialArgs to pass
# arguments to home.nix
extraSpecialArgs = {
inherit (packages.${system}) nvim;
firefox-addons = inputs.firefox-addons.packages.${system};
theme = import ../../theme;
};
};
}
27 changes: 27 additions & 0 deletions modules/user/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.user;

mkOpt = type: default: description:
mkOption { inherit type default description; };
in
{
options.user = with types; {
name = mkOpt str "walawren" "The name to use for the user account";
};

config = {
users.users.${cfg.name} = {
inherit (cfg) name;
shell = pkgs.zsh;
isNormalUser = true;
home = "/home/${cfg.name}";
group = "users";

extraGroups = [ "wheel" "networkmanager" "audio" "sound" "video" "input" "tty" "docker" ];
};

programs.zsh.enable = true;
};
}

0 comments on commit d52f990

Please sign in to comment.