Skip to content

Commit

Permalink
refactor(flake): create derivation manually
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovyerus committed Jun 30, 2024
1 parent 92a3698 commit db40e11
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 44 deletions.
32 changes: 4 additions & 28 deletions flake.lock

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

19 changes: 3 additions & 16 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,26 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
pnpm2nix = {
url = "github:nzbr/pnpm2nix-nzbr";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};

outputs = {
flake-utils,
nixpkgs,
pnpm2nix,
...
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
overlays = [pnpm2nix.outputs.overlays.default];
inherit system;
};
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.default = with pkgs;
mkShell {
buildInputs = [
nodejs
nodejs.pkgs.pnpm
pnpm
];
};

packages.default = pkgs.mkPnpmPackage {
src = ./.;
};
packages.default = pkgs.callPackage ./package.nix {};
}
);
}
38 changes: 38 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
lib,
stdenv,
nodejs,
pnpm,
}: let
packageJSON = builtins.fromJSON (builtins.readFile ./package.json);
in
stdenv.mkDerivation (finalAttrs: {
pname = packageJSON.name;
version = packageJSON.version;

src = lib.cleanSource ./.;

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

nativeBuildInputs = [nodejs pnpm.configHook];

buildPhase = ''
runHook preBuild
pnpm build
runHook postBuild
'';

installPhase = ''
runHook preInstall
mkdir -p $out
cp -r {dist/main.js,manifest.json} $out/
runHook postInstall
'';
})

0 comments on commit db40e11

Please sign in to comment.