Migrate to npmlock2nix
This commit is contained in:
parent
d8f81c4a78
commit
fae59fbb3f
8 changed files with 73 additions and 12231 deletions
107
flake.nix
107
flake.nix
|
|
@ -3,70 +3,65 @@
|
|||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
npmlock2nix = {
|
||||
url = "github:nix-community/npmlock2nix";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }@inputs:
|
||||
flake-utils.lib.simpleFlake {
|
||||
inherit self nixpkgs;
|
||||
name = "tlaternet-templates";
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
npmlock2nix,
|
||||
}: let
|
||||
# At the moment, we only deploy to x86_64-linux. Update when we
|
||||
# care about another platform.
|
||||
system = "x86_64-linux";
|
||||
overlays = [
|
||||
(final: prev: {
|
||||
npmlock2nix = import npmlock2nix {pkgs = prev;};
|
||||
})
|
||||
];
|
||||
pkgs = import nixpkgs {inherit system overlays;};
|
||||
in {
|
||||
packages.${system} = rec {
|
||||
tlaternet-templates = pkgs.npmlock2nix.build {
|
||||
src = self;
|
||||
|
||||
overlay = final: prev: {
|
||||
tlaternet-templates = rec {
|
||||
packages = rec {
|
||||
nodeEnv = prev.callPackage ./nix/override.nix { pkgs = prev; };
|
||||
templates = prev.callPackage ({ stdenv, nodejs, rename, ... }:
|
||||
let nodeDeps = nodeEnv.shell.nodeDependencies;
|
||||
in stdenv.mkDerivation {
|
||||
name = "tlaternet-templates";
|
||||
src = ./.;
|
||||
installPhase = ''
|
||||
cp -r dist $out/
|
||||
'';
|
||||
|
||||
buildInputs = [ nodejs rename ];
|
||||
buildPhase = ''
|
||||
ln -s ${nodeDeps}/lib/node_modules ./node_modules
|
||||
export PATH="${nodeDeps}/bin:$PATH"
|
||||
postFixup = ''
|
||||
${pkgs.rename}/bin/rename 's/.html$/.html.hbs/' $out/browser/*.html
|
||||
'';
|
||||
|
||||
npm run build
|
||||
'';
|
||||
node_modules_attrs = {
|
||||
buildInputs = with pkgs; [
|
||||
pkg-config
|
||||
python3
|
||||
vips
|
||||
glib
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
installPhase = ''
|
||||
cp -r dist $out/
|
||||
'';
|
||||
default = tlaternet-templates;
|
||||
};
|
||||
|
||||
postFixup = ''
|
||||
rename 's/.html$/.html.hbs/' $out/browser/*.html
|
||||
'';
|
||||
}) { };
|
||||
};
|
||||
defaultPackage = packages.templates;
|
||||
|
||||
devShell = prev.mkShell {
|
||||
buildInputs = with prev;
|
||||
with nodePackages;
|
||||
[
|
||||
nodejs
|
||||
node2nix
|
||||
|
||||
# Handy dev tools
|
||||
prettier
|
||||
typescript
|
||||
typescript-language-server
|
||||
] ++ packages.nodeEnv.shell.buildInputs;
|
||||
};
|
||||
|
||||
# TODO: This would be the ideal. Sadly, parcel isn't smart
|
||||
# enough to pull its plugins from $NODE_PATH.
|
||||
#
|
||||
#
|
||||
# devShell = packages.nodeEnv.shell.override {
|
||||
# buildInputs = with prev; with nodePackages; [
|
||||
# node2nix
|
||||
|
||||
# prettier
|
||||
# typescript-language-server
|
||||
# ];
|
||||
# };
|
||||
devShells.${system} = {
|
||||
default = pkgs.npmlock2nix.shell {
|
||||
src = self;
|
||||
node_modules_attrs = {
|
||||
buildInputs = with pkgs; [
|
||||
pkg-config
|
||||
python3
|
||||
vips
|
||||
glib
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue