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 = {
|
nethack = {
|
||||||
url = git+https://git.psf.lt/xezo360hye/nethack?shallow=1;
|
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:
|
outputs = { self, nixpkgs, home-manager, nixvim, nethack, ... } @ inputs:
|
||||||
let
|
let
|
||||||
inherit (self) outputs;
|
inherit (self) outputs;
|
||||||
|
inherit (nixpkgs) lib;
|
||||||
|
|
||||||
username = "andrey";
|
username = "andrey";
|
||||||
hostnames = [ "tokishiko" "maidena" ];
|
hostnames = [ "tokishiko" "maidena" ];
|
||||||
|
stateVersion = "24.05";
|
||||||
|
|
||||||
mkSystem = hostname: {
|
makeSystem = hostname: {
|
||||||
"${hostname}" = nixpkgs.lib.nixosSystem {
|
"${hostname}" = nixpkgs.lib.nixosSystem {
|
||||||
specialArgs = { inherit inputs; };
|
specialArgs = { inherit inputs; };
|
||||||
system = "x86_64-linux";
|
|
||||||
modules = [
|
modules = [
|
||||||
./system/common.nix
|
./system/common.nix
|
||||||
./system/${hostname}.nix
|
./system/${hostname}.nix
|
||||||
./hardware/${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 {
|
"${username}@${hostname}" = home-manager.lib.homeManagerConfiguration {
|
||||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
extraSpecialArgs = inputs;
|
modules = homeManagerModules ++ [
|
||||||
modules = [
|
|
||||||
nixvim.homeManagerModules.nixvim
|
|
||||||
nethack.homeManagerModules.nethack
|
|
||||||
./home/${hostname}.nix
|
./home/${hostname}.nix
|
||||||
./home/common.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 {
|
in {
|
||||||
nixosConfigurations = merge mkSystem;
|
nixosConfigurations = forEachHost makeSystem;
|
||||||
homeConfigurations = merge mkHome;
|
homeConfigurations = forEachHost makeHome;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,6 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
news.display = "show";
|
|
||||||
nixpkgs.config.allowUnfree = true;
|
nixpkgs.config.allowUnfree = true;
|
||||||
|
|
||||||
home = {
|
home = {
|
||||||
@ -76,9 +75,5 @@
|
|||||||
sessionVariables = {
|
sessionVariables = {
|
||||||
ANI_CLI_PLAYER = "mpv";
|
ANI_CLI_PLAYER = "mpv";
|
||||||
};
|
};
|
||||||
|
|
||||||
username = "andrey";
|
|
||||||
homeDirectory = "/home/andrey";
|
|
||||||
stateVersion = "24.05";
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -84,8 +84,4 @@ in
|
|||||||
tappingDragLock = false;
|
tappingDragLock = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
# Something important
|
|
||||||
system.stateVersion = "24.05";
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,4 @@
|
|||||||
{
|
{
|
||||||
inputs,
|
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
{
|
|
||||||
networking.hostName = "maidena";
|
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
desktopManager.plasma6.enable = true;
|
desktopManager.plasma6.enable = true;
|
||||||
displayManager.sddm = {
|
displayManager.sddm = {
|
||||||
|
@ -1,12 +1,4 @@
|
|||||||
{
|
{
|
||||||
inputs,
|
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
{
|
|
||||||
networking.hostName = "tokishiko";
|
|
||||||
console.keyMap = "no";
|
console.keyMap = "no";
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
|
Loading…
Reference in New Issue
Block a user