From 0cbc8086dbc35b12e44f5472444a15a53b13d276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Estrella?= <2049686+sestrella@users.noreply.github.com> Date: Thu, 28 Nov 2024 01:23:27 -0500 Subject: [PATCH] Nix templates (#5) --- README.md | 62 +++++++++++++++++++++++++++++++ flake.nix | 4 +- templates/.gitignore | 2 + templates/devenv/.envrc | 3 ++ templates/devenv/.gitignore | 9 +++++ templates/devenv/devenv.nix | 5 +++ templates/devenv/devenv.yaml | 8 ++++ templates/flake-overlay/.envrc | 1 + templates/flake-overlay/flake.nix | 26 +++++++++++++ templates/flake/.envrc | 1 + templates/flake/flake.nix | 24 ++++++++++++ 11 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 templates/.gitignore create mode 100644 templates/devenv/.envrc create mode 100644 templates/devenv/.gitignore create mode 100644 templates/devenv/devenv.nix create mode 100644 templates/devenv/devenv.yaml create mode 100644 templates/flake-overlay/.envrc create mode 100644 templates/flake-overlay/flake.nix create mode 100644 templates/flake/.envrc create mode 100644 templates/flake/flake.nix diff --git a/README.md b/README.md index 6679eef..b76844d 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,66 @@ list of all tasks running on ECS. ## Installation +
+Nix users + +### devenv + +Add the project input into the `devenv.yaml` file: + +```yml +inputs: + iecs: + url: github:sestrella/iecs + overlays: + - default +``` + +To install the binary, add it to the `packages` section in the `devenv.nix` +file: + +```nix +packages = [ pkgs.iecs ]; +``` + +### flake + +Add the project input into the `flake.nix` file: + +```nix +inputs.iecs.url = "github:sestrella/iecs/nix_templates"; +``` + +#### Using it as an overlay + +Add the project overlay to `nixpkgs`: + +```nix +pkgs = import nixpkgs { + inherit system; + overlays = [ iecs.overlays.default ]; +}; +``` + +Use the binary as derivation input for creating packages or shells: + +```nix +buildInputs = [ pkgs.iecs ]; +``` + +#### Using it as a package + +Use the binary as derivation input for creating packages or shells: + +```nix +buildInputs = [ iecs.packages.${system}.default ]; +``` + +
+ +
+Non-Nix users + Clone the repository: ``` @@ -39,6 +99,8 @@ cp iecs ~/.local/bin/iecs > Check that the path where the binary is copied exists in the `PATH` > environment variable. +
+ ## References - https://aws.github.io/aws-sdk-go-v2/docs/getting-started/ diff --git a/flake.nix b/flake.nix index 8e434dc..11e2b62 100644 --- a/flake.nix +++ b/flake.nix @@ -17,7 +17,7 @@ systems = import systems; - perSystem = { config, system, pkgs, ... }: { + perSystem = { self', pkgs, system, ... }: { _module.args.pkgs = import nixpkgs { inherit system; overlays = [ gomod2nix.overlays.default ]; @@ -31,7 +31,7 @@ }; overlayAttrs = { - iecs = config.packages.default; + iecs = self'.packages.default; }; }; }; diff --git a/templates/.gitignore b/templates/.gitignore new file mode 100644 index 0000000..cb28342 --- /dev/null +++ b/templates/.gitignore @@ -0,0 +1,2 @@ +devenv.lock +flake.lock diff --git a/templates/devenv/.envrc b/templates/devenv/.envrc new file mode 100644 index 0000000..894571b --- /dev/null +++ b/templates/devenv/.envrc @@ -0,0 +1,3 @@ +source_url "https://raw.githubusercontent.com/cachix/devenv/82c0147677e510b247d8b9165c54f73d32dfd899/direnvrc" "sha256-7u4iDd1nZpxL4tCzmPG0dQgC5V+/44Ba+tHkPob1v2k=" + +use devenv diff --git a/templates/devenv/.gitignore b/templates/devenv/.gitignore new file mode 100644 index 0000000..4d058db --- /dev/null +++ b/templates/devenv/.gitignore @@ -0,0 +1,9 @@ +# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml diff --git a/templates/devenv/devenv.nix b/templates/devenv/devenv.nix new file mode 100644 index 0000000..6243b86 --- /dev/null +++ b/templates/devenv/devenv.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: + +{ + packages = [ pkgs.iecs ]; +} diff --git a/templates/devenv/devenv.yaml b/templates/devenv/devenv.yaml new file mode 100644 index 0000000..ac34342 --- /dev/null +++ b/templates/devenv/devenv.yaml @@ -0,0 +1,8 @@ +# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json +inputs: + iecs: + url: github:sestrella/iecs + overlays: + - default + nixpkgs: + url: github:cachix/devenv-nixpkgs/rolling diff --git a/templates/flake-overlay/.envrc b/templates/flake-overlay/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/templates/flake-overlay/.envrc @@ -0,0 +1 @@ +use flake diff --git a/templates/flake-overlay/flake.nix b/templates/flake-overlay/flake.nix new file mode 100644 index 0000000..469e43a --- /dev/null +++ b/templates/flake-overlay/flake.nix @@ -0,0 +1,26 @@ +{ + inputs = { + iecs.url = "github:sestrella/iecs"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + systems.url = "github:nix-systems/default"; + }; + + outputs = { iecs, nixpkgs, systems, ... }: + let + eachSystem = nixpkgs.lib.genAttrs (import systems); + in + { + devShells = eachSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ iecs.overlays.default ]; + }; + in + { + default = pkgs.mkShell { + buildInputs = [ pkgs.iecs ]; + }; + }); + }; +} diff --git a/templates/flake/.envrc b/templates/flake/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/templates/flake/.envrc @@ -0,0 +1 @@ +use flake diff --git a/templates/flake/flake.nix b/templates/flake/flake.nix new file mode 100644 index 0000000..bf25c3a --- /dev/null +++ b/templates/flake/flake.nix @@ -0,0 +1,24 @@ +{ + inputs = { + iecs.url = "github:sestrella/iecs"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + systems.url = "github:nix-systems/default"; + }; + + outputs = { iecs, nixpkgs, systems, ... }: + let + eachSystem = nixpkgs.lib.genAttrs (import systems); + in + { + devShells = eachSystem (system: + let + iecsPkgs = iecs.packages.${system}; + pkgs = nixpkgs.legacyPackages.${system}; + in + { + default = pkgs.mkShell { + buildInputs = [ iecsPkgs.default ]; + }; + }); + }; +}