From 2b9f33af314f4ad849100b93c093ec90e7e7d3d0 Mon Sep 17 00:00:00 2001 From: xenia Date: Mon, 2 Dec 2024 02:11:19 -0500 Subject: [PATCH] add templates --- flake.nix | 28 ++++++++++++++++++++++++++-- templates/default/flake.nix | 14 ++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 templates/default/flake.nix diff --git a/flake.nix b/flake.nix index 0d928c1..3e82b21 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-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 { from = { id = "nixpkgs"; 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 [ 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 + ''; + }; + }; +}