mirror of
https://github.com/nix-community/nixos-generators.git
synced 2024-10-26 11:39:05 +03:00
flake: export formats as nixosModules
This commit is contained in:
parent
23143c87be
commit
afab4671b8
@ -6,6 +6,14 @@
|
||||
outputs = { self, nixpkgs }: let
|
||||
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" "x86_64-darwin" "i686-linux" "aarch64-linux" ];
|
||||
in {
|
||||
|
||||
# export all generator formats in ./formats
|
||||
nixosModules = nixpkgs.lib.mapAttrs' (file: _: {
|
||||
name = nixpkgs.lib.removeSuffix ".nix" file;
|
||||
# The exported module should include the internal format* options
|
||||
value.imports = [ (./formats + "/${file}") ./format-module.nix ];
|
||||
}) (builtins.readDir ./formats);
|
||||
|
||||
# Packages
|
||||
packages = forAllSystems (system: let
|
||||
pkgs = nixpkgs.legacyPackages."${system}";
|
||||
|
14
format-module.nix
Normal file
14
format-module.nix
Normal file
@ -0,0 +1,14 @@
|
||||
{ lib, ... }: {
|
||||
options = {
|
||||
filename = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Declare the path of the wanted file in the output directory";
|
||||
default = "*";
|
||||
};
|
||||
formatAttr = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Declare the default attribute to build";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -8,19 +8,7 @@
|
||||
, flakeAttr ? null
|
||||
}:
|
||||
let
|
||||
module = { lib, ... }: {
|
||||
options = {
|
||||
filename = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Declare the path of the wanted file in the output directory";
|
||||
default = "*";
|
||||
};
|
||||
formatAttr = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Declare the default attribute to build";
|
||||
};
|
||||
};
|
||||
};
|
||||
module = import ./format-module.nix;
|
||||
|
||||
# Will only get evaluated when used, so no worries
|
||||
flake = builtins.getFlake flakeUri;
|
||||
|
Loading…
Reference in New Issue
Block a user