refactor(flake, system): improve code structure
Refactor configuration generation - Inherit lib from nixpkgs - Rename functions (mkHome -> makeHome, merge -> forEachHost - Relocate some variables' definitions into config generator functions - Create separate function to track home-manager modules
This commit is contained in:
parent
2f0934d02b
commit
668c2f17c4
35
flake.nix
35
flake.nix
@ -16,49 +16,54 @@
|
||||
|
||||
nethack = {
|
||||
url = git+https://git.psf.lt/xezo360hye/nethack?shallow=1;
|
||||
#url = git+ssh://git@git.psf.lt/xezo360hye/nethack?shallow=1;
|
||||
#url = path:/home/andrey/nethack;
|
||||
};
|
||||
|
||||
# nixpkgs-2405.url = github:nixos/nixpkgs/nixos-24.05;
|
||||
# hm-2405.url = github:nix-community/home-manager/release-24.05;
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, home-manager, nixvim, nethack, ... } @ inputs:
|
||||
let
|
||||
inherit (self) outputs;
|
||||
inherit (nixpkgs) lib;
|
||||
|
||||
username = "andrey";
|
||||
hostnames = [ "tokishiko" "maidena" ];
|
||||
stateVersion = "24.05";
|
||||
|
||||
mkSystem = hostname: {
|
||||
makeSystem = hostname: {
|
||||
"${hostname}" = nixpkgs.lib.nixosSystem {
|
||||
specialArgs = { inherit inputs; };
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
./system/common.nix
|
||||
./system/${hostname}.nix
|
||||
./hardware/${hostname}.nix
|
||||
{
|
||||
system.stateVersion = stateVersion;
|
||||
networking.hostName = hostname;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
mkHome = hostname: {
|
||||
extractModule = { homeManagerModules, ... }: homeManagerModules."${lib.head (lib.attrNames homeManagerModules)}";
|
||||
homeManagerModules = map extractModule [ nixvim nethack ];
|
||||
makeHome = hostname: {
|
||||
"${username}@${hostname}" = home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
extraSpecialArgs = inputs;
|
||||
modules = [
|
||||
nixvim.homeManagerModules.nixvim
|
||||
nethack.homeManagerModules.nethack
|
||||
modules = homeManagerModules ++ [
|
||||
./home/${hostname}.nix
|
||||
./home/common.nix
|
||||
{
|
||||
news.display = "show";
|
||||
home.username = username;
|
||||
home.homeDirectory = "/home/${username}";
|
||||
home.stateVersion = stateVersion;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
merge = fn: nixpkgs.lib.fold nixpkgs.lib.mergeAttrs {} (map fn hostnames);
|
||||
forEachHost = fn: lib.fold lib.mergeAttrs {} (map fn hostnames);
|
||||
in {
|
||||
nixosConfigurations = merge mkSystem;
|
||||
homeConfigurations = merge mkHome;
|
||||
nixosConfigurations = forEachHost makeSystem;
|
||||
homeConfigurations = forEachHost makeHome;
|
||||
};
|
||||
}
|
||||
|
@ -56,7 +56,6 @@
|
||||
};
|
||||
|
||||
|
||||
news.display = "show";
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
|
||||
home = {
|
||||
@ -76,9 +75,5 @@
|
||||
sessionVariables = {
|
||||
ANI_CLI_PLAYER = "mpv";
|
||||
};
|
||||
|
||||
username = "andrey";
|
||||
homeDirectory = "/home/andrey";
|
||||
stateVersion = "24.05";
|
||||
};
|
||||
}
|
||||
|
@ -84,8 +84,4 @@ in
|
||||
tappingDragLock = false;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
# Something important
|
||||
system.stateVersion = "24.05";
|
||||
}
|
||||
|
@ -1,13 +1,4 @@
|
||||
{
|
||||
inputs,
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
networking.hostName = "maidena";
|
||||
|
||||
services = {
|
||||
desktopManager.plasma6.enable = true;
|
||||
displayManager.sddm = {
|
||||
|
@ -1,12 +1,4 @@
|
||||
{
|
||||
inputs,
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
networking.hostName = "tokishiko";
|
||||
console.keyMap = "no";
|
||||
|
||||
services = {
|
||||
|
Loading…
Reference in New Issue
Block a user