tuckershea / constellation

My laptop and server configuration
0 stars 0 forks source link

Surfingkeys is broken #99

Open NoRePercussions opened 1 month ago

NoRePercussions commented 1 month ago

Surfingkeys broke while being updated to MV3.

This also brings to my attention that I'd prefer to build from source for an extension that can log my keystrokes.

A dream2nix configuration for the chrome extension is attached in the comments, but I may think about how I want to actually include it. Potentially it is time for my own NUR instance.

NoRePercussions commented 1 month ago

flake.nix

{
  description = "Surfingkeys extension builder";

  inputs = {
    dream2nix.url = "github:nix-community/dream2nix";
    nixpkgs.follows = "dream2nix/nixpkgs";
  };

  outputs = {
    self,
    dream2nix,
    nixpkgs,
  }: let
    eachSystem = nixpkgs.lib.genAttrs [
      "aarch64-darwin"
      "aarch64-linux"
      "x86_64-darwin"
      "x86_64-linux"
    ];
  in {
    packages = eachSystem (system: {
      default = dream2nix.lib.evalModules {
        packageSets.nixpkgs = nixpkgs.legacyPackages.${system};
        modules = [
          ./default.nix
          {
            paths.projectRoot = ./.;
            paths.projectRootFile = "flake.nix";
            paths.package = ./.;
          }
        ];
      };
    });
  };
}

default.nix

{
  lib,
  config,
  dream2nix,
  ...
}: {
  imports = [
    dream2nix.modules.dream2nix.nodejs-package-json-v3
    dream2nix.modules.dream2nix.nodejs-granular-v3
  ];

  mkDerivation = {
    src = builtins.fetchGit {
      shallow = true;
      url = "https://github.com/brookhong/Surfingkeys";
      rev = "965301c079852f9d310145d823628d107e940588";
    };

    # by default we run `npm build` in buildPhaseNodejs,
    # which runs tests which fail without chromium
    preBuildPhases = lib.mkForce [];
    buildPhase = ''
      npm run build:prod
    '';

    preInstallPhases = lib.mkForce [];
    installPhase = ''
      mkdir -p "''${out}"
      cp -r "''${nodeModules}/surfingkeys/dist/production/chrome/." "''${out}"
    '';
  };

  deps = {nixpkgs, ...}: {
    inherit
      (nixpkgs)
      fetchFromGitHub
      stdenv
      ;
  };

  nodejs-granular-v3.overrides.puppeteer.env.PUPPETEER_SKIP_DOWNLOAD = 1;

  name = "surfingkeys";
  version = "0.0.0";
}