1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-30 11:37:44 +00:00

Clean: Clean flake.nix

This commit is contained in:
RGBCube 2023-05-03 13:39:22 +03:00
parent 6d5003935c
commit 0af238c15b

View file

@ -25,36 +25,40 @@
... ...
}: }:
let let
lib = nixpkgs.lib; importConfiguration = directory:
importConfiguration = directory: { let
nixosConfigurations.${builtins.baseNameOf directory} = hostPlatform = import (directory + "/platform.nix");
let # The folder name is the host name of the machine.
hostPlatform = import (directory + "/platform.nix"); hostName = builtins.baseNameOf directory;
in userName = import (directory + "/username.nix");
lib.nixosSystem { in
{
nixosConfigurations.${hostName} = nixpkgs.lib.nixosSystem {
specialArgs = { specialArgs = {
inherit lib; lib = nixpkgs.lib;
pkgs = import nixpkgs { pkgs = import nixpkgs {
system = hostPlatform; system = hostPlatform;
config.allowUnfree = true; config.allowUnfree = true;
}; };
# Helper function for DRY.
homeManagerConfiguration = attrs: { homeManagerConfiguration = attrs: {
home-manager.users.${import (directory + "/username.nix")} = attrs; home-manager.users.${userName} = attrs;
}; };
}; };
modules = [ modules = [
directory directory
home-manager.nixosModules.home-manager
# Extra configuration derived from the metadata.
{ {
networking.hostName = builtins.baseNameOf directory; networking.hostName = builtins.baseNameOf directory;
nixpkgs.hostPlatform = hostPlatform; nixpkgs.hostPlatform = hostPlatform;
}
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
} }
@ -62,6 +66,7 @@
}; };
}; };
in in
# Basically imports all machines in ./machines/.
builtins.foldl' lib.recursiveUpdate {} (builtins.map importConfiguration [ builtins.foldl' lib.recursiveUpdate {} (builtins.map importConfiguration [
./machines/asus # HACK: Use a function to list the directory. ./machines/asus # HACK: Use a function to list the directory.
]); ]);