add templates

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

View File

@ -91,7 +91,15 @@
}; };
setNixpkgsFlakeAlias = lib.mkOption { 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; type = lib.types.bool;
default = true; default = true;
defaultText = lib.literalExpression "true"; defaultText = lib.literalExpression "true";
@ -99,12 +107,19 @@
}; };
}; };
config.nix.registry.dragnpkgs-unstable = lib.mkIf config.dragnpkgs.setFlakeRegistry self.meta.registry-entry; config.nix.registry.dragnpkgs-unstable =
lib.mkIf config.dragnpkgs.setFlakeRegistry self.meta.registry-entry;
config.nix.registry.nixpkgs = lib.mkIf config.dragnpkgs.setNixpkgsFlakeAlias { config.nix.registry.nixpkgs = lib.mkIf config.dragnpkgs.setNixpkgsFlakeAlias {
from = { id = "nixpkgs"; type = "indirect"; }; from = { id = "nixpkgs"; type = "indirect"; };
to = { id = "dragnpkgs-unstable"; type = "indirect"; }; to = { id = "dragnpkgs-unstable"; type = "indirect"; };
}; };
config.nix.registry.templates = lib.mkIf config.dragnpkgs.setTemplatesFlakeAlias {
from = { id = "templates"; type = "indirect"; };
to = { id = "dragnpkgs-unstable"; type = "indirect"; };
};
config.nix.nixPath = lib.mkIf config.dragnpkgs.setNixPath [ config.nix.nixPath = lib.mkIf config.dragnpkgs.setNixPath [
self.meta.path-entry self.meta.path-entry
]; ];
@ -139,5 +154,14 @@
); );
nixosModules = nixpkgs.nixosModules; 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
'';
};
};
}