Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
# max-parallel: 2
strategy:
matrix:
template: [bogus, minimal, microvm, nvf-standalone]
template: [bogus, minimal, microvm, nvf-standalone, flake-parts-modules]
os: [ubuntu-latest]
name: Check template ${{matrix.template}} ${{matrix.os}}
runs-on: ${{matrix.os}}
Expand Down
2 changes: 2 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ let
microvm.description = "MicroVM example";
nvf-standalone.path = ../templates/nvf-standalone;
nvf-standalone.description = "Standalone NVF";
flake-parts-modules.path = ../templates/flake-parts-modules;
flake-parts-modules.description = "flake-parts classes";
ci.path = ../templates/ci;
ci.description = "Feature Tests";
bogus.path = ../templates/bogus;
Expand Down
2 changes: 1 addition & 1 deletion nix/lib/forward.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let
};

freeformMod = {
config._module.freeformType = lib.types.lazyAttrsOf lib.types.anything;
config._module.freeformType = lib.types.lazyAttrsOf lib.types.unspecified;
};

adapterMods = [
Expand Down
7 changes: 7 additions & 0 deletions templates/flake-parts-modules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Example Den custom classes for flake-parts modules and perSystem outputs.

This example showcases Den forward classes for third-party flake-parts modules.

This README is generated by `nix run .#write-files`.

See den.nix, custom-classes.nix and perSystem-forward.nix
206 changes: 206 additions & 0 deletions templates/flake-parts-modules/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions templates/flake-parts-modules/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
description = "Using flake-parts modules from Den";

outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules);

inputs = {
den.url = "github:vic/den";
import-tree.url = "github:vic/import-tree";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";

pkgs-by-name-for-flake-parts.url = "github:drupol/pkgs-by-name-for-flake-parts";

files.url = "github:mightyiam/files";

devshell.url = "github:numtide/devshell";
devshell.inputs.nixpkgs.follows = "nixpkgs";

treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";

nix-unit.url = "github:nix-community/nix-unit";
nix-unit.inputs = {
nixpkgs.follows = "nixpkgs";
flake-parts.follows = "flake-parts";
nix-github-actions.follows = "";
treefmt-nix.follows = "treefmt-nix";
};

nix-topology.url = "github:oddlama/nix-topology";
nix-topology.inputs = {
nixpkgs.follows = "nixpkgs";
flake-parts.follows = "flake-parts";
};

};
}
94 changes: 94 additions & 0 deletions templates/flake-parts-modules/modules/custom-classes.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
den,
lib,
inputs,
config,
...
}:
{
systems = builtins.attrNames den.hosts;

# Some third-party flake-parts modules for demo purposes.
# Read their documentation at https://flake.parts for usage.
imports = [
inputs.devshell.flakeModule
inputs.files.flakeModules.default
inputs.nix-topology.flakeModule
inputs.nix-unit.modules.flake.default
inputs.pkgs-by-name-for-flake-parts.flakeModule
inputs.treefmt-nix.flakeModule
];

# some globals
perSystem = {
pkgsDirectory = ../packages;
nix-unit = {
allowNetwork = true;
inputs = inputs;
};
};

# den.ctx.flake-parts transformations define which
# custom classes exist and where to read them.
den.ctx.flake-parts.into = _: {

# Read flake-parts classes from hosts and their includes
host = map (host: { inherit host; }) (
builtins.concatMap builtins.attrValues (builtins.attrValues den.hosts)
);

# Our custom flake-parts perSystem classes.
# These are partial params for `den._.forward`.
# See ./perSystem-forward.nix
flake-parts-system = [

# A class for flake-parts' perSystem.packages
# NOTE: this is different from Den's flake-packages class.
{
fromClass = _: "packages";
intoPath = _: [ "packages" ];
}

{
fromClass = _: "files";
intoPath = _: [
"files"
];
adapterModule = { };
}

# a default `devshell` class
{
fromClass = _: "devshell";
intoPath = _: [
"devshells"
"default"
];
}

{
fromClass = _: "treefmt";
intoPath = _: [ "treefmt" ];
}

{
fromClass = _: "tests";
intoPath = _: [
"nix-unit"
"tests"
];
# test helpers
adaptArgs =
{ pkgs, ... }:
let
igloo = config.flake.nixosConfigurations.igloo.config;
tux = igloo.users.users.tux;
in
{
inherit pkgs igloo tux;
};
}
];
};

}
Loading
Loading