forked from pub-solar/os
lib: init mkFlake to create a devos flake
general lib function - not devos specific
This commit is contained in:
parent
01b0555117
commit
a76ca177fd
|
@ -17,6 +17,8 @@ lib.makeExtensible (final:
|
|||
lists = callLibs ./lists.nix;
|
||||
strings = callLibs ./strings.nix;
|
||||
|
||||
mkFlake = callLibs ./mkFlake;
|
||||
|
||||
inherit (attrs) mapFilterAttrs genAttrs' safeReadDir
|
||||
pathsToImportedAttrs concatAttrs filterPackages;
|
||||
inherit (lists) pathsIn;
|
||||
|
|
60
lib/mkFlake/default.nix
Normal file
60
lib/mkFlake/default.nix
Normal file
|
@ -0,0 +1,60 @@
|
|||
{ dev, nixos, inputs, ... }:
|
||||
let
|
||||
inherit (dev) os;
|
||||
inherit (inputs) utils deploy;
|
||||
evalFlakeArgs = dev.callLibs ./evalArgs.nix;
|
||||
in
|
||||
|
||||
{ self, ... } @ args:
|
||||
let
|
||||
|
||||
cfg = (lib.evalFlakeArgs { inherit args; }).config;
|
||||
|
||||
multiPkgs = os.mkPkgs { inherit (cfg) extern overrides; };
|
||||
|
||||
outputs = {
|
||||
nixosConfigurations = os.mkHosts {
|
||||
inherit self multiPkgs;
|
||||
inherit (cfg) extern suites overrides;
|
||||
dir = cfg.hosts;
|
||||
};
|
||||
|
||||
homeConfigurations = os.mkHomeConfigurations;
|
||||
|
||||
nixosModules = cfg.modules;
|
||||
|
||||
homeModules = cfg.userModules;
|
||||
|
||||
overlay = cfg.packages;
|
||||
inherit (cfg) overlays;
|
||||
|
||||
deploy.nodes = os.mkNodes deploy self.nixosConfigurations;
|
||||
};
|
||||
|
||||
systemOutputs = utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = multiPkgs.${system};
|
||||
# all packages that are defined in ./pkgs
|
||||
legacyPackages = os.mkPackages { inherit pkgs; };
|
||||
in
|
||||
{
|
||||
checks =
|
||||
let
|
||||
tests = nixos.lib.optionalAttrs (system == "x86_64-linux")
|
||||
(import "${self}/tests" { inherit self pkgs; });
|
||||
deployHosts = nixos.lib.filterAttrs
|
||||
(n: _: self.nixosConfigurations.${n}.config.nixpkgs.system == system) self.deploy.nodes;
|
||||
deployChecks = deploy.lib.${system}.deployChecks { nodes = deployHosts; };
|
||||
in
|
||||
nixos.lib.recursiveUpdate tests deployChecks;
|
||||
|
||||
inherit legacyPackages;
|
||||
packages = dev.filterPackages system legacyPackages;
|
||||
|
||||
devShell = import "${self}/shell" {
|
||||
inherit self system;
|
||||
};
|
||||
});
|
||||
in
|
||||
outputs // systemOutputs
|
||||
|
Loading…
Reference in a new issue