Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
A minimal flake using flake-parts importing nixpkgs with the unfree option.
'';
};
dogfood = {
path = ./template/dogfood;
description = ''
A minimal flake using flake-parts creating flake modules to build its own outputs.
'';
};
};
flakeModules = {
easyOverlay = ./extras/easyOverlay.nix;
Expand Down
1 change: 1 addition & 0 deletions template/dogfood/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.direnv/
20 changes: 20 additions & 0 deletions template/dogfood/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
description = "Description for the project";

inputs = {
nixpkgs_22_11.url = "github:NixOS/nixpkgs/nixos-22.11";
};

outputs = { flake-parts, self, nixpkgs, ... }@inputs:
flake-parts.lib.mkFlake
{
inherit inputs;
moduleLocation = ./flake.nix;
}
{
imports = [
./modules/anotherFlakeModule.nix
./modules/dev.nix
];
};
}
8 changes: 8 additions & 0 deletions template/dogfood/modules/anotherFlakeModule.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{inputs, ...}: {
imports = [
inputs.flake-parts.flakeModules.flakeModules
];
flake.flakeModules.anotherFlakeModule = {
# Define another flake module here
};
}
27 changes: 27 additions & 0 deletions template/dogfood/modules/dev.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{flake-parts-lib, lib, inputs, ...}@topLevel:
rec {
imports = [
inputs.flake-parts.flakeModules.flakeModules
flake.flakeModules.dev

# Use file name to dogfood a flake module defined from the current flake to avoid infinite recursion
./hello.nix
];
flake.flakeModules.dev = dev: {
imports = lib.lists.optionals (topLevel.moduleLocation != dev.moduleLocation) [
# Use attributes to reference the flake module from other flakes
topLevel.config.flake.flakeModules.hello
];

config.systems = [ "x86_64-linux" "aarch64-darwin" ];

options.perSystem = flake-parts-lib.mkPerSystemOption ({pkgs, ...}@perSystem: {
devShells.default = pkgs.mkShell {
buildInputs = [ perSystem.config.packages.hello_22_11 ];
shellHook = ''
hello
'';
};
});
};
}
14 changes: 14 additions & 0 deletions template/dogfood/modules/hello.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{inputs, flake-parts-lib, ...}:
rec {
imports = [
inputs.flake-parts.flakeModules.flakeModules
flake.flakeModules.hello
];

flake.flakeModules.hello = {
options.perSystem = flake-parts-lib.mkPerSystemOption ({ system, ... }: {
packages.hello_22_11 =
inputs.nixpkgs_22_11.legacyPackages.${system}.hello;
});
};
}