add top-level flake

This commit is contained in:
Pim Kunis 2023-10-21 20:10:11 +02:00
parent 8e675f17e2
commit b8bf494ac1
2 changed files with 97 additions and 0 deletions

27
flake.lock Normal file
View file

@ -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
}

70
flake.nix Normal file
View file

@ -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";
};
};
};
}