Skip to content

Commit

Permalink
Nix templates (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
sestrella authored Nov 28, 2024
1 parent 043ed4a commit 0cbc808
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 2 deletions.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,66 @@ list of all tasks running on ECS.

## Installation

<details>
<summary>Nix users</summary>

### 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 ];
```

</details>

<details>
<summary>Non-Nix users</summary>

Clone the repository:

```
Expand All @@ -39,6 +99,8 @@ cp iecs ~/.local/bin/iecs
> Check that the path where the binary is copied exists in the `PATH`
> environment variable.

</details>

## References

- https://aws.github.io/aws-sdk-go-v2/docs/getting-started/
Expand Down
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
Expand All @@ -31,7 +31,7 @@
};

overlayAttrs = {
iecs = config.packages.default;
iecs = self'.packages.default;
};
};
};
Expand Down
2 changes: 2 additions & 0 deletions templates/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
devenv.lock
flake.lock
3 changes: 3 additions & 0 deletions templates/devenv/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_url "https://raw.githubusercontent.com/cachix/devenv/82c0147677e510b247d8b9165c54f73d32dfd899/direnvrc" "sha256-7u4iDd1nZpxL4tCzmPG0dQgC5V+/44Ba+tHkPob1v2k="

use devenv
9 changes: 9 additions & 0 deletions templates/devenv/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Devenv
.devenv*
devenv.local.nix

# direnv
.direnv

# pre-commit
.pre-commit-config.yaml
5 changes: 5 additions & 0 deletions templates/devenv/devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ pkgs, ... }:

{
packages = [ pkgs.iecs ];
}
8 changes: 8 additions & 0 deletions templates/devenv/devenv.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions templates/flake-overlay/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
26 changes: 26 additions & 0 deletions templates/flake-overlay/flake.nix
Original file line number Diff line number Diff line change
@@ -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 ];
};
});
};
}
1 change: 1 addition & 0 deletions templates/flake/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
24 changes: 24 additions & 0 deletions templates/flake/flake.nix
Original file line number Diff line number Diff line change
@@ -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 ];
};
});
};
}

0 comments on commit 0cbc808

Please sign in to comment.