Skip to content

Commit

Permalink
Use gleam proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoDaniels committed Oct 29, 2023
1 parent 60b71a4 commit 8ef6b9b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 43 deletions.
2 changes: 1 addition & 1 deletion buildWebsite.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ let
pkgs = (import ./nix/shared.nix).pkgs;

buildWebsite = pkgs.writeScriptBin "buildWebsite" ''
${pkgs.elmPackages.elm-pages}/bin/elm-pages build --debug
${pkgs.elmPackages.elm-pages}/bin/elm-pages build
'';

in pkgs.mkShell {
Expand Down
6 changes: 3 additions & 3 deletions nix/shared.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
let
pkgs = import (fetchTarball {
name = "nixpkgs-23.05-darwin";
url = "https://github.com/NixOS/nixpkgs/archive/fc541b860a28.tar.gz";
sha256 = "0929i9d331zgv86imvsdzyfsrnr7zwhb7sdh8sw5zzsp7qsxycja";
name = "nixpkgs-23.05-darwin-2023-10-05";
url = "https://github.com/NixOS/nixpkgs/archive/1e9c7c0203be.tar.gz";
sha256 = "10qbybc9k3dj1xap9n0i3z7pc3svzwhclgsyfzzsf8cfh8l518pn";
}) { };

jsHandler = pkgs.writeShellScriptBin "jsHandler" ''
Expand Down
61 changes: 22 additions & 39 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,28 @@ let
jsHandler = (import ./nix/shared.nix).jsHandler;

cockpitProxy = let
proxyName = "cockpit-proxy";
proxyVersion = "1.0.0";
proxySrc = fetchGit {
url = "https://github.com/MarcoDaniels/cockpit-cms-proxy.git";
rev = "7ae8b96057d1b67dfb2e5ff226f76be91fbc1777";
};
proxyElm = pkgs.stdenv.mkDerivation {
name = "${proxyName}-elm-dep";
proxyName = "cockpit-proxy";
proxyVersion = "2.0.0";
nixGleamSrc = pkgs.stdenv.mkDerivation {
name = "nix-gleam";
src = fetchGit {
url = "https://github.com/arnarg/nix-gleam.git";
rev = "d1d2d6bcc5be6ea6a2d31e48aa55e7ea3bd41a1f";
};
installPhase = ''
mkdir -p $out
cp $src/builder/default.nix $out
'';
};
nixGleam = (pkgs.callPackage nixGleamSrc {});
in nixGleam.buildGleamApplication {
pname = proxyName;
version = proxyVersion;
src = proxySrc;
buildInputs = [ pkgs.elm2nix pkgs.nix pkgs.cacert ];
buildPhase = ''
${pkgs.elm2nix}/bin/elm2nix convert > default.nix
${pkgs.elm2nix}/bin/elm2nix snapshot
'';
installPhase = ''
mkdir -p $out
cp default.nix registry.dat $out
'';
};
in pkgs.stdenv.mkDerivation {
name = proxyName;
version = proxyVersion;
src = proxySrc;
buildInputs = [ pkgs.elmPackages.elm pkgs.nix pkgs.cacert ];
configurePhase = pkgs.elmPackages.fetchElmDeps {
elmPackages = import proxyElm;
elmVersion = "0.19.1";
registryDat = "${proxyElm}/registry.dat";
src = fetchGit {
url = "https://github.com/MarcoDaniels/cockpit-cms-proxy.git";
ref = "refs/tags/v${proxyVersion}";
};
};
buildPhase = ''
elm make --optimize src/Main.elm --output=dist/elm.js
sed -e '1i\#!/usr/bin/env node' src/index.js > dist/${proxyName}
'';
installPhase = ''
mkdir -p $out/bin
cp -a dist/. $out/bin/
chmod +x $out/bin/${proxyName}
'';
};

dot2Env = pkgs.stdenv.mkDerivation {
name = "dot2Env";
Expand All @@ -61,7 +43,7 @@ let

# concurrently Pages with Proxy & Preview
start = pkgs.writeShellScriptBin "start" ''
${pkgs.concurrently}/bin/concurrently "${pkgs.elmPackages.elm-pages}/bin/elm-pages dev" "${cockpitProxy}/bin/cockpit-proxy"
${pkgs.concurrently}/bin/concurrently "${pkgs.elmPackages.elm-pages}/bin/elm-pages dev" cockpit_cms_proxy
'';

# to include flags: buildLambda AssetRequest "{flags:{token:'123',domain:'abc'}}"
Expand Down Expand Up @@ -100,6 +82,7 @@ in pkgs.mkShell {
pkgs.elmPackages.elm-pages
pkgs.elm2nix

cockpitProxy
dot2Env
testLambda
jsHandler
Expand Down

0 comments on commit 8ef6b9b

Please sign in to comment.