diff --git a/flake.nix b/flake.nix index 10d495a..b9c8936 100644 --- a/flake.nix +++ b/flake.nix @@ -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; }; } diff --git a/templates/default/flake.nix b/templates/default/flake.nix new file mode 100644 index 0000000..598b181 --- /dev/null +++ b/templates/default/flake.nix @@ -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 + ''; + }; + }; +}