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:
parent
9aba31a8b5
commit
f2e42edb60
3 changed files with 64 additions and 5 deletions
18
flake.nix
18
flake.nix
|
@ -7,11 +7,19 @@
|
|||
|
||||
outputs = { self, nixpkgs, ... }: {
|
||||
lib = import ./lib.nix { inherit (nixpkgs) lib; };
|
||||
defaultTemplate = {
|
||||
path = ./template/default;
|
||||
description = ''
|
||||
A minimal flake using flake-modules-core.
|
||||
'';
|
||||
templates = {
|
||||
default = {
|
||||
path = ./template/default;
|
||||
description = ''
|
||||
A minimal flake using flake-modules-core.
|
||||
'';
|
||||
};
|
||||
multi-module = {
|
||||
path = ./template/multi-module;
|
||||
description = ''
|
||||
A minimal flake using flake-modules-core.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
33
template/multi-module/flake.nix
Normal file
33
template/multi-module/flake.nix
Normal 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;
|
||||
}
|
18
template/multi-module/hello/flake-module.nix
Normal file
18
template/multi-module/hello/flake-module.nix
Normal 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
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue