From b8bf494ac1c20e7ef19f8797123bf5ad87b4c8a8 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sat, 21 Oct 2023 20:10:11 +0200 Subject: [PATCH] add top-level flake --- flake.lock | 27 +++++++++++++++++++++ flake.nix | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..fd481ad --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1697793076, + "narHash": "sha256-02e7sCuqLtkyRgrZmdOyvAcQTQdcXj+vpyp9bca6cY4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "038b2922be3fc096e1d456f93f7d0f4090628729", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..5f03ecf --- /dev/null +++ b/flake.nix @@ -0,0 +1,70 @@ +{ + description = "Generic development environment for my projects"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + outputs = { self, nixpkgs }: + let + # overlays = [ + # (final: prev: + # let + # exec = pkg: "${prev.${pkg}}/bin/${pkg}"; + # in + # { + # format = prev.writeScriptBin "format" '' + # ${exec "nixpkgs-fmt"} **/*.nix + # ''; + # dvt = prev.writeScriptBin "dvt" '' + # if [ -z $1 ]; then + # echo "no template specified" + # exit 1 + # fi + + # TEMPLATE=$1 + + # ${exec "nix"} \ + # --experimental-features 'nix-command flakes' \ + # flake init \ + # --template \ + # "github:the-nix-way/dev-templates#''${TEMPLATE}" + # ''; + # update = prev.writeScriptBin "update" '' + # for dir in `ls -d */`; do # Iterate through all the templates + # ( + # cd $dir + # ${exec "nix"} flake update # Update flake.lock + # ${exec "nix"} flake check # Make sure things work after the update + # ) + # done + # ''; + # }) + # ]; + supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { + pkgs = import nixpkgs { inherit system; }; #overlays + }); + in + { + devShells = forEachSupportedSystem ({ pkgs }: { + default = pkgs.mkShell { + packages = with pkgs; [ format update ]; + }; + }); + + packages = forEachSupportedSystem ({ pkgs }: rec { + default = dvt; + inherit (pkgs) dvt; + }); + } + + // + + { + templates = { + terraform = { + path = ./terraform; + description = "Terraform development environment"; + }; + }; + }; +}