Refactor flake structure with flake-parts
This commit is contained in:
parent
8ca6499da1
commit
cf83a45191
10 changed files with 203 additions and 176 deletions
|
|
@ -1,42 +1,37 @@
|
|||
{
|
||||
rootPath,
|
||||
outputs,
|
||||
}: {inputs, ...}: let
|
||||
inputs,
|
||||
lib,
|
||||
self,
|
||||
...
|
||||
}: let
|
||||
rootPath = ./..;
|
||||
inherit (self) outputs;
|
||||
inherit (inputs) nixpkgs;
|
||||
defaultNixosModule = import (rootPath + "/nixos/modules");
|
||||
inherit (inputs.nixpkgs) lib;
|
||||
in {
|
||||
flake = {
|
||||
nixosModules.default = defaultNixosModule;
|
||||
nixosConfigurations = let
|
||||
nixosConfigDir = rootPath + "/nixos/configurations";
|
||||
makeNixConfiguration = hostName:
|
||||
lib.nixosSystem {
|
||||
nixpkgs.lib.nixosSystem {
|
||||
modules =
|
||||
[defaultNixosModule]
|
||||
++ [
|
||||
(
|
||||
let
|
||||
dirPath = nixosConfigDir + "/${hostName}";
|
||||
filePath = nixosConfigDir + "/${hostName}.nix";
|
||||
in
|
||||
if builtins.pathExists dirPath
|
||||
then dirPath
|
||||
else filePath
|
||||
)
|
||||
(rootPath + "/nixos/configurations/${hostName}")
|
||||
];
|
||||
specialArgs = {
|
||||
inherit inputs outputs rootPath;
|
||||
};
|
||||
};
|
||||
in
|
||||
nixosConfigDir
|
||||
|> builtins.readDir
|
||||
|> builtins.attrNames
|
||||
|> map (f: lib.removeSuffix ".nix" f)
|
||||
|> map (name: {
|
||||
inherit name;
|
||||
value = makeNixConfiguration name;
|
||||
})
|
||||
|> builtins.listToAttrs;
|
||||
[
|
||||
"Tytonidae"
|
||||
"Cape"
|
||||
"Akun"
|
||||
]
|
||||
|> (
|
||||
with lib;
|
||||
flip genAttrs makeNixConfiguration
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue