From cab19ec5cadde6b4af9a99a3504f76127a9a38f7 Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Wed, 7 Aug 2024 18:51:52 -0400 Subject: [PATCH] templates: init --- flake.nix | 1 + templates/default.nix | 15 +++++++++++++++ templates/default/.envrc | 1 + templates/default/flake.nix | 29 +++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 templates/default.nix create mode 100644 templates/default/.envrc create mode 100644 templates/default/flake.nix diff --git a/flake.nix b/flake.nix index 5817d13..052efcb 100644 --- a/flake.nix +++ b/flake.nix @@ -211,6 +211,7 @@ imports = [ ./pkgs ./shell + ./templates inputs.devshell.flakeModule inputs.treefmt-nix.flakeModule ]; diff --git a/templates/default.nix b/templates/default.nix new file mode 100644 index 0000000..d55db48 --- /dev/null +++ b/templates/default.nix @@ -0,0 +1,15 @@ +{ lib, ... }: +let + mkTemplate = name: + let + path = ./. + "/${name}"; + flake = import (path + "/flake.nix"); + in + { inherit path; } + // lib.optionalAttrs (flake ? description) { inherit (flake) description; }; + + templates = lib.attrNames (lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./.)); +in +{ + flake.templates = lib.genAttrs templates mkTemplate; +} diff --git a/templates/default/.envrc b/templates/default/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/templates/default/.envrc @@ -0,0 +1 @@ +use flake diff --git a/templates/default/flake.nix b/templates/default/flake.nix new file mode 100644 index 0000000..cbcac29 --- /dev/null +++ b/templates/default/flake.nix @@ -0,0 +1,29 @@ +{ + description = "My standard flake-parts devshell template"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + devshell.url = "github:numtide/devshell"; + + devshell.inputs.nixpkgs.follows = "nixpkgs"; + flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; + }; + + outputs = inputs: inputs.flake-parts.lib.mkFlake ({ ... }: { + systems = [ "x86_64-linux" ]; + + imports = with inputs; [ + devshell.flakeModule + ]; + + perSystem = { pkgs, ... }: { + devshells.default.devshell = { + name = "template"; + motd = ""; + + packages = with pkgs; [ ]; + }; + }; + }); +}