Skip to content

Commit

Permalink
configure nix flakes
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Feb 23, 2024
1 parent e2112f0 commit 2973b46
Show file tree
Hide file tree
Showing 8 changed files with 280 additions and 37 deletions.
44 changes: 32 additions & 12 deletions .fluentci/src/dagger/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ export async function compile(
let command = [
"deno",
"compile",
"--unstable",
"-A",
"--output",
output,
"pocketenv",
"--target",
Deno.env.get("TARGET") || target,
file,
Expand All @@ -180,26 +181,45 @@ export async function compile(
.withExec([
"tar",
"czvf",
`/assets/${output}_${Deno.env.get("TAG") || ""}_${
`/assets/pocketenv_${Deno.env.get("TAG") || ""}_${
Deno.env.get("TARGET") || target
}.tar.gz`,
output,
"pocketenv",
])
.withExec([
"sh",
"-c",
`shasum -a 256 /assets/${output}_${Deno.env.get("TAG") || ""}_${
`shasum -a 256 /assets/pocketenv_${Deno.env.get("TAG") || ""}_${
Deno.env.get("TARGET") || target
}.tar.gz > /assets/${output}_${
Deno.env.get("TAG") || ""
}_${Deno.env.get("TARGET" || target)}.tar.gz.sha256`,
]);

const exe = await ctr.file(`/app/${output}`);
exe.export(`./${output}`);
}.tar.gz > /assets/pocketenv_${Deno.env.get("TAG") || ""}_${
Deno.env.get("TARGET") || target
}.tar.gz.sha256`,
])
.withExec(["sh", "-c", "cp /assets/* /app"]);

const sha256 = await ctr.file(
`/app/pocketenv_${Deno.env.get("TAG") || ""}_${
Deno.env.get("TARGET") || target
}.tar.gz.sha256`
);
const tar = await ctr.file(
`/app/pocketenv_${Deno.env.get("TAG") || ""}_${
Deno.env.get("TARGET") || target
}.tar.gz`
);
tar.export(
`./pocketenv_${Deno.env.get("TAG") || ""}_${
Deno.env.get("TARGET") || target
}.tar.gz`
);
sha256.export(
`./pocketenv_${Deno.env.get("TAG") || ""}_${
Deno.env.get("TARGET") || target
}.tar.gz.sha256`
);

await ctr.stdout();
id = await exe.id();
id = await tar.id();
});

return id;
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Setup Fluent CI
uses: fluentci-io/setup-fluentci@v3
uses: fluentci-io/setup-fluentci@v4
- name: Run Dagger Pipelines
run: fluentci run deno_pipeline fmt lint
env:
Expand Down
23 changes: 0 additions & 23 deletions .github/workflows/codesee-arch-diagram.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/flakestry-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Publish a flake to flakestry"
on:
push:
tags:
- "v?[0-9]+.[0-9]+.[0-9]+"
- "v?[0-9]+.[0-9]+"
workflow_dispatch:
inputs:
tag:
description: "The existing tag to publish"
type: "string"
required: true
jobs:
publish-flake:
runs-on: ubuntu-latest
permissions:
id-token: "write"
contents: "read"
steps:
- uses: tsirysndr/flakestry-publish@main
with:
version: "${{ inputs.tag || github.ref_name }}"
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: release
on:
release:
types: [created]

jobs:
build:
name: release
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-apple-darwin
- aarch64-apple-darwin
steps:
- uses: actions/checkout@v3
- name: Setup Fluent CI
uses: fluentci-io/setup-fluentci@v4
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build
run: fluentci run . compile
env:
TAG: ${{ env.RELEASE_VERSION }}
TARGET: ${{ matrix.target }}
DAGGER_CLOUD_TOKEN: ${{ secrets.DAGGER_CLOUD_TOKEN }}
- name: Upload release assets
run: |
for ext in tar.gz tar.gz.sha256; do
export FILE=/app/pocketenv_${{ env.RELEASE_VERSION }}_${{ matrix.target }}.$ext
fluentci run github_pipeline release_upload
done
env:
TAG: ${{ env.RELEASE_VERSION }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DAGGER_CLOUD_TOKEN: ${{ secrets.DAGGER_CLOUD_TOKEN }}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

# Pocketenv

[![CodeSee](https://codesee-docs.s3.amazonaws.com/badge.svg?)](https://app.codesee.io/maps/public/85353fa0-c4dd-11ee-95ac-897807a2630c)
[![FlakeHub](https://img.shields.io/endpoint?url=https://flakehub.com/f/pocketenv-io/pocketenv/badge)](https://flakehub.com/flake/pocketenv-io/pocketenv)
[![deno module](https://shield.deno.dev/x/pocketenv)](https://deno.land/x/pocketenv)
![deno compatibility](https://shield.deno.dev/deno/^1.37)
[![flakestry.dev](https://flakestry.dev/api/badge/flake/github/pocketenv-io/pocketenv)](https://flakestry.dev/flake/github/pocketenv-io/pocketenv)

Pocketenv is a simple and lightweight tool to manage development workspace environments. It allows you to define and manage workspaces for your projects, and easily switch between them.

Expand Down
139 changes: 139 additions & 0 deletions flake.lock

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

45 changes: 45 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
description = "Manage your development environment with ease ✨";

inputs = {
utils.url = "github:numtide/flake-utils";
deno2nix = {
url = "github:tsirysndr/deno2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, utils, deno2nix }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ deno2nix.overlays.default ];
};
in
rec {

apps.default = utils.lib.mkApp {
drv = packages.default;
};

packages.default = pkgs.deno2nix.mkExecutable {
pname = "pocketenv";
version = "0.1.0";

src = ./.;
lockfile = "./deno.lock";
config = "./deno.json";
entrypoint = "./main.ts";
allow = {
all = true;
};
};

devShell = pkgs.mkShell {
buildInputs = with pkgs; [
deno
];
};
});
}

0 comments on commit 2973b46

Please sign in to comment.