add templates

This commit is contained in:
xenia 2024-12-02 02:11:19 -05:00
parent 984654610a
commit e67fb3b037
2 changed files with 40 additions and 2 deletions

View File

@ -91,7 +91,15 @@
};
setNixpkgsFlakeAlias = lib.mkOption {
description = "Set nix path entry for `nixpkgs` to self";
description = "Set flake registry entry for `nixpkgs` to self";
type = lib.types.bool;
default = true;
defaultText = lib.literalExpression "true";
example = lib.literalExpression "false";
};
setTemplatesFlakeAlias = lib.mkOption {
description = "Set flake registry entry for `templates` to self";
type = lib.types.bool;
default = true;
defaultText = lib.literalExpression "true";
@ -99,12 +107,19 @@
};
};
config.nix.registry.dragnpkgs = lib.mkIf config.dragnpkgs.setFlakeRegistry self.meta.registry-entry;
config.nix.registry.dragnpkgs =
lib.mkIf config.dragnpkgs.setFlakeRegistry self.meta.registry-entry;
config.nix.registry.nixpkgs = lib.mkIf config.dragnpkgs.setNixpkgsFlakeAlias {
from = { id = "nixpkgs"; type = "indirect"; };
to = { id = "dragnpkgs"; type = "indirect"; };
};
config.nix.registry.templates = lib.mkIf config.dragnpkgs.setTemplatesFlakeAlias {
from = { id = "templates"; type = "indirect"; };
to = { id = "dragnpkgs"; type = "indirect"; };
};
config.nix.nixPath = lib.mkIf config.dragnpkgs.setNixPath [
self.meta.path-entry
];
@ -139,5 +154,14 @@
);
nixosModules = nixpkgs.nixosModules;
templates = {
default = {
path = ./templates/default;
description = "A very basic flake (with dragnpkgs)";
};
};
defaultTemplate = self.templates.default;
};
}

View File

@ -0,0 +1,14 @@
{
description = "A very basic flake";
outputs = { self, dragnpkgs } @ inputs: {
packages.hello = { stdenv }: stdenv.mkDerivation {
name = "hello";
src = self;
installPhase = ''
echo TODO
'';
};
};
}