Skip to content

Commit

Permalink
Implement binary caching (ALT-F4-LLC#56)
Browse files Browse the repository at this point in the history
* feat(workflows): setup caching for all builds

* fix(workflows): added nix develop prefix

* fix(workflows)

* chore(format)

* docs(README)

* feature(templates): nestjs template (ALT-F4-LLC#54)

* Swift Template (ALT-F4-LLC#55)

* feat(swift): begin building swiftpm executable template

* feat(swift): make the build work wooooo!

* feat(swiftpm): add missing docs & CI tasks

* fix(ci): swiftpm, not swift

* fix(ci): include example-swiftpm in flake

* chore(format)

* docs(README)

* chore(format)

---------

Co-authored-by: Daniel Snetcov <[email protected]>
Co-authored-by: Hayden <[email protected]>
  • Loading branch information
3 people authored Mar 1, 2024
1 parent 9f97b9a commit 714aee8
Show file tree
Hide file tree
Showing 39 changed files with 1,065 additions and 936 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/flake-home-manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ jobs:
runs-on: macos-latest
steps:
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: extractions/setup-just@v1
- uses: cachix/cachix-action@v12
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
name: altf4llc-os
- uses: actions/checkout@v3
- run: just build-home-manager "x86_64-darwin"
- run: cachix use "altf4llc-os"
- run: nix develop -c just cache-build 'build-home-manager "x86_64-darwin"'

linux:
runs-on: ubuntu-latest
steps:
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: extractions/setup-just@v1
- uses: cachix/cachix-action@v12
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
name: altf4llc-os
- uses: actions/checkout@v3
- run: just build-home-manager "x86_64-linux"
- run: cachix use "altf4llc-os"
- run: nix develop -c just cache-build 'build-home-manager "x86_64-linux"'
18 changes: 12 additions & 6 deletions .github/workflows/flake-language.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ jobs:
- zig
steps:
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: extractions/setup-just@v1
- uses: cachix/cachix-action@v12
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
name: altf4llc-os
- uses: actions/checkout@v3
- run: just build-language "${{ matrix.template }}" "default"
- run: cachix use "altf4llc-os"
- run: nix develop -c just cache-build 'build-language "${{ matrix.template }}" "default"'

docker:
runs-on: ubuntu-latest
Expand All @@ -56,7 +59,10 @@ jobs:
- zig
steps:
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: extractions/setup-just@v1
- uses: cachix/cachix-action@v12
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
name: altf4llc-os
- uses: actions/checkout@v3
- run: just build-language "${{ matrix.template }}" "docker"
- run: cachix use "altf4llc-os"
- run: nix develop -c just cache-build 'build-language "${{ matrix.template }}" "docker"'
27 changes: 18 additions & 9 deletions .github/workflows/flake-system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ jobs:
runs-on: macos-latest
steps:
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: extractions/setup-just@v1
- uses: cachix/cachix-action@v12
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
name: altf4llc-os
- uses: actions/checkout@v3
- run: just build-darwin "x86_64"
- run: cachix use "altf4llc-os"
- run: nix develop -c just cache-build 'build-darwin "x86_64"'

nixos-desktop:
strategy:
Expand All @@ -25,16 +28,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: extractions/setup-just@v1
- uses: cachix/cachix-action@v12
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
name: altf4llc-os
- uses: actions/checkout@v3
- run: just build-nixos-desktop "x86_64" ${{ matrix.desktop }}
- run: cachix use "altf4llc-os"
- run: nix develop -c just cache-build 'build-nixos-desktop "x86_64" "${{ matrix.desktop }}"'

nixos-minimal:
runs-on: ubuntu-latest
steps:
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: extractions/setup-just@v1
- uses: cachix/cachix-action@v12
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
name: altf4llc-os
- uses: actions/checkout@v3
- run: just build-nixos-minimal "x86_64"
- run: cachix use "altf4llc-os"
- run: nix develop -c just cache-build 'build-nixos-minimal "x86_64"'
10 changes: 8 additions & 2 deletions .github/workflows/flake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: cachix/cachix-action@v12
with:
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
name: altf4llc-os
- uses: actions/checkout@v3
- run: nix flake check
- run: cachix use "altf4llc-os"
- run: nix develop -c just check
- run: nix develop -c just cache-inputs
- run: nix develop -c just cache-shell
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ Kickstart your Nix environments.
- Languages
- [Bash](#bash)
- [C++ (cmake)](#cpp-cmake)
- [Dart](#dart)
- [Go (module)](#go-module)
- [Go (package)](#go-package)
- [Haskell](#haskell)
- [Lua (application)](#lua-application)
- [Node.js (backend)](#nodejs-backend)
- [NestJS](#nestjs)
- [Node.js (backend)](#nodejs-backend)
- [OCaml](#ocaml)
- [Powershell](#powershell)
- [Python (application)](#python-application)
- [Python (package)](#python-package)
- [Rust](#rust)
- [Swift](#swift)
- [Dart](#dart)
- [Zig](#zig)
- [Haskell](#haskell)

- Systems
- Linux
Expand Down Expand Up @@ -301,6 +301,14 @@ Used for C++ projects using CMake as a build system.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#cpp-cmake
```

#### Dart

Used for Dart applications.

```bash
nix flake init -t github:ALT-F4-LLC/kickstart.nix#dart
```

#### Go (module)

Used for modern Go apps setup with `go.mod` system. To build legacy Go apps, use `go-pkg` template.
Expand All @@ -323,6 +331,14 @@ Used for legacy Go apps **not** setup with `go.mod` system. To build modern Go a
nix flake init -t github:ALT-F4-LLC/kickstart.nix#go-pkg
```

#### Haskell

Used for Haskell applications.

```bash
nix flake init -t github:ALT-F4-LLC/kickstart.nix#haskell
```

#### Lua (application)

Used for Lua script applications. This template creates a shell script wrapper which executes your Lua code. See `flake.nix` for more.
Expand All @@ -334,13 +350,12 @@ Used for Lua script applications. This template creates a shell script wrapper w
nix flake init -t github:ALT-F4-LLC/kickstart.nix#lua-app
```

#### Node.js (backend)
#### NestJS

Used for Node.js backend applications. The template builds using `npm`, and does
not assume you use TypeScript.
Used for NestJS applications. The template builds using `npm`.

```bash
nix flake init -t github:ALT-F4-LLC/kickstart.nix#nodejs-backend
nix flake init -t github:ALT-F4-LLC/kickstart.nix#nestjs
```

To update your dependencies, install/upgrade them as normal via NPM, then use
Expand All @@ -353,17 +368,13 @@ $ nix shell 'nixpkgs#prefetch-npm-deps' -c prefetch-npm-deps package-lock.json
sha256-nTTzkQEdnwWEQ/3uy8hUbPsRvzM53xuoJHoQhR3E/zk=
```

> [!TIP]
> To add TypeScript, install it with `npm install --save-dev typescript`, add a
> `build` script to `package.json` that calls `tsc`, and then remove
> `dontNpmBuild = true;` from `packages.default` in your Flake.
#### NestJS
#### Node.js (backend)

Used for NestJS applications. The template builds using `npm`.
Used for Node.js backend applications. The template builds using `npm`, and does
not assume you use TypeScript.

```bash
nix flake init -t github:ALT-F4-LLC/kickstart.nix#nestjs
nix flake init -t github:ALT-F4-LLC/kickstart.nix#nodejs-backend
```

To update your dependencies, install/upgrade them as normal via NPM, then use
Expand All @@ -376,6 +387,11 @@ $ nix shell 'nixpkgs#prefetch-npm-deps' -c prefetch-npm-deps package-lock.json
sha256-nTTzkQEdnwWEQ/3uy8hUbPsRvzM53xuoJHoQhR3E/zk=
```

> [!TIP]
> To add TypeScript, install it with `npm install --save-dev typescript`, add a
> `build` script to `package.json` that calls `tsc`, and then remove
> `dontNpmBuild = true;` from `packages.default` in your Flake.
#### OCaml

Used for OCaml applications.
Expand Down Expand Up @@ -436,14 +452,6 @@ swiftpm2nix

Then build again.

#### Dart

Used for Dart applications.

```bash
nix flake init -t github:ALT-F4-LLC/kickstart.nix#dart
```

#### Zig

Used for Zig applications.
Expand All @@ -452,14 +460,6 @@ Used for Zig applications.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#zig
```

#### Haskell

Used for Haskell applications.

```bash
nix flake init -t github:ALT-F4-LLC/kickstart.nix#haskell
```

### Systems

#### Home Manager
Expand Down
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 21 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

outputs = inputs@{ flake-parts, self, ... }:
let
lib = import ./lib { inherit inputs; };
in
flake-parts.lib.mkFlake { inherit inputs; } {
outputs = inputs @ {
flake-parts,
self,
...
}: let
lib = import ./lib {inherit inputs;};
in
flake-parts.lib.mkFlake {inherit inputs;} {
flake = {
templates = {
bash = {
Expand Down Expand Up @@ -112,13 +115,24 @@
};
};

perSystem = { config, self', inputs', pkgs, system, ... }: {
systems = ["aarch64-darwin" "aarch64-linux" "x86_64-linux" "x86_64-darwin"];

perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: {
devShells = {
default = pkgs.mkShell {
buildInputs = with pkgs; [ just jq ];
buildInputs = with pkgs; [just jq];
};
};

formatter = pkgs.alejandra;

packages = {
example-bash = lib.flake.bash system;
example-cpp-cmake = lib.flake.cpp-cmake system;
Expand All @@ -144,7 +158,5 @@
example-haskell = lib.flake.haskell system;
};
};

systems = [ "aarch64-darwin" "aarch64-linux" "x86_64-linux" "x86_64-darwin" ];
};
}
Loading

0 comments on commit 714aee8

Please sign in to comment.