mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-04-28 00:19:11 +00:00
Update home-manager modules and related configs
This commit is contained in:
parent
db5fc8269e
commit
e2699c2cea
6
flake.lock
generated
6
flake.lock
generated
@ -42,11 +42,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1638097282,
|
"lastModified": 1638129630,
|
||||||
"narHash": "sha256-EXCzj9b8X/lqDPJapxZThIOKL5ASbpsJZ+8L1LnY1ig=",
|
"narHash": "sha256-vaYC1DhrR1nao2rQ8fUf4PNhBLfSeCi2LVrDXTxUu1Y=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "78cb77b29d37a9663e05b61abb4fa09465da4b70",
|
"rev": "9f25a8ac3a985ba213f775b19750efefdecc9974",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
47
flake.nix
47
flake.nix
@ -12,8 +12,22 @@
|
|||||||
|
|
||||||
outputs = inputs@{ self, nixpkgs, home-manager, ... }:
|
outputs = inputs@{ self, nixpkgs, home-manager, ... }:
|
||||||
let
|
let
|
||||||
libExtended = nixpkgs.lib.extend
|
# All the target systems.
|
||||||
(final: prev: (import ./lib { inherit inputs; lib = final; }));
|
systems = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-darwin"
|
||||||
|
"aarch64-linux"
|
||||||
|
"armv6l-linux"
|
||||||
|
"armv7l-linux"
|
||||||
|
];
|
||||||
|
|
||||||
|
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
|
||||||
|
libExtended = nixpkgs.lib.extend (final: prev:
|
||||||
|
(import ./lib {
|
||||||
|
inherit inputs;
|
||||||
|
lib = final;
|
||||||
|
}));
|
||||||
|
|
||||||
hostDefaultConfig = {
|
hostDefaultConfig = {
|
||||||
# Stallman-senpai will be disappointed.
|
# Stallman-senpai will be disappointed.
|
||||||
@ -39,37 +53,38 @@
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
userDefaultConfig = {
|
userDefaultConfig = { system = "x86_64-linux"; };
|
||||||
system = "x86_64-linux";
|
|
||||||
};
|
|
||||||
in {
|
in {
|
||||||
# Exposes only my library with the custom functions to make it easier to include in other flakes.
|
# Exposes only my library with the custom functions to make it easier to include in other flakes.
|
||||||
lib = import ./lib { inherit inputs; lib = nixpkgs.lib; };
|
lib = import ./lib {
|
||||||
|
inherit inputs;
|
||||||
|
lib = nixpkgs.lib;
|
||||||
|
};
|
||||||
|
|
||||||
# A list of NixOS configurations from the `./hosts` folder.
|
# A list of NixOS configurations from the `./hosts` folder.
|
||||||
# It also has some sensible default configurations.
|
# It also has some sensible default configurations.
|
||||||
nixosConfigurations =
|
nixosConfigurations = libExtended.mapAttrs
|
||||||
libExtended.mapAttrs (host: path: libExtended.mkHost path hostDefaultConfig) (libExtended.filesToAttr ./hosts);
|
(host: path: libExtended.mkHost path hostDefaultConfig)
|
||||||
|
(libExtended.filesToAttr ./hosts);
|
||||||
|
|
||||||
# We're going to make our custom modules available for our flake. Whether
|
# We're going to make our custom modules available for our flake. Whether
|
||||||
# or not this is a good thing is debatable, I just want to test it.
|
# or not this is a good thing is debatable, I just want to test it.
|
||||||
nixosModules =
|
nixosModules = libExtended.mapAttrs (_: path: import path)
|
||||||
libExtended.mapAttrs (_: path: import path) (libExtended.filesToAttr ./modules);
|
(libExtended.filesToAttr ./modules);
|
||||||
|
|
||||||
homeConfigurations =
|
homeConfigurations = let
|
||||||
let
|
|
||||||
excludedModules = [
|
excludedModules = [
|
||||||
"config" # The common user-specific configurations.
|
"config" # The common user-specific configurations.
|
||||||
"modules" # User-specific Nix modules.
|
"modules" # User-specific Nix modules.
|
||||||
];
|
];
|
||||||
in
|
in libExtended.mapAttrs (user: path:
|
||||||
libExtended.mapAttrs (user: path:
|
|
||||||
home-manager.lib.homeManagerConfiguration {
|
home-manager.lib.homeManagerConfiguration {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
configuration = import path;
|
configuration = import path;
|
||||||
homeDirectory = "/home/${user}";
|
homeDirectory = "/home/${user}";
|
||||||
username = user;
|
username = user;
|
||||||
})
|
}) (libExtended.filterAttrs (n: v: !libExtended.elem n excludedModules)
|
||||||
(libExtended.filterAttrs (n: v: !libExtended.elem n excludedModules) (libExtended.filesToAttr ./users));
|
(libExtended.filesToAttr ./users));
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
12
hosts/README.adoc
Normal file
12
hosts/README.adoc
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
= Host-specific configuration
|
||||||
|
:toc:
|
||||||
|
|
||||||
|
These are configurations that are specific to a machine (e.g., desktop, servers, VM, containers).
|
||||||
|
Ideally, it should be made minimal as much as possible considering you also have to manage your users.
|
||||||
|
|
||||||
|
For managing users, there are multiple ways to manage them with this config:
|
||||||
|
|
||||||
|
* The usual `users.users.${user}` from system configuration (see `man configuration.nix.5`).
|
||||||
|
|
||||||
|
* Modularize them (see link:../users/README.adoc[User-specific configuration] for more information).
|
||||||
|
If you have user-specific configs in set, you have to manage them with link:../modules/users.nix[`modules.users.users`] which is my implementation of managing users (e.g., `modules.users.users = [ "foo-dogsquared" ]`).
|
@ -21,6 +21,7 @@
|
|||||||
dev = {
|
dev = {
|
||||||
enable = true;
|
enable = true;
|
||||||
shell.enable = true;
|
shell.enable = true;
|
||||||
|
virtualization.enable = true;
|
||||||
};
|
};
|
||||||
editors = {
|
editors = {
|
||||||
emacs.enable = true;
|
emacs.enable = true;
|
||||||
|
@ -42,8 +42,8 @@ modules/
|
|||||||
dev = path/to/dev.nix;
|
dev = path/to/dev.nix;
|
||||||
editors = path/to/editors.nix;
|
editors = path/to/editors.nix;
|
||||||
specific = {
|
specific = {
|
||||||
borg = path/to/specific/borg.nix
|
borg = path/to/specific/borg.nix;
|
||||||
prometheus = path/to/specific/prometheus.nix
|
prometheus = path/to/specific/prometheus.nix;
|
||||||
};
|
};
|
||||||
themes = path/to/themes; # Since it has a 'default.nix' detected, we're using it instead.
|
themes = path/to/themes; # Since it has a 'default.nix' detected, we're using it instead.
|
||||||
users = path/to/users.nix;
|
users = path/to/users.nix;
|
||||||
|
@ -10,9 +10,12 @@ let
|
|||||||
|
|
||||||
mkUser = user: path:
|
mkUser = user: path:
|
||||||
let
|
let
|
||||||
|
userModule = import path;
|
||||||
defaultConfig = {
|
defaultConfig = {
|
||||||
home.username = user;
|
home.username = user;
|
||||||
home.homeDirectory = "/home/${user}";
|
home.homeDirectory = "/home/${user}";
|
||||||
|
|
||||||
|
xdg.enable = true;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@ -20,8 +23,7 @@ let
|
|||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
extraGroups = [ "wheel" ];
|
extraGroups = [ "wheel" ];
|
||||||
};
|
};
|
||||||
|
home-manager.users.${user} = userModule // defaultConfig;
|
||||||
home-manager.users.${user} = defaultConfig // import path;
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -19,3 +19,36 @@ Here's an example of a sample user config placed in `users/hello.nix`.
|
|||||||
----
|
----
|
||||||
|
|
||||||
This is to be imported to `homeManagerConfiguration` in the flake outputs and when indicated from `config.modules.users.users` (e.g., `modules.users.users = [ "hello" ];`).
|
This is to be imported to `homeManagerConfiguration` in the flake outputs and when indicated from `config.modules.users.users` (e.g., `modules.users.users = [ "hello" ];`).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
== Modules
|
||||||
|
|
||||||
|
There are also user modules (in link:./modules[`./modules`]) that are imported to use with home-manager, allowing you to extend it as you wish.
|
||||||
|
It works just like link:https://github.com/nix-community/home-manager/tree/master/modules[home-manager modules].
|
||||||
|
|
||||||
|
For easier identification, it should be stored with `modules` as the top-level attribute (e.g., `modules.alacritty`, `modules.i18n`).
|
||||||
|
|
||||||
|
Here's an example user module that simply ports my Alacritty config.
|
||||||
|
|
||||||
|
[source, nix]
|
||||||
|
----
|
||||||
|
{ config, options, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.modules.alacritty;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.modules.alacritty.enable = lib.mkEnableOption "Ports my Alacritty configuration.";
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
home.packages = with pkgs; [ alacritty ];
|
||||||
|
xdg.configFile."alacritty" = {
|
||||||
|
source = ../config/alacritty
|
||||||
|
recursive = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
----
|
||||||
|
|
||||||
|
@ -1,11 +1,20 @@
|
|||||||
{ config, options, lib, pkgs, ... }:
|
{ config, options, lib, pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
programs.direnv.enable = true;
|
fonts.fontconfig.enable = true;
|
||||||
|
|
||||||
|
# My specific usual stuff.
|
||||||
programs.git = {
|
programs.git = {
|
||||||
enable = true;
|
enable = true;
|
||||||
lfs.enable = true;
|
lfs.enable = true;
|
||||||
userName = "foo-dogsquared";
|
userName = "foo-dogsquared";
|
||||||
userEmail = "foo.dogsquared@gmail.com";
|
userEmail = "foo.dogsquared@gmail.com";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# My custom modules.
|
||||||
|
modules = {
|
||||||
|
alacritty.enable = true;
|
||||||
|
i18n.enable = true;
|
||||||
|
dev.enable = true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
16
users/modules/alacritty.nix
Normal file
16
users/modules/alacritty.nix
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{ config, options, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.modules.alacritty;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.modules.alacritty.enable = lib.mkEnableOption "Enable Alacritty config";
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
home.packages = with pkgs; [ alacritty ];
|
||||||
|
xdg.configFile."alacritty" = {
|
||||||
|
source = ../config/alacritty/alacritty.yml;
|
||||||
|
recursive = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
34
users/modules/dev.nix
Normal file
34
users/modules/dev.nix
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{ config, options, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.modules.dev;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.modules.dev = {
|
||||||
|
enable = lib.mkEnableOption "Enable my user-specific development setup.";
|
||||||
|
shell.enable = lib.mkEnableOption "Configures my shell of choice.";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||||
|
({
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
neovim # My text editor of choice.
|
||||||
|
lazygit # Git interface for the lazy.
|
||||||
|
fzf # A fuzzy finder that enables fuzzy finding not furry finding, a common misconception.
|
||||||
|
gopass # An improved version of the password manager for hipsters.
|
||||||
|
|
||||||
|
# Coreutils replacement.
|
||||||
|
fd # Oh nice, a more reliable `find`.
|
||||||
|
ripgrep # On nice, a more reliable `grep`.
|
||||||
|
exa # Oh nice, a shinier `ls`.
|
||||||
|
bat # dog > bat > cat
|
||||||
|
];
|
||||||
|
|
||||||
|
programs.direnv = {
|
||||||
|
enable = true;
|
||||||
|
nix-direnv.enable = true;
|
||||||
|
};
|
||||||
|
programs.zoxide.enable = true;
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
}
|
21
users/modules/i18n.nix
Normal file
21
users/modules/i18n.nix
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{ config, options, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.modules.i18n;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.modules.i18n.enable = lib.mkEnableOption "Enable fcitx5 as input method engine.";
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
i18n.inputMethod = {
|
||||||
|
enabled = "fcitx5";
|
||||||
|
fcitx5.addons = with pkgs; [
|
||||||
|
fcitx5-gtk # Add support for GTK-based programs.
|
||||||
|
libsForQt5.fcitx5-qt # Add support for QT-based programs.
|
||||||
|
fcitx5-lua # Add Lua support.
|
||||||
|
fcitx5-rime # Chinese input addon.
|
||||||
|
fcitx5-mozc # Japanese input addon.
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user