From 863f8b69be7cb7d4cb4e793c031b5d60f0fc97d0 Mon Sep 17 00:00:00 2001 From: "Yang, Bo" Date: Fri, 3 Nov 2023 14:48:37 +0000 Subject: [PATCH] Add a dev flake --- template/dogfood/.envrc | 1 + template/dogfood/.gitignore | 1 + template/dogfood/dev/flake.nix | 11 +++++++++++ template/dogfood/flake.nix | 23 +++++++++++++---------- template/dogfood/modules/dev.nix | 20 ++++++++++++++++++++ template/dogfood/modules/dogfood.nix | 23 ----------------------- 6 files changed, 46 insertions(+), 33 deletions(-) create mode 100644 template/dogfood/.envrc create mode 100644 template/dogfood/.gitignore create mode 100644 template/dogfood/dev/flake.nix create mode 100644 template/dogfood/modules/dev.nix delete mode 100644 template/dogfood/modules/dogfood.nix diff --git a/template/dogfood/.envrc b/template/dogfood/.envrc new file mode 100644 index 0000000..4804957 --- /dev/null +++ b/template/dogfood/.envrc @@ -0,0 +1 @@ +use flake ./dev --no-write-lock-file --show-trace \ No newline at end of file diff --git a/template/dogfood/.gitignore b/template/dogfood/.gitignore new file mode 100644 index 0000000..0474498 --- /dev/null +++ b/template/dogfood/.gitignore @@ -0,0 +1 @@ +/.direnv/ \ No newline at end of file diff --git a/template/dogfood/dev/flake.nix b/template/dogfood/dev/flake.nix new file mode 100644 index 0000000..89c9168 --- /dev/null +++ b/template/dogfood/dev/flake.nix @@ -0,0 +1,11 @@ +{ + description = "The dev flake to set up the devShell. It dogfoods modules provided by the public flake"; + + inputs = { + public.url = "path:.."; + nixpkgs.follows = "public/nixpkgs"; + flake-parts.follows = "public/flake-parts"; + }; + + outputs = { public, flake-parts, nixpkgs, self, ... }@inputs: flake-parts.lib.mkFlake { inherit inputs; } public.flakeModules.dev; +} diff --git a/template/dogfood/flake.nix b/template/dogfood/flake.nix index 86350d4..60edd9e 100644 --- a/template/dogfood/flake.nix +++ b/template/dogfood/flake.nix @@ -5,14 +5,17 @@ nixpkgs_22_11.url = "github:NixOS/nixpkgs/nixos-22.11"; }; - outputs = { flake-parts, self, ... }@inputs: let - bootstrap = - flake-parts.lib.mkFlake - { - inherit inputs; - moduleLocation = ./flake.nix; - } - ./modules/dogfood.nix; - in - flake-parts.lib.mkFlake { inherit inputs; } bootstrap.flakeModules.dogfood; + outputs = { flake-parts, self, nixpkgs, ... }@inputs: + flake-parts.lib.mkFlake + { + inherit inputs; + moduleLocation = ./flake.nix; + } + { + imports = [ + ./modules/anotherFlakeModule.nix + ./modules/dev.nix + ./modules/hello.nix + ]; + }; } diff --git a/template/dogfood/modules/dev.nix b/template/dogfood/modules/dev.nix new file mode 100644 index 0000000..4682d9f --- /dev/null +++ b/template/dogfood/modules/dev.nix @@ -0,0 +1,20 @@ +{flake-parts-lib, lib, inputs, ...}@topLevel: { + imports = [ + ./hello.nix + inputs.flake-parts.flakeModules.flakeModules + ]; + flake.flakeModules.dev = { + config.systems = [ "x86_64-linux" "aarch64-darwin" ]; + imports = [ + topLevel.config.flake.flakeModules.hello + ]; + options.perSystem = flake-parts-lib.mkPerSystemOption ({pkgs, ...}@perSystem: { + devShells.default = pkgs.mkShell { + buildInputs = [ perSystem.config.packages.hello_22_11 ]; + shellHook = '' + hello + ''; + }; + }); + }; +} diff --git a/template/dogfood/modules/dogfood.nix b/template/dogfood/modules/dogfood.nix deleted file mode 100644 index 7febe02..0000000 --- a/template/dogfood/modules/dogfood.nix +++ /dev/null @@ -1,23 +0,0 @@ -{flake-parts-lib, lib, inputs, ...}@topLevel: { - imports = [ - ./hello.nix - inputs.flake-parts.flakeModules.flakeModules - ]; - flake.flakeModules.dogfood = { - config.systems = [ "x86_64-linux" "aarch64-darwin" ]; - imports = [ - topLevel.config.flake.flakeModules.hello - - # Expose flake modules - ./dogfood.nix - ./hello.nix - ./anotherFlakeModule.nix - ]; - options.perSystem = flake-parts-lib.mkPerSystemOption (perSystem: { - apps.default = { - type = "app"; - program = "${perSystem.config.packages.hello_22_11}/bin/hello"; - }; - }); - }; -}