1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2024-12-14 11:47:31 +00:00

Add multi-module template

This commit is contained in:
Robert Hensing 2022-05-11 23:05:53 +02:00
parent 9aba31a8b5
commit f2e42edb60
3 changed files with 64 additions and 5 deletions

View file

@ -7,11 +7,19 @@
outputs = { self, nixpkgs, ... }: { outputs = { self, nixpkgs, ... }: {
lib = import ./lib.nix { inherit (nixpkgs) lib; }; lib = import ./lib.nix { inherit (nixpkgs) lib; };
defaultTemplate = { templates = {
path = ./template/default; default = {
description = '' path = ./template/default;
A minimal flake using flake-modules-core. description = ''
''; A minimal flake using flake-modules-core.
'';
};
multi-module = {
path = ./template/multi-module;
description = ''
A minimal flake using flake-modules-core.
'';
};
}; };
}; };

View file

@ -0,0 +1,33 @@
{
description = "Description for the project";
inputs = {
flake-modules-core.url = "github:hercules-ci/flake-modules-core";
flake-modules-core.inputs.nixpkgs.follows = "nixpkgs";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, flake-modules-core, ... }:
(flake-modules-core.lib.evalFlakeModule
{ inherit self; }
{
imports = [
./hello/flake-module.nix
];
systems = [ "x86_64-linux" "aarch64-darwin" ];
perSystem = system: { config, self', inputs', ... }: {
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
packages.figlet = inputs'.nixpkgs.legacyPackages.figlet;
};
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
}
).config.flake;
}

View file

@ -0,0 +1,18 @@
# Definitions can be imported from a separate file like this one
{ self, ... }: {
perSystem = system: { config, self', inputs', ... }: {
# Definitions like this are entirely equivalent to the ones
# you may have directly in flake.nix.
packages.hello = inputs'.nixpkgs.legacyPackages.hello;
};
flake = {
nixosModules.hello = { pkgs, ... }: {
environment.systemPackages = [
# or self.inputs.nixpkgs.legacyPackages.${pkgs.stdenv.hostPlatform.system}.hello
self.packages.${pkgs.stdenv.hostPlatform.system}.hello
];
};
};
}