mirror of
https://github.com/donovanglover/nix-config.git
synced 2024-11-22 00:03:55 +01:00
flake.nix: Dynamically import nixosConfigurations
This commit is contained in:
parent
30e0239cf7
commit
5f25e19d3f
@ -4,10 +4,7 @@ let
|
||||
inherit (builtins) attrValues;
|
||||
in
|
||||
{
|
||||
imports = attrValues self.nixosModules ++ [
|
||||
./hardware/laptop.nix
|
||||
];
|
||||
|
||||
imports = attrValues self.nixosModules;
|
||||
nixpkgs.overlays = attrValues self.overlays;
|
||||
home-manager.sharedModules = attrValues self.homeManagerModules;
|
||||
environment.systemPackages = attrValues self.packages.${pkgs.system};
|
||||
|
29
flake.nix
29
flake.nix
@ -27,19 +27,11 @@
|
||||
inherit (nixpkgs.legacyPackages.x86_64-linux) nixpkgs-fmt callPackage;
|
||||
inherit (builtins) attrNames listToAttrs map replaceStrings readDir;
|
||||
|
||||
flakeOutputs = [ "overlays" "nixosModules" "homeManagerModules" "packages" "checks" ];
|
||||
flakeDirectories = [ "overlays" "modules" "home" "packages" "tests" ];
|
||||
flakeOutputs = [ "overlays" "nixosModules" "nixosConfigurations" "homeManagerModules" "packages" "checks" ];
|
||||
flakeDirectories = [ "overlays" "modules" "hardware" "home" "packages" "tests" ];
|
||||
in
|
||||
{
|
||||
formatter.x86_64-linux = nixpkgs-fmt;
|
||||
|
||||
nixosConfigurations = {
|
||||
nixos = nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
specialArgs = attrs // { nix-config = self; };
|
||||
modules = [ ./. ];
|
||||
};
|
||||
};
|
||||
} //
|
||||
(listToAttrs
|
||||
(map
|
||||
@ -52,7 +44,10 @@
|
||||
attributeValue = (listToAttrs
|
||||
(map
|
||||
(file: {
|
||||
name = replaceStrings [ ".nix" ] [ "" ] file;
|
||||
name =
|
||||
if file == "laptop.nix"
|
||||
then "nixos"
|
||||
else replaceStrings [ ".nix" ] [ "" ] file;
|
||||
value =
|
||||
if directory == "packages"
|
||||
then callPackage ./${directory}/${file} { }
|
||||
@ -62,7 +57,17 @@
|
||||
inherit self;
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
}
|
||||
else import ./${directory}/${file};
|
||||
else
|
||||
if directory == "hardware"
|
||||
then nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
specialArgs = attrs // { nix-config = self; };
|
||||
modules = [
|
||||
./.
|
||||
./${directory}/${file}
|
||||
];
|
||||
}
|
||||
else import ./${directory}/${file};
|
||||
})
|
||||
(attrNames (readDir ./${directory}))));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user