Skip to content

Commit

Permalink
nix: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelCoding committed Nov 20, 2024
1 parent 825220f commit 86c4969
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 97 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/gh-pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "pages"

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

permissions:
actions: read
contents: read
pages: write
id-token: write
deployments: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v30

- uses: DeterminateSystems/magic-nix-cache-action@v8
with:
diagnostic-endpoint: false
use-flakehub: false

- name: Build search
run: nix build -L .

- name: Publish to Cloudflare Pages
if: "github.repository_owner == 'tlm-solutions'"
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 2a09613716e511a8fe8ca74abc084762
projectName: tlms
directory: result
gitHubToken: ${{ github.token }}
24 changes: 0 additions & 24 deletions derivation.nix

This file was deleted.

68 changes: 7 additions & 61 deletions flake.lock

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

20 changes: 8 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
pnpm2nix = {
url = "github:nzbr/pnpm2nix-nzbr";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, pnpm2nix, flake-utils, ... }:
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
pkgs = (import nixpkgs) {
inherit system;
};
in
{
packages = rec {
kindergarten = pkgs.callPackage ./derivation.nix {
mkPnpmPackage = pnpm2nix.packages."${system}".mkPnpmPackage;
};
kindergarten = pkgs.callPackage ./package.nix { };
default = kindergarten;
};
}
) // {
overlays.default = final: prev: {
inherit (self.packages.${prev.system})
kindergarten;
overlays.default = _: prev: {
inherit (self.packages.${prev.system}) kindergarten;
};
};
}
36 changes: 36 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{ lib, stdenv, nodejs, pnpm, domain ? "tlm.solutions" }:

let
manifest = lib.importJSON ./package.json;
in
stdenv.mkDerivation (finalAttrs: {
pname = "website";
inherit (manifest) version;

src = lib.cleanSource ./.;

postPatch = ''
substituteInPlace src/app/data/api.domain.ts \
--replace 'staging.tlm.solutions' '${domain}'
'';

pnpmDeps = pnpm.fetchDeps {
inherit (finalAttrs) pname version src;
hash = "sha256-AdTHpm4HPoXbdSpF6QNboqFJchpRoLCvBk8xOpaxWkc=";
};

nativeBuildInputs = [ nodejs pnpm.configHook ];

buildPhase = ''
pnpm run build:ci
'';

installPhase = ''
runHook preInstall
mkdir -p $out/en
mkdir -p $out/de
cp -r ./dist/browser/en-US/* $out/en/
cp -r ./dist/browser/de-DE/* $out/de/
runHook postInstall
'';
})

0 comments on commit 86c4969

Please sign in to comment.